Stream error and random data after 10 minutes #366
Description
I have a NodeMCU project where something is triggered (switching my TV ON/OFF) when some data is updated in my Firebase.
Here is the main loop:
void loop() {
if (Firebase.failed()) {
Serial.println("streaming error");
Serial.println(Firebase.error());
}
if (Firebase.available()) {
Serial.println("value changed:");
bool newphilipsOn = Firebase.getBool("room/PhilipsTV/on");
bool newsamsungOn = Firebase.getBool("room/SamsungTV/on");
if (newphilipsOn != philipsOn) {
Serial.print("Philips TV state changed to ");
Serial.println(newphilipsOn);
philipsOn = newphilipsOn;
irsend.sendRC6(0x1000C, 20);
irsend.sendRC6(0xC, 20);
irsend.sendRC6(0xC, 20);
irsend.sendRC6(0xC, 20);
}
if (newsamsungOn != samsungOn) {
Serial.print("Samsung TV state changed to ");
Serial.println(newsamsungOn);
samsungOn = newsamsungOn;
irsend.sendSAMSUNG(0xE0E040BF, 32);
irsend.sendSAMSUNG(0xE0E040BF, 32);
}
...
...
}
}
This code works pretty well for 10/15 minutes then it gets crazy, my TV starts to turn on and off.
To see what happened I checked the serial monitor and after 10/15 minutes I saw that Firebase.failed()
was triggered multiple times. Right after that, Firebase.available()
too and my variables newPhilipsOn
and newSamsungOn
was filled with wrong values, resulting in non-desirable actions.
This "crash" always occur after 10/15 minutes following the same pattern: getting several Firebase.failed()
triggered, then, Firebase.available()
is triggered with wrong values.
Since Firebase.error()
isn't explicit I can't figure out what's wrong with my code.
What can I do ?
Thanks.