How to fetch data from node mcu to arduino uno

Hi, guys currently I am writing a code for two-way communication in between the Arduino Uno board with the node MCU(Amica). I was able to send multiple sensor data from Arduino to NodeMCU. However, I am having trouble fetching multiple data from NodeMcu back to Arduino Uno. The interconnection between the two boards is shown below. Can anybody shows me how to fetch multiple data(for example A=111 and B=222) to the Arduino Uno from Nodemcu?? I really need helps. Appreciate a lot.

Arduino 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);

If the NodeMCU uses 3.3V logic (which it most likely does) you should start by getting a logic level shifter since the Arduino uses 5V logic and this may damage the NodeMCU.

1 Like

Hi @copernicus_yew

Please redo your initial post and enclose your code in </> tags.

If you don't know how to do this then why not read the initial thread when registering in the forum.
Then read: How to get the best out of this forum.

How to get the best out of this forum - Using Arduino / Installation & Troubleshooting - Arduino Forum

RV mineirin

1 Like

Hi, ruilviana. Thanks for the information. Will amend my post.

Hi, Danois. Thanks for the information. I will a voltage divider to connect the arduino Uno with the NodeMCU.

Some pins on the NodeMCU may be 5V tolerant, look at this guide and also try to search for "5v tolerant pins" for your specific board.

EDIT: This may be better.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.