Solved disconnect/cmd skipped etc issues. My advice

Fellow Blynkers,

I had a project that ran great on a Mega with an ESP8266 as a WiFi adapter, but ran into a number of issues getting the same code to work on an ESP8266 natively. I finally worked them all out tonight, and thought I would share my observations with the community, as I have noticed many of you having similar issues. Hopefully, my experience can help you.

Basically, I was getting lot of errors: constant disconnects/reconnects, cmd skipped, login timeout, etc. Here are some observations and approaches I took to resolve them all (no more errors!!) This is a decent-sized sketch, about 800 lines of code, so no cutting corners.

  1. Be aware of your processor speed. The 8266 executes instructions a lot faster than the Uno/Mega, so you may need to throttle back a bit. I have a lot of widgets on my screen, and the flood of initializations was choking Blynk. I just added some 1 second delays after every 4 widget updates or so.
  2. Use push updates for widgets to avoid unnecessary calls to BLYNK_READ. I had 4 value displays that were being updated every second but the values were frequently the same. So I switched the update frequency to “push” and wrote a timer-called function to send the update only when it changed. (The documentation says no more than 10 updates per second, so make sure you respect that.) This eliminated a lot of needless messages.
  3. Use simple, short, modular functions. There is a lot of logic going on in my app, which I suspect was sometimes running too long and locking Blynk out. So I rewrote the code to use more modules and had them do as few things as possible. Then the next important step:
  4. Use a lot of timer routines. I went from 1 timer-called routine (SimpleTimer) to 5 (calling the new modules in item 3 above). Each one has a #define for how frequently it is called and they are of course staggered. This allowed me to easily tune the volume of Blynk messages to balance the message traffic out while still being responsive.
  5. There is now nothing else in loop() besides the calls to Blynk.run() and Timer.run().

All told, this eliminated all of the runtime errors I was getting.

I hope others will find this information useful and save you some time, effort, and most of all frustration!

RD7

6 Likes

Thanks very much for this very useful information.

Please share your experience on combining mega and esp8266 (nodemcu v3) in more detail.
I went to several forums for this and could not find any clear advice.
Lay out detailed information-the firmware version for your devices, preferably with all files uploaded to the cloud - the firmware program itself, the firmware files, video or photo that you chose.
Sorry if I ask you to chew this process too carefully, but I can not get quite a long time to get a positive result.
I try different firmwares, sketches, tx/rx combinations, voltage, different boards, but the result [1609] ESP is not responding

First of all, I see no mention in @Rom3oDelta7’s post from almost 3 years ago of using a NodeMCU as a Wi-Fi adapter for a Mega. An ESP8266 is mentioned, but I’m fairly certain that this would be the ESP-01 variation that’s commonly used for this.

Secondly, if I were asked to:

it would feel like I was back in school, not participating in a community forum. As a result, I’d probably tell you where to get off.

If you did a bit of searching then you’d come across this recent topic:

As you’ll see, if you take the time to read it, very few people thought that it was worth the time or effort to go down that route, but the author of the thread managed it working in the end.

Pete.

2 Likes