BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

HC-05 and Blynk don't work

In these days i have tryed to use my bluetooth and it work very well. But i have only a question, when i connect the arduino with pc in order to upload a new sketch it doesn’t work. If i disconnect the cable tx from hc-05 and i upload a new sketch its ok. Thk

So, after all this previous discussion, you seem to have decoded to attach your HC-05 to the hardware serial port (pins 0 & 1) rather than a SoftwareSerial port.
Why is this?

Pete.

I use port RX and TX of Arduino because i thought it was correct. Do you think that i must use other port? But because i can’t upload my sketch with port Tx and Rx?

If you want to be able to upload code via the single hardware serial port, and/or you wish to use the single hardware serial port for debugging, then you can’t have the HC-05 attached to that port.

If you wish to run the HC-05 at a baud rate higher than 9600 then you have no alternative but to use the hardware serial port to connect the HC-05 to the Nano.

Pete.

I am using hc-05 with bound rate 9600, and i want upload the sketch even if the Tx and Rx of hc-05 Is connected.
So must i connect hc-05 in pin 2 and 3?

Yes, assuming that you are creating a SoftwareSerial port that uses those two pins, and that you modify your sketch so that the SoftwareSerial port you create is used in the Blynk connection process.

Pete.

This is my sketch and it work very well.

[Unformatted code removed by moderator]

Tomorrow when i will be in my laboratory i will try to use pin 2 and 3.
I will mus use a voltage divider in order to ude this 2 pin?
Thk for your team

Your incorrectly formatted code has been deleted.

Please post code correctly, as you did in your first post in this topic.

No.

Pete.

I use this sketch in my arduino nano but if i connect pin 2 and 3 to Rx and Tx of HC-05, it doesn’t send any data to my Blink application.
Pls help me i don’t understand why:

[Unformatted code removed by moderator]

Pete.

[Unformatted code removed by moderator]

Pete.

#include <SPI.h>

#include <SD.h>

#define BLYNK_USE_DIRECT_CONNECT

#include <BlynkSimpleSerialBLE.h>

char auth[] = "92VFpWptDnjibDuxg1Vd9HGetmWkAhD_"; //codice applicazione

File Storico;

void setup()

{

  Serial.begin(9600); // attivazione del seriale per risultati di arduino

  Blynk.begin(Serial, auth); //Attivazione della trasmissione al server Blink
  
  pinMode (A0, INPUT); //Impostazione del pin in Input Analogico per lettura valori

  pinMode (A1, INPUT); //Impostazione del pin in Input Analogico per lettura valori  

  if (!SD.begin(10)){
      Serial.println("Errore");
      while(1);
    }

}


void loop()
{

  Blynk.run();

  int Conta = Conta + 1;

  float R1 = 62000; //Restistenza a monte.

  float R2 = 8000;  //resistenza a valle.

  float calc_res = (R1 + R2) / R2;  // Partitore di tensione
  

//Segnali in ingresso

  int ValPinBatt = analogRead(A0);  // Leggo valore in ingresso im porta analogica

  int ValPinCorr = analogRead(A1);  // Leggo valore in ingresso im porta analogica

  // Trasformazione in Volt dei segnali digitali -- Per la Batteria

  float Vpin = ValPinBatt*4.69/985;  // Per settare il valore "982" consiglio di farlo dal seriale vedendo cosa leggere quando la batteria è al max 4.69
  
  //4.8V = 4,2V max carica che scende subito dopo la carica
  //ma io max carica fino a 4,34V = 3,8V per batteria --> 982 Analogici
  //per batteria scarica 4.11V = 36V
  
  float Vbatt = Vpin * calc_res;  //VALORE PER APPLICAZINE

  int ValBattPerc = Vbatt*100/38; // Vbatt:36=ValBattPerc:100 VALORE PER APPLICAZIONE

  if (ValBattPerc > 100){     // Evitare valori superiori a 100 per le batterie

    ValBattPerc = 100;
    
    }

// Trasformazione in Volt dei segnali digitali -- Per la Corrente

  float CorrBatt = ValPinCorr*2.36/520-2.36;

  if (CorrBatt < 0){     // Valori al di stotto dello 0
    CorrBatt = 0;
    
    }

//Scrivo sull'SD card

if (Conta = 2000){
  
String Storico_SD = 
  String(Vbatt)+";"+
  String(CorrBatt)+";"+
  String(CorrBatt);
Storico = SD.open("File_Batteria", FILE_WRITE);
if(Storico){
  Storico.close();
 
  }

Conta = 0;

}


// Segnali verso l'applicazione

  Blynk.virtualWrite(V0, Vbatt); //Byte di scrittura applicativo VOLT

  Blynk.virtualWrite(V1, ValBattPerc); //Byte di scrittura applicativo % BATTERIA

  Blynk.virtualWrite(V2, CorrBatt); //Byte di scrittura applicativo CORRENTE (A)

  
  //delay(1000);

  //Serial.println(ValPinBatt);
  
  //Serial.print(Vpin);
  
  //Serial.println(Vpin);                

  //Serial.print("Percentuale batteria:");
  
  //Serial.println(Vbatt); 

  //Serial.println(ValPinCorr);

  //Serial.print("Corrente erogata:");
  
  //Serial.println(CorrBatt); 

}

As I said before…

You haven’t created a SoftwareSerial port, and you are still telling your sketch to use the hardware serial port for the Blynk connection process…

You also havent taken any notice of this advice…

I’d recommend that you go back to the example I linked to earlier…

as it has everything you need to connect with your current setup, provided you change the SoftwareSerial pin from 10 & 11

Pete.

1 Like

I tried to use your link But i don’t understand what is it in the serial.begin(serialBLE, auth) becouse serialBLE i don’t keon what is it. Can gou help me?


#define BLYNK_TEMPLATE_ID           "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME           "Device"
#define BLYNK_AUTH_TOKEN            "YourAuthToken"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX

#include <BlynkSimpleSerialBLE.h>

char auth[] = BLYNK_AUTH_TOKEN;


void setup()
{
  // Debug console
  Serial.begin(115200);

  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);

  Serial.println("Waiting for connections...");
}

void loop()
{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

Change this…

to this…

SoftwareSerial SerialBLE(10, 11); // RX, TX

Pete.

I try but i don’t work.
how could i upload the sketch in arduino while it is connect with Tx and Rx with HC-05?
It is a big problem for me

You are telling your hardware that the HC-05 is connected to pins 10 and 11, not 0 and 1…

Pete.

I tryed to use 10 and 11 pin but it didn’t work. So u use a transistor in order to turn off the hc-05 when arduino is powered by usb.

Now i have a new question, in blynk app a use a super chart where i can export the data in CSV. But when i try it didn’t work do you know why?
I put data in blynk with hc-05 (BT) but my smartphone is connected to the blynk server. But when i click on export ti CSV and send to my mail it doesn’t work.

Probably because you’re using Bluetooth.

Pete.