firebase-arduino: ESP8266 fails to reconnect to FIREBASE

When i turn on the ESP8266 everything works fine for a while, until the connection with firebase for some reason stops, and im having problems reconnecting to firebase again. Can somebody give me an idea to solve this? without manually reseting the ESP8266 (witch kills the purpose of the ESP8266)

this is my code:

`#include <ESP8266WiFi.h> #include<FirebaseArduino.h>

#define FIREBASE_HOST “XXXXXXX.firebaseio.com” //Your Firebase Project URL goes here without “http:” , "" and “/” #define FIREBASE_AUTH “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX” //Your Firebase Database Secret goes here

#define WIFI_SSID “wifi” //your WiFi SSID for which yout NodeMCU connects #define WIFI_PASSWORD “XXXXX”//Password of your wifi network

String varCooler;

#define Cooler 14 //D5 int val2;

void setup() { Serial.begin(115200); // Select the same baud rate if you want to see the datas on Serial Monitor

pinMode(Cooler,OUTPUT);

digitalWrite(Cooler,HIGH);

WiFi.begin(WIFI_SSID,WIFI_PASSWORD); Serial.print(“connecting”); while (WiFi.status()!=WL_CONNECTED){ Serial.print(“.”); delay(500); } Serial.println(); Serial.print(“connected:”); Serial.println(WiFi.localIP());

Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH); varCooler = Firebase.getString(“Cooler”); Firebase.setString(“Cooler”,“1”); Firebase.setString(“Cooler”,varCooler); }

void firebasereconnect() { Serial.println(“Trying to reconnect”); Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); }

void loop() {

if (Firebase.failed()) { Serial.print(“setting number failed:”); Serial.println(Firebase.error()); firebasereconnect(); return; }

val2=Firebase.getString(“Cooler”).toInt(); //Reading the value of the varialble Status from the firebase

if(val2==1) // If, the Status is 1, turn on the Relay2 { digitalWrite(Cooler,HIGH); Serial.println(“Cooler OFF”); } else if(val2==0) // If, the Status is 0, turn Off the Relay2 {
digitalWrite(Cooler,LOW); Serial.println(“Cooler ON”); }

}`

Cooler is just variable that is use for output

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 28 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Firebase fingerprint change again E2:34:53:7A:1E:D9:7D:B8:C5:02:36:0D:B2:77:9E:5E:0F:32:71:17

I have the same error. Did anyone try to debug the library?

I found the error in the library Firebase.cpp => void FirebaseCall::analyzeError You should change this code Before

void FirebaseCall::analyzeError(char* method, int status, const std::string& path_with_auth) { if (status != 200) { error_ = FirebaseError(status, std::string(method) + " " + path_with_auth + ": " + http_->errorToString(status)); } }

After

void FirebaseCall::analyzeError(char* method, int status, const std::string& path_with_auth) { if (status != 200) { error_ = FirebaseError(status, std::string(method) + " " + path_with_auth + ": " + http_->errorToString(status)); } else { error_ = FirebaseError(); } }

Hi there,

Use this site to find fingerprint:- https://www.grc.com/fingerprints.htm

Steps to update fingerprints:-

  • Right now fingerprint is:- E2 34 53 7A 1E D9 7D B8 C5 02 36 0D B2 77 9E 5E 0F 32 71 17

  • So, go to “C:\Users\user-name\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient.h

  • Update fingerprint:-

static const char kFirebaseFingerprint[] = “E2 34 53 7A 1E D9 7D B8 C5 02 36 0D B2 77 9E 5E 0F 32 71 17”;

Done 😃

Thanks

Use Mobizt library. Forget this repo!!!

You can do this: if (Firebase.failed()) { Serial.print(“setting number failed:”); Serial.println(Firebase.error()); ESP.reset(); }

I have the same problem, the connections fails at random times.