firebase-arduino icon indicating copy to clipboard operation
firebase-arduino copied to clipboard

Error setting number to Firebase using NodeMCU

Open sreeharsha-rav opened this issue 5 years ago • 7 comments

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: Capture

sreeharsha-rav avatar Mar 09 '19 05:03 sreeharsha-rav

Did you tried using database URL in this form (ignore https) #define FIREBASE_HOST "**.firebaseio.com/"

Bhupesh-V avatar Mar 09 '19 06:03 Bhupesh-V

Got the solution:

  1. Replace the FirebaseHttpClient.h in the firebase-arduino-master>src with the given file FirebaseHttpClient.zip

  2. Set the rules in your firebase project to false Capture

  3. 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

sreeharsha-rav avatar Mar 09 '19 07:03 sreeharsha-rav

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

sreeharsha-rav avatar Mar 09 '19 07:03 sreeharsha-rav

  1. 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 !!

kingame96 avatar Mar 11 '19 11:03 kingame96

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

TrickSumo avatar Mar 11 '19 14:03 TrickSumo

IT is well explained here https://youtu.be/ZZ5JvSA-Ed8

YogPanjarale avatar Nov 18 '20 11:11 YogPanjarale

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/

stackblogger avatar Sep 26 '21 06:09 stackblogger