BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Solved disconnect/cmd skipped etc issues. My advice


#1

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


[SOLVED] Arduino + ESP8266 ESP-01(AI-Cloud, Black Version)
Repeatedly receiving "Cmd error" even with simplest examples
#2

Thanks very much for this very useful information.