Blynk project disconnecting and connecting in approximately 10sec intervals (as showing up in blynk app)

hi,
the project involves switching a led ON from the blynk app. the setup is:
-arduino uno and esp8266
-the blynk app is running on android 7.0.
-using blynk server and blynk library version v0.5.0

after getting the ready and ping status in arduino ide serial monitor, the project shows connected and disconnected in roughly 10 sec intervals. i am not understanding what i am doing wrong. please help

code:

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


#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "b136f026d8e54fa5b61e1ea45bc29eb1";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "j5 net";
char pass[] = "shittyshit";

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, millis() / 1000);
}

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

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

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

Possible network issuesā€¦ and too high a rate for a ESP/Arduino linkā€¦ 9600 BAUD is recommended. And remember, you also have to change the ESP BAUD rate via AT commands as well as the sketch command.

For software serial - Yes (from my experience up to 33kbps), But for hardware UART Iā€™m using 115kbps on Atmega32 and ESP-01 with 1.5.4 SDK without major issue. The only thing to handle is connection checking and hardware reset/reinit after it is lost (happens sometime - not very often). What is interesting, I tried newer version of SDK (2.0.0) and failed. It worksā€¦ or notā€¦ Without any noticeable reasonā€¦

I also run a 115200 BAUD rate on my ESP/MEGA Serial1 connectionā€¦ BUT I am not talking about that, here, in this OPs issue :wink:

Correctā€¦ I was too lazy to dig into code. Then it is a waay too fast for small Atmega on basic Arduino boardā€¦ As noted - up to 33kbps it is working for me with SoftwareSerial

1 Like

I would still throttle it down to 9600 unless you think 33K has a benefit.

Then, there is other question: Why use software serial emulation in ā€œproductionā€ (final) version of firmware at all?? Iā€™m disabling all debug output, and using UART (or it is USART on ATMEGAā€™s?) for ESP comm. The other option: Use DEBUG on software serial, and disable it after debugging?? Never tried this one thoughā€¦

Because many Arduinos only have the one hardware UART, and swapping between ESP and programing is a painā€¦ and you canā€™t reprogram an ā€˜Arduino with shieldā€™ via OTA, that I am aware ofā€¦ but really all beyond the point of this topic :slight_smile:

Makes no difference to this OPs issue, as the OP is using the programming port for the debug and the software port for the connection

That is all true, but I mean the ā€œfinalā€ setup, where debug is not needed, as well as frequent flashing. Then ONE, and only one serial port seems to be fairly enough! Naturally a setup composited from ESP as a ā€œshieldā€ and Arduino as a controller is much more inconvenient than just using ESP standalone and it should be noted whenever possible. But Iā€™m not helping @ramchaitanya95 much with this discussion, soā€¦ :slight_smile: