I'm a newbie coder who trying some programming to improve my skills and do projects. I was trying to send data from the Arduino Mega board to the NodeMcu and found issues in the program. the sent data value(from Arduino) was 50 and the received and printed data(to nodemcu) is not the required value. the output result is varying from 150 to 300 values. I don't know what is the problem and need some help from experts. thank you.
pins were connected as follows
D6 ---------------------- Tx0 (1)
D5 ---------------------- Rx0(0)
Arduino code
#include <SoftwareSerial.h>
SoftwareSerial s(0,1);
void setup() {
s.begin(9600);
}
void loop() {
int data=50;
if(s.available()>0)
{
s.write(data);
delay(500);
}
}
NodeMCU code
#include <SoftwareSerial.h>
SoftwareSerial s(D6,D5);
int data;
void setup() {
s.begin(9600);
Serial.begin(9600);
}
void loop() {
s.write("s");
if (s.available()>0)
{
data=s.read();
Serial.println(data);
delay(500);
}
}