How to fetch multiple data from Nodemcu(Amica) to Arduino Uno

Dear guys, I am currently writing codes on two-way communication between Arduino Uno and Node MCU. I was able to send multiple dataS from Arduino Uno to NodeMCU. However, I have some trouble fetching multiple data from NodeMcu back to Arduino Uno. I have tried out some code myself but it not working as I expected. The connection between the Arduino Uno and NodeMCU is as below. Can you show me how to pass ( A= 128 and B=456) from NodeMCU to the Arduino Uno? I really need some helps in fetching data from NodeMCU to Arduino Uno. Really appreciate it if you can help me out here.

Arduino Uno Code

const int GSR=A0;
int sensorValue=0;
int gsr_average=0;
int muscle=0;
char c; 
String dataIn;                      

void setup(){
Serial.begin(9600);              //hardware serial communicate with PC  

void loop(){
  long sum=0;
  for(int i=0;i<10;i++)           //Average the 10 measurements to remove the glitch
      sum += sensorValue;
   gsr_average = sum/10;
   muscle = 10;
   Serial.print(gsr_average);         Serial.print("A");
   Serial.print(muscle);              Serial.print("B");
   //reset variable

NodeMcu code

#include <SoftwareSerial.h>
SoftwareSerial DataSerial(D6, D7);        //D6=12, D7=13

char c;
String dataIn;
int8_t indexOfA, indexOfB, indexOfC;
String GSR;                              
String Muscle; 
int ReturnData1 = 888;
int ReturnData2 = 999;

void setup() {
Serial.begin(9600);                      // Open serial communications and wait for port to open:
DataSerial.begin(9600);                  //software serial communicate with NodeMCU

void loop() { 
    while(DataSerial.available()>0)       //read data serial
    //test data
    else       {dataIn+=c;}


        //Show all the data in serial monitor
        Serial.println("GSR = " + GSR);
        Serial.println("Muscle = " + Muscle);
        //reset variable

void Parse_the_Data()
  indexOfA = dataIn.indexOf("A");
  indexOfB = dataIn.indexOf("B");
  GSR = dataIn.substring (0, indexOfA);
  Muscle = dataIn.substring(indexOfA+1, indexOfB);

I’m not familiar with the Nodemcu, but I assume it’s pretty close to the ESP32 dev kits I use…

First, you have the Nodemcu serial uart connected to pins 0 & 1 of the UNO. Those two pins are basically connected to the USB connector on the UNO. Basically when you communicate with the UNO via a USB cable to your computer (to upload code, serial monitor) that transmission takes place on pins 0 & 1. `See here. Since the UNO only has one hardware serial port, you need to use software serial on the UNO to create a new serial port.

I looked up the Nodemcu’s pinout. It appears to have 2 hardware serial ports. The RX & TX pins are the Serial0 port, the one connected to the USB connector. Serial2 uses pin D8 for TX and pin D7 for RX. So you could use that port instead of the software serial port you create on the Nodemcu.

Since you have data going from UNO to Nodemcu, I wouldn’t change anything on the Nodemcu yet. I would focus on creating a software serial port on the UNO, maybe pins 2 & 3, and wire the Nodemcu up to those pins. That should give you data to the UNO from Nodemcu. Once working, I would then do away with software serial on Nodemcu and use Serial2 instead.

Hope this helps,

Hi Randy, Thank you for explaining to me. I have developed a new code lately. And it seems working fine. I get to receive data and send data from both the Arduino UNO and node MCU. I have connected the circuit as below:
serial connection
Arduino Uno- Nodemcu
10(RX) - D2(TX)
11(TX) - D1(RX)