BLYNK2.0 SoftwareSerial NodeMCU

Hello All,
Im transferring working code from Blank Legacy to Blynk2.0
I have a software serial function transmitting simple int values from a NODEMCU to a Arduino MEGA which no longer seems to transmit when called.

Do I need an updated library or something in the new Blynk2.0 Code?

The code looks like this:

#define BLYNK_TEMPLATE_ID "****removed**"
#define BLYNK_DEVICE_NAME "**removed****"
#define BLYNK_FIRMWARE_VERSION        "0.1.0"
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
SoftwareSerial NodeMCU(D2,D3);   //RXD2 TXD3

Then in void setup

NodeMCU.begin(9600);

The code send function is


void Transmit_Blynk_Data_to_Mega() {
    i = transmit_blynk_code + 10;           // Transmits the code and adds 10 to the number
      NodeMCU.print(i);
      NodeMCU.println("\p");
      delay(30);
      Serial.print("TX_Code_to_MEGA:");
      Serial.print(i);
      Serial.println("");
      delay(20);
      }

Nothing is arriving at the MEGA which works fine when I upload the old code and use the Blynk legacy APP.

Thanks for any help

You’ll need to use Library version 1.0.1 with Blynk 2.

What does your serial monitor show?

Pete.

Thanks.
I updated the Blynk Library to this one already

Do you mean another library for the SoftwareSerial?
Can you please send a link

Thanks for the answer.
The serial monitor shows everything as normal when the button on the phone app is pressed.
i.e. that the softwareserial command has been sent

Manuel Mode Selected
TX_Code_to_MEGA:15

Which is exactly what it should say.

I was more interested in what it shows in boot-up in relation to Blynk.

Pete.

On boot it it shows this


[292] Using default config.

>[292] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.1 on NodeMCU

[424] --------------------------
[459] Product:  ####removed###
[490] Firmware: 0.1.0 (build Oct 23 2021 17:33:12)
[544] Device:   NodeMCU @ 80MHz
[579] MAC:      48:3F:DA:36:18:15
[615] Flash:    4096K
[639] ESP core: 2.7.4
[663] ESP SDK:  2.2.2-dev(38a443e)
[701] Boot Ver: 6
[720] Boot Mode:1
[740] FW info:  476480/1617920, MD5:a0ccc096096b3973fb74aff7d8c94cef
[955] Free mem: 25440
[955] --------------------------
[955] INIT => WAIT_CONFIG
[1740] AP SSID: ####removed###
[1740] AP IP:   192.168.4.1
[1741] AP URL:  blynk.setup
[41621] WAIT_CONFIG => CONFIGURING
[220770] CONFIGURING => WAIT_CONFIG
[274387] WAIT_CONFIG => CONFIGURING
[278354] Sending board info...
[278471] Scanning networks...
[280657] Found networks: 5
[283778] Applying configuration...
[283779] WiFi SSID: o2-WLAN61 Pass: ####removed###
[283779] Blynk cloud:####removed### @ blynk.cloud:443
[283818] CONFIGURING => SWITCH_TO_STA
Volt:0.00|Loop:0|Docked:1|Running:0|Parked:0|Charge:0|Tracking:0||Wire Status:OFF
[283944] Switching to STA...
[285224] SWITCH_TO_STA => CONNECTING_NET
Volt:0.00|Loop:0|Docked:1|Running:0|Parked:0|Charge:0|Tracking:0||Wire Status:OFF|Docked Counts Wire:0|Setup Sync:1
[285257] Connecting to WiFi: ####removed###
[293796] Using Dynamic IP: 192.168.1.53
[293796] CONNECTING_NET => CONNECTING_CLOUD
Volt:0.00|Loop:0|Docked:1|Running:0|Parked:0|Charge:0|Tracking:0||Wire Status:OFF|Docked Counts Wire:1|Setup Sync:2
[309110] Current time: Sat Oct 23 15:41:44 2021
[309111] Connecting to blynk.cloud:443
[310039] Ready (ping: 12ms).
[310256] CONNECTING_CLOUD => RUNNING
[310290] Configuration stored to flash


***

So you’re actually using the Edgent sketch? That isn’t clear from what you’ve previously posted.

I’d suggest that you look at the Settings.h tab for whatever board type you’ve defined, or the default board type of you haven’t defined a board type.

You probably have pins defined that conflict with those used for software serial.

Pete.

Is there a better approach?
I’m open to change to a different way if it makes it easier.
Thanks

It depends whether you’re able to identify and resolve the conflicts in Settings.h

Pete.

Thanks for the great tip. I modifed the Settings for the NodeMCU Board with ‘D’ before the pin. Also I needed to change the LED to D4. I also added a define for the TX and RX pins and called the include <Software.serial.h> in the BlankEdgent.h tab. Nopw it all seems to work great


#if defined(USE_NODE_MCU_BOARD) || defined(USE_WEMOS_D1_MINI)

  #define BOARD_BUTTON_PIN            D0
  #define BOARD_BUTTON_ACTIVE_LOW     true

  #define BOARD_LED_PIN               D4
  #define BOARD_LED_INVERSE           true
  #define BOARD_LED_BRIGHTNESS        255
  #define RX                          D2
  #define TX                          D3

***

Thanks for the help!
1 Like