I have uploaded the firebase code in NodeMCU(esp8266) and its fully functional. I have connected arduino uno with nodemcu using Rx, Tx pins. When I get values from sensors and transfer it to nodeMCU. I get half junk values and half correct values. The length of junk keeps on changing, I get perfect value once while its full of junk the other time.
I tried changing baud rates but it didn't work. I came across 2 different baud rates for nodeMCU and arduino.
SoftwareSerial ESP(0,1);
void setup() {
ESP.begin(9600);
}
void sendStatus(bool dish, byte gas, int knob, unsigned long alarmIn) {
DynamicJsonDocument status(50);
status["K"] = knob;
status["G"] = gas;
status["D"] = dish;
status["A"] = alarmIn;
String statusString;
serializeJson(status, statusString);
Serial.println(statusString);
ESP.println(statusString);
}
void readSerial() {
if (!ESP.available()) return;
String cmd = "";
while (ESP.available()) {
char ch = (char)ESP.read();
if (ch != 10 && ch != 13) cmd += ch;
if (ch == '}')
break;
delay(1);
}
while (ESP.available()) {
ESP.read();
delay(1);
} // for arduino uno
I expected to get the full string but i get last 50-70% of string while the first part gets as junk values. Need to get full string which I am able to see in arduino's serial monitor.