Page 1 of 1

firebase sent message to ESP32

Posted: Fri Jun 03, 2022 7:04 am
by nikosX
I am new to firebase and ESP32. I successfully wrote a sketch sending data to a firebase real time database.
I wonder if i can make the oposite ie to sent data from firebase to the ESP32.
I recently came across with the following example where the ESP32 request the led state continiously in the main loop.
Is there any other way without continiously requesting the led state? Maybe with firebase functions to target the spesific ESP32 and sent a message?

void loop() {
led_state = Firebase.getString("LED State: ");
if (led_state == "ON") {
Serial.println("Led is ON");
digitalWrite(led_gpio, HIGH);
}
else if (led_state == "OFF")
{
Serial.println("Led is OFF");
digitalWrite(led_gpio, LOW);
}
else {
Serial.println("Wrong value entered! Only ON or OFF accepted");
}
}