Uploading data to firebase using NodeMCU
-
Thanks, @rafitc99. But even this didn't solve my problem!!
I have changed the code in the below format...#include <ESP8266WiFi.h> #include <FirebaseArduino.h> // Set these to run example. #define FIREBASE_HOST "syndinnovate-1.firebaseio.com" #define FIREBASE_AUTH "AIzaS********************7hKQe4uPbfUKHc" #define WIFI_SSID "SSID" #define WIFI_PASSWORD "PASS" void setup() { Serial.begin(9600); delay(1000); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); //try to connect with wifi Serial.print("Connecting to "); Serial.print(WIFI_SSID); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.println(); Serial.print("Connected to "); Serial.println(WIFI_SSID); Serial.print("IP Address is : "); Serial.println(WiFi.localIP()); //print local IP address Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); // connect to firebase //Start reading dht sensor } void loop() { //Convert RainSensr data into string Firebase.pushString("/NEW", "No"); delay(1000);//setup path and send readings Firebase.pushString("/NEW", "Yes"); //setup path and send readings delay(1000);//setup path and send readings }
-
@Anudeep Ok , compilation part is clear .did you getting anything on the firebase side ? Any erros ?
-
@salmanfaris Nothing, No errors!!
Do I need to change anything in Firebase settings or something? -
@salmanfaris Thanks for the support!!
I finally resolved the error. I have taken FIREBASE_AUTH as apiKey instead of Database secrets. -
@Anudeep Great . Glad to know that it is solved , Keep hacking
-
@Anudeep Hello Anudeep could you please help me out by elaborating the fix to get rid of that error?
Thanks in advance. -
Hello @Palani, In the Firebase, there are two types of storage,
- Cloud Firestore (Very recent one & NoSQL database)
- Realtime Database (To which we upload the data using NodeMCU)
In the Arduino Code, you can see that there is a variable named FIREBASE_AUTH.
This variable should be assigned to the Database secret. This you can find in Project Settings -> Service accounts -> Database Secrets.
My mistake is, i have mistakenly assigned thay to Web API key. This is found at Project Settings -> General.
The error can also occur when u don't initialise a proper realtime database in Firebase. (This is not my case).
-
@Anudeep Thanks a lot m8, I actually made a very silly mistake of including the https:// while entering FIREBASE_HOST, where I must have entered the Domain name alone and removed the https:// extension.
Thanks again for replying that quick. Cheers.