firebase-arduino
firebase-arduino copied to clipboard
Error setting number to Firebase using NodeMCU
I have written a code which sets soil moisture value to firebase. I have installed ArduinoJson library version 5.13.1 and using Arduino IDE 1.8.8 . The wifi connection works and Firebase.begin works. The Firebase_host and the Database secret is correct. Please help me with this . Here is the code.
#include <FirebaseArduino.h> #include <ESP8266WiFi.h> #define WIFI_SSID "" #define WIFI_PASSWORD "*" #define WIFI_LED D2
#define FIREBASE_HOST "https://**.firebaseio.com/" #define FIREBASE_AUTH ""
void setup() {
Serial.begin(115200);
pinMode(A0,INPUT);
pinMode(WIFI_LED,OUTPUT);
delay(10000);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
digitalWrite(WIFI_LED,LOW);
delay(500);
digitalWrite(WIFI_LED,HIGH);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
digitalWrite(WIFI_LED,HIGH);
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("");
Serial.println("Connecting to Firebase : ");
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); //connect to Database
if (Firebase.failed()) {
Serial.print("Error connecting to Firebase");
Serial.println(Firebase.error());
}
else {
Serial.print("Firebase connection established");
Firebase.set("Soil Moisture",0);
}
Serial.println("");
delay(1000);
}
void loop() { int sensorValue = analogRead(A0); Serial.print("Writing on firebase : "); Firebase.setInt("Soil Moisture",sensorValue); if (Firebase.failed()) { Serial.print("Error setting sensorValue"); Serial.println(Firebase.error()); } else { Serial.print("Moisture Value = "); Serial.println(sensorValue); } Serial.println(""); delay(2000); }
The serial monitor shows:
Did you tried using database URL in this form
(ignore https)
#define FIREBASE_HOST "**.firebaseio.com/"
Got the solution:
-
Replace the FirebaseHttpClient.h in the firebase-arduino-master>src with the given file FirebaseHttpClient.zip
-
Set the rules in your firebase project to false
-
In Arduino IDE go to Tools>Debug Level and select "SSL+HTTP_CLIENT"
It should work now, it worked for me and if there are anymore issues post it here
Did you tried using database URL in this form (ignore https)
#define FIREBASE_HOST "**.firebaseio.com/"
no for the sake of privacy i put ** instead of the real one
- ttpClient.h in the firebase-arduino-master>src
Oh i have the same issue and already fix it using the first solution. thanks a lot !!
Hi
Go to :- C:\Users\user-name\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient.h
Update last three lines:-
static const char kFirebaseFingerprint[] = "E2 34 53 7A 1E D9 7D B8 C5 02 36 0D B2 77 9E 5E 0F 32 71 17"; #endif // FIREBASE_HTTP_CLIENT_H
Thanks
IT is well explained here https://youtu.be/ZZ5JvSA-Ed8
The error comes where your Firebase Fingerprint is expired and your NodeMCU is trying to connect firebase. The Error will keep coming until you insert a new key there.
Here are steps on how to insert a new firebase fingerprint and fix the error- https://stackblogger.com/setting-number-failed-firebase-nodemcu/