I am working on an ESP8266-based IoT project (waste segregation system) and trying to send data to Firebase Realtime Database. I am using the latest Firebase ESP8266 Client library (FirebaseESP8266.h) on Arduino IDE.
I have configured my Firebase database to public/test mode, meaning it does not require authentication, and I want to write simple integer values to it. My ESP8266 is successfully connecting to Wi-Fi, but writing to Firebase fails.
Hardware:
- ESP8266 (NodeMCU or generic ESP-12E)
- Wi-Fi network (SSID provided, password optional)
Firebase setup:
- Realtime Database: public access enabled (test mode)
- No auth key required since public mode )
What I have tried:
#include <ESP8266WiFi.h>
#include <FirebaseESP8266.h>
const char* ssid = "mySSID";
const char* password = "";
#define FIREBASE_HOST "myURL"
FirebaseData fbData;
FirebaseConfig fbConfig;
void setup() {
Serial.begin(115200);
delay(2000);
WiFi.begin(ssid, password);
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("✅ Wi-Fi Connected");
fbConfig.host = FIREBASE_HOST;
fbConfig.api_key = ""; // left blank for public DB
// For public DB, I pass nullptr as auth
Firebase.begin(&fbConfig, nullptr);
Firebase.reconnectWiFi(true);
}
void loop() {
if (Firebase.setInt(fbData, "/testValue", millis()/1000)) {
Serial.println("✅ Data written");
} else {
Serial.println("❌ Failed to write:");
Serial.println(fbData.errorReason());
}
delay(5000);
}
Observed behavior / error messages:
Serial monitor shows:
✅ Wi-Fi Connected
❌ Failed to write:
token is not ready (revoked or expired)
❌ Failed to write:
token is not ready (revoked or expired