firebase-arduino
firebase-arduino copied to clipboard
ESP8266 not connecting to firebase!
I've a problem connecting the ESP8266 board to Firebase (sketch is correct), but the board connects to the wi-fi, I've already updated the Arduino Json Library and i reinstalled the Firebase library, but nothing (2 months ago I had no problems with the connection).
Same for me, it fails to read and write. Although Firebase.begin gives success. I am using DB Secret.
try this : https://github.com/firebase/firebase-arduino/issues/369
I'll try this solution later.
@prj-x I've I tried to change the Firebase fingerprint, but nothing...it is working for you? I'm a bit worried, beacuse i have to finish a project for school...
I have tried changing the Firebase fingerprint as well as updating the library itself but no use ? Firebase begins connection without any error but Unable to read data from firebase and streaming also fails, Does Anyone know the solution ?
@prj-x @JaysArtworks @adamrabbani
I Changing the firebase fingerprint, nothing. I'm try get new firebase library complete, but don't work. Help-us!!
@prj-x @JaysArtworks @adamrabbani
@heriveltogabriel @santoshn547 @JaysArtworks
try use old libary for a while.. This link --> https://github.com/RaemondBW/firebase-arduino
but this library doesn't work for stream function just simple function like "get" and "set" is work.
download and edit to newest fingerprint.. (FirebaseHttpClient.h) 6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26
@adamrabbani
Using the old library in esp8266 it is reseting.
it shows the following exception : Exception (28): epc1=0x4020e636 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
and it continuously resets . I can say that my sketch is error free, Its because of using old library . Does anyone know the solution ? Stuck in a project thats in due.
@santoshn547 can i see the code ?
@adamrabbani `#include <Firebase.h> #include <FirebaseArduino.h> #include <FirebaseCloudMessaging.h> #include <FirebaseError.h> #include <FirebaseHttpClient.h> #include <FirebaseObject.h> #include <ESP8266Ping.h> #include <ESP8266WiFi.h>//https://github.com/esp8266/Arduino //needed for library #include <DNSServer.h> #include <ESP8266WebServer.h> #include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
#define firebaseURl "****" #define authCode "*****"
FirebaseArduino FirebaseStream; FirebaseArduino MyFirebase; String chipId = "123"; WiFiManager wifiManager;
int leds[4] = {D1, D2, D3, D4}; volatile int states[4] = {LOW, LOW, LOW, LOW};
#define BOUNCE_DURATION 20 // define an appropriate bounce time in ms for your switches volatile unsigned long bounceTime=0; // variable to hold ms count to debounce a pressed switch String path = chipId + "/status"; String devicePath ;
#define DEBOUNCE 20 byte buttons[] = {D5, D6, D7, D8}; #define NUMBUTTONS sizeof(buttons)
void setup() { // put your setup code here, to run once: Serial.begin(115200);
setupLeds();
setupButtons();
attachInterrupt(digitalPinToInterrupt(D5),hello,CHANGE);
attachInterrupt(digitalPinToInterrupt(D6),changeState,CHANGE);
setupLeds();
setupButtons();
wifiManager.autoConnect("AutoConnectAP");
Serial.println("connected...yeey :)");
bool ret = Ping.ping("www.google.com");
if (ret == true){
MyFirebase.begin(firebaseURl,authCode);
FirebaseStream.begin(firebaseURl,authCode);
FirebaseStream.stream(chipId + "/status");
};
}
void loop() {
detachInterrupt(D5); detachInterrupt(D6);
if (FirebaseStream.failed()) { FirebaseStream.stream(chipId + "/status"); Serial.println("streaming error"); Serial.println(Firebase.error()); }
if (FirebaseStream.available()) { FirebaseObject event = FirebaseStream.readEvent(); String eventType = event.getString("type"); Serial.print("event: "); getData(); Serial.println(eventType); if (eventType == "put") { Serial.print("data: "); getData(); } }
byte btn = pressed();
String devicePath;
switch (btn) { case 0: Serial.println("button one pressed"); devicePath = chipId + "/status/001"; doOnOffLed(btn, devicePath); break; case 1: Serial.println("button two pressed"); devicePath = chipId + "/status/002"; doOnOffLed(btn, devicePath); break; case 2: Serial.println("button three pressed"); // devicePath = chipId + "/status/003"; // doOnOffLed(btn, devicePath); break; }
}
void getData() {
FirebaseObject object = MyFirebase.get(path); bool led1 = object.getBool("001"); bool led2 = object.getBool("002");
digitalWrite(leds[0], led1); digitalWrite(leds[1], led2);
Serial.println(led1); Serial.println(led2);
int D1state = led1; states[leds[0]] = D1state;
int D2state = led2; states[leds[1]] = D2state; }
void hello(){
if(millis() > bounceTime)
{
btn1Changed = true;
int state = !states[0];
states[0] = state;
Serial.println(state);
digitalWrite(D1, state);
bounceTime = millis() + BOUNCE_DURATION; // set whatever bounce time in ms is appropriate
}
}
void changeState(){
if(millis() > bounceTime)
{
btn2Changed = true;
int state = !states[0];
states[0] = state;
Serial.println(state);
digitalWrite(D2, state);
bounceTime = millis() + BOUNCE_DURATION; // set whatever bounce time in ms is appropriate
}
}`
The above Sketch was working fine before 5 days.
Hi everyone here is the solution that is working for me.
- download the file from the link : https://github.com/firebase/firebase-arduino/files/2268787/firebase-arduino-master.zip
- extract the zip file.
- copy everything from the file and paste and replace into the location C:\Users\hossa\Documents\Arduino\libraries\firebase-arduino-master
- now download this file from the link https://github.com/firebase/firebase-arduino/files/2268800/FirebaseHttpClient.zip
- extract it and paste and replace the file into C:\Users\hossa\Documents\Arduino\libraries\firebase-arduino-master\src

@santoshn547 sorry the old library doesn't work for stream function but basic function like "get" and "set" is work.
@adamrabbani
Using the below code only returns 0 while the data in firebase is 1.
I am not getting data from firebase it is blank when converted to String.
My Url and Authcode is right.
MyFirebase.begin(firebaseURl,authCode);
FirebaseObject object = MyFirebase.get(path);
bool led1 = object.getBool("001");
bool led2 = object.getBool("002");
Is my code right for the old library ?
@kabir1995 What code are you using to begin connection as well as to get bool from firebase ?
@kabir1995 Thank you very much man! Now the code is working, I did all the steps which you said above, and i deleted the #include <ArduinoJson.h> from the code, because when i upload the code with the Json Library included, it gives me errors, anyway all is working, so thank you again!
@JaysArtworks What code are you using for reading data from firebase ?
n=Firebase.getString("FAN_STATUS").toInt();
Serial.println(n);
// handle error
if (n==1) {
Serial.println("Fan ON");
digitalWrite(Fan,HIGH);
return;
delay(100);
}
else{
Serial.println("Fan OFF");
digitalWrite(Fan,LOW);
}
@santoshn547 These are the lines of code which i'm using to get the value from Firebase, when the value is 1 the fan turns on and when is 0 it turns off.
@JaysArtworks How do you begin connection to firebase ? How do you give path of where your string is located in firebase ?
@santoshn547 you can see in this example=> https://github.com/firebase/firebase-arduino/blob/master/examples/FirebaseRoom_ESP8266/FirebaseRoom_ESP8266.ino
@kabir1995 Thank you so much friend. Your solution worked and saved my project.
HELLO PERSONAL I HAD A PROJECT WITH ESP8266, WHERE IT WORK PERFECTLY, BUT AFTER THAT CHANGE EVERYTHING WAS ONLY, I COULD CONNECT THE INVENTOR APP WITH THE DATABASE, BUT THE ESP8266 HE SHOWS CONNECTED THE WAFI, BUT IT DOES NOT CONNECT TO THE DATA BANK FROM FIREBASE
@adamrabbani I do not understand why my copila is not what is being the mistake? here in mine of the board error
@Wagnerviana apply @kabir1995 solution written above. I am also facing similar problem and finally kar it's solution work.
Can you confirm that was fixed with #368 ?
@karan13421 let me ask you ? Are you using ESP 8266? THE ARDUINO
@karan13421 THEN KNOW, THAT MY PROJECT, I HAD ALREADY HAD IT UP TO THIS FIREBASE CHANGE, BUT AGR PR APPLY, IN MY RESIDENTIAL AUTOMATION, WHERE I OPEN MY GATE WINDOW, AIR DEFINITIONED TELEVISION, I AM NOT GONNA APPLY. TRY IT TO A HERE CODE OF @adamrabbani BUT TA DAMAGE PLATE ERROR, MY ANCIENT CODE WILL CONNECT TO THE WIFI BUT DOES NOT SEND AND NOR RECEIVE THE FIREBASE INTENDI. SOMEONE WHO CAN HELP ME?
BOMM I CAN CONTAIN EVERYTHING OK,
NO DATA BANK MAKES READINGS BUT I NEED TO TRANSPORT MY DESIGN OF IOT AND AUTOMATION RESINDENTIAL, THAT WAS FUNCTIONING, FOR THAT NEW DEMANDS THAT CREATED, In order for this to work my code within this new version
@Wagnerviana CAN YOU SHARE THE CODE ?
@kabir1995
MUITO OBRIGADO
MUITO OBRIGADO MESMO
SALVOU MEU TRABALHO DE CONCLUSÃO DE CURSO
MUITO OBRIGADO
FUNCIONOU SUA DICA
@prj-x @JaysArtworks @adamrabbani @kabir1995
I have a problem with nodemcu and firebase ......when nodemcu start working it connects to wifi then connects to the firebase then i send int and every thing is working fine ...... but if nodemcu lost it connection to wifi and then reconnect again successfully then it can't connect to firebase again untill i use ESP.restart();
Thanks @kabir1995 . In my case it worked.