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

Blynk Edgent corrupts serial input

OK so I am migrating from Blynk1 to Blynk2 and though the edgent facility with OTA firmware upgrades would be nice.
However when using Blynkedgent.h it is not possible to disable debug prints (compile errors come up if you don’t include a #define BLYNK_PRINT Serial)

What I notice is that the edgent code somewhere is reading the serial input! (not just using it for debug output)

So this very simple example will miss random serial input (the character input is simply output somewhere by the Blynkedgent.run code and never received by my code.

I can remove the issue by #define BLYNK_PRINT Serial1

But sadly in my real project I need Seral and Serial 1 on an ESP8266 and there are no more serial to divert the edgent debug output to.

If I use the basic Blynk code, it a) doesn’t corrupt the serial input and b) debug prints can be disabled

Any ideas?

Here is stripped down code to demonstrate the issue

#define BLYNK_TEMPLATE_ID "***********"

#define BLYNK_DEVICE_NAME "**********"

#define BLYNK_FIRMWARE_VERSION        "1.1.0"

#define BLYNK_PRINT Serial  //Enable define for basic level Blynk debug info

#define ESP_SDK_VERSION_NUMBER  0x020202 //Kludge as I have a later version but Blynk never detects this

#define USE_NODE_MCU_BOARD

#include <Arduino.h>

#include "BlynkEdgent.h"

//**************************************************************************************************

void setup() {

  Serial.begin(9600);

  Serial.println("Blynk Rx Corruption Test");

  delay(1000);

  BlynkEdgent.begin();

}

void loop() {

  if ((Serial.available()>0)) {

    Serial.println(Serial.read());

  }

  BlynkEdgent.run(); //Note corrupts Rx buffer

}

Here is example output, note last line where first ‘a’ was simply echoed back by something but not detected by my code

Blynk Rx Corruption Test
[1283]
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.1.0 on ESP8266

 #StandWithUkraine    https://bit.ly/swua



>[5374] Using Dynamic IP: 192.168.1.222
[5486] Current time: Tue Sep 20 15:18:03 2022
[5486] Connecting to blynk.cloud:443
[6441] Ready (ping: 11ms).
a97
a97
aaa97

please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly. Triple backticks look like this: ```

Done - thanks for the tip

1 Like

Have you tried the SoftwareSerial approach…

#include <SoftwareSerial.h>
SoftwareSerial Dummy_Serial;
#define BLYNK_PRINT Dummy_Serial

I’m curious to know what this means…

Pete.

Yes adding your code to define (but not use) a Software serial removes the issue. It’s not really a long-term fix since I now cannot have Blynk Debug messages.
#define ESP_SDK_VERSION_NUMBER 0x020202 line is needed because in the Blynk src header files (for example BlynkSimpleEsp8266_SSL.h is the following code which will halt the complier since the constant is never defined (unless I manually define it)

#if ESP_SDK_VERSION_NUMBER < 0x020200
#error Please update your ESP8266 Arduino Core
#endif

This maybe due to a conflict with a file called version.h (I have my own version.h file)

Well, obviously if you’re using your Serial and Serial1 ports for something else then you can’t also use them for debug messages.
The only option then is to redirect your SoftwareSerial output to a couple of available pins and add an FTDI adapter to those pins, or if you don’t have any available pins to use a different board type.

Pete.

But I want to use the same functionality as the normal Blynk code. There is a bug in the Edgent code

In Standard Blynk I can use Serial Rx for my program And Serial TX for the Blynk debug messages (as my debug messages)

The bug in Edgent is that it randomly reads Serial input and stops my program from receiving it. I repeat, this bug does not appear in the standard Blynk code

The Edgent example is very different from what you will be running in your Legacy sketch.
Maybe you should sim play convert your Legacy sketch to IoT then add the minimal Blynk.Air OTA functionality?

Pete.

I have already converted from legacy Blynk that is not the issue

The bug is in the Edgent code, the Blynk2 code works without the bug. Why would I want to manually redevelop all the functionality of the edgent OTA code when it already exists (albeit with a bug)

You don’t need to…

Pete.

1 Like