I built a system which can talk to my Firebase application using ESP8266 with firebase Arduino library,
Everything works flawlessly however I now have a problem making the ESP8266 talk and listen to the Microcontroller which is StandAlone Atmega328P (The one used in Arduino Uno).
here are the points 1- cannot use softwareSerial as all the digital pins are occupied. 2- Tried different Bauds with the same issue. 3- only one time worked, where the Arduino was able to listen to the Serial correctly. but couldn't read from serial by ESP.
I am definitely able to Write Strings to the Serial from ESP and read it by Arduino but when trying to use IF statement, cannot recognize the String,
So I tried to Println the String 4 times, and this is what I got.
Lock Door
Lock Door
Lock Door
Lock Door
if anyone can address the problem, I posted the Code for both Arduino and ESP
ESP Code
void getData(){
FirebaseObject object = Firebase.get(EspMac);
String Door = object.getString("Door");
String Connection = object.getString("Connect");
if(Door == "Open Door"){
Serial.println(Door);
delay(100);
Firebase.set(path3,"");
Door = "";
}else if(Door == "Lock Door"){
Serial.println(Door);
delay(100);
Firebase.set(path3,"");
Door = "";
}else if (Connection == "Connect"){
Firebase.set(path5,"Received");
Connection = "";
}
}
ARDUINO Code
do {
if(digitalRead(wipeB) == LOW)
servoDoorOpen ();
while (Serial.available() > 0){
String Door = Serial.readString();
delay(100);
Serial.println(Door);
Serial.println(Door);
Serial.println(Door);
Serial.println(Door);
if (Door.equals("Open Door")){
//Serial.println("We open Doors");
servoDoorOpen();
Door = "";
}
else if (Door.equals("Lock Door")){
//Serial.println("We Lock Doors");
servoDoorLock();
Door = "";
}
}
Thank you.