Using blynk.begin(); block all serial communication

Hi, all my project is based on a local server, connected with a proteus simulation.

I’m using arduino nano (ATMEGAs) communicating between each other via serial.

every separate parts (blynk w/ single arduino & network of arduinos) works fine on their own.

the troubles began when i connected all together, the Blynk.begin(auth, Serial); method seem to block all other serial communications


#include <BlynkSimpleStream.h>
#include <SoftwareSerial.h>

SoftwareSerial SerialBlue (2, 3); // RX, TX
SoftwareSerial mySerial (4, 5); // RX, TX

// Pin Assignments
int redPin=8,greenPin=9,bluePin=10;


// app authentication token fetched from blynk app
char auth[] = "XXXXXXXXXXXXXXXXXXXXXXXXXXnwT9";
BlynkTimer timer;

void  sens1(long state)
{
  mySerial.println("call1");
  Blynk.virtualWrite(V0, state);
}

void  sens2(long state)
{
  mySerial.println("call2");
  Blynk.virtualWrite(V1, state);
}

void  sens3(long state)
{
  mySerial.println("call3");
  Blynk.virtualWrite(V2, state);
}

void  sens4(long state)
{
  mySerial.println("call4");
  Blynk.virtualWrite(V3, state);
}

void (*ptr_arr[])(long) = {&sens1, &sens2, &sens3, &sens4}; 

void setup()
{
  //Set the three LED pins as output
  pinMode(redPin,OUTPUT);
  pinMode(greenPin,OUTPUT);
  pinMode(bluePin,OUTPUT);

  // Blynk will work through Serial
  Serial.begin(9600);
  mySerial.begin(9600);
  SerialBlue.begin(9600);
  //Blynk.begin(auth, Serial);  // commenting this makes the rest work
  timer.setInterval(50L, coRoutine);
}

void coRoutine()
{
  mySerial.println("ok"); // this works only when i don't begin blynk
  if (SerialBlue.available() > 0)
  {
    int c = SerialBlue.read();
    String s = String(c);
    mySerial.println("receipt" + c);
    (*ptr_arr[c / 10 - 1])(c % 10);
  }  
}

void loop()
{
  // Blynk.run();
  timer.run();
}

here is a simplified version of this code for you to reproduce:

#include <BlynkSimpleStream.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial (4, 5); // RX, TX  // this is supposed to be a serial terminal

// app authentication token fetched from blynk app
char auth[] = "XXXXXXXXXXXXXXXXXXXXXXXXXXnwT9";
BlynkTimer timer;

void setup()
{

  // Blynk will work through Serial
  Serial.begin(9600);
  mySerial.begin(9600);
  //Blynk.begin(auth, Serial);
  timer.setInterval(1000L, coRoutine);
}

void coRoutine()
{
  mySerial.println("ok");
}

void loop()
{
  // Blynk.run();
  timer.run();
}

Thank you for your patience, don’t hesitate to ask for additional informations.

Is the device showing as online in the app?
Blynk.begin is a blocking function, and the code execution won’t progress beyond that point until a connection is established. I suspect that the connection is failing.

If you add:

#define BLYNK_PRINT mySerial

at the beginning of your code then you should get more feedback via your pin 4/5 + FTDI interface.

Pete.

Oh yes, i didn’t thought about it.
This should fix this false issue.

Thank you for the help, i guess the topic can be closed now.