Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Firebase was not reconnecting ESP8266 #437

Open
stechome opened this issue Apr 18, 2019 · 20 comments
Open

Firebase was not reconnecting ESP8266 #437

stechome opened this issue Apr 18, 2019 · 20 comments

Comments

@stechome
Copy link

Once the internet connection is disconnected, it's wired again. When I'm wired again, firebase does not connect. So when the problem is wired again, it's not connected to firebasis again. How do I do that?

`boolean WiFiReturns() {
if (WiFi.localIP() == IPAddress(0, 0, 0, 0)) return 0;
switch (WiFi.status()) {
case WL_NO_SHIELD: return 0;
case WL_IDLE_STATUS: return 0;
case WL_NO_SSID_AVAIL: return 0;
case WL_SCAN_COMPLETED: return 1;
case WL_CONNECTED: return 1;
case WL_CONNECT_FAILED: return 0;
case WL_CONNECTION_LOST: return 0;
case WL_DISCONNECTED: return 0;
default: return 0;
}
}
void firebasereconnect()
{
Serial.println("Trying to reconnect");
Firebase.begin(firebaseURl, authCode);
}
void loop() {

if (!WiFiReturns()) {
WiFi.isConnected();
digitalWrite(WIFILED, HIGH);
firebasereconnect();

} else {
digitalWrite(WIFILED, LOW);
}
}`

@TrickSumo
Copy link
Contributor

TrickSumo commented Apr 18, 2019

Hi

I am also facing the same issue. I am using ESP.reset as a temporary remedy.

Though it does not fully resolve the problem but ESP.reset(); helps to reconnect to firebase.

// header

int count =0;

void setup{// wifi etc.}

void loop()
{

  if (Firebase.failed())
  {
    Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
    Serial.println(Firebase.error());
    delay(10);
    Serial.println("Error connecting firebase!");
    count++;
    if (count == 10) {
      count = 0;
      ESP.reset();
    }
  
  return;
  }

@FrankAndYoung
Copy link

FrankAndYoung commented Apr 19, 2019

I can't seem to set or push any value to firebase from NodeMCU that worked a month ago.
Does anyone has the same problem? Is the fingerprint of the firebase changed again?

Edit: NVM firebase changed their fingerprint to B6:F5:80:C8:B1:DA:61:C1:07:9D:80:42:D8:A9:1F:AF:9F:C8:96:7D
for anyone who has the problem connecting, go to firebase-arduino-master/src/FirebaseHttpClient.h
and change kFirebaseFingerprint[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

@nheoo
Copy link

nheoo commented Apr 19, 2019

error stream :((

@FrankAndYoung
Copy link

I installed the Version 5.13.4 of ArduinoJson library, the newer versions seems to not work for NodeMCU

@TrickSumo
Copy link
Contributor

Hi

ArduinoJson 6.0 is not compatible with firebase-arduino right now.

This one will work:-

https://github.com/bblanchon/ArduinoJson/tree/5.x

@nikrath
Copy link

nikrath commented Apr 19, 2019

@FrankAndYoung Hey frank, how do you check the fingerprint of firebase?
I used the GRC website (https://www.grc.com/fingerprints.htm) to check and I got a different fingerprint for console.firebase.google.com than what you have got. The fingerprint you gave worked, but the one I found did not work.

@FrankAndYoung
Copy link

Oh you dont enter the actual url, instead you enter the host reference to your realtime database
For example #define FIREBASE_HOST "example.firebaseio.com" in the FirebaseDemo,
it will be "example.firebaseio.com".

@nikrath
Copy link

nikrath commented Apr 19, 2019

@FrankAndYoung Thanks a lot Frank! It worked

@ironaraujo
Copy link

It Works... @FrankAndYoung Thank you.
Do you know if will be necessary to rebuild to all devices every time it occurs? Does it happen that often?

@TrickSumo
Copy link
Contributor

TrickSumo commented Apr 20, 2019

Hi @ironaraujo

Yes, it is necessary to rebuild all devices after fingerprint update.

It happens everytime whenever firebase server SSL certificate renewed.

@ironaraujo
Copy link

@TrickSumo
Is there anyway to avoid that?

@TrickSumo
Copy link
Contributor

This library does not use fingerprint to connect to firebase:-

https://github.com/mobizt/Firebase-ESP8266

@nheoo
Copy link

nheoo commented Apr 21, 2019

Two days I did everything to connect to the firebase but I couldn't connect. below is my code. Looking for help plz:

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

#define LedPin 16

#define FIREBASE_HOST "nodemculed-32c6b.firebaseio.com"
#define FIREBASE_AUTH "E7R2aboxbpvddXEDY9MBPLxyU2b4ZfNWtOpqXoLs"
#define WIFI_SSID "conmabachbach"
#define WIFI_PASSWORD "dung3gdi"

void setup() {
pinMode(LedPin, OUTPUT);
Serial.begin(115200);
// connect to wifi.
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);
Firebase.stream("/Myhome");
}
void loop() {
if (Firebase.failed()) {
Serial.println("streaming error");
Serial.println(Firebase.error());
}

if (Firebase.available()) {
FirebaseObject event = Firebase.readEvent();
String eventType = event.getString("type");
Serial.print("event: ");
Serial.println(eventType);
if (eventType == "put") {
String path = event.getString("path");
String data = event.getString("data");
Serial.println(String("data: ") + data);
if (path.equals("/light/value")) {
if (data.equals("off")) {
digitalWrite(LedPin, HIGH);
} else {
digitalWrite(LedPin, LOW);
}
}
}
}
}

@ironaraujo
Copy link

@TrickSumo This libs is awesome. It recovers from internet disconnection and firebase stream time out.
Ty.

@ironaraujo
Copy link

@nheoo
Check if your Arduino Library is updated, google fingerprint have change a couple days ago.
So I would reinstall Arduino lib, if you want continue using that one...

I also would add an delay(1000) immediately after "Firebase.stream("/Myhome");" in setup. It will give more time to estabilish the connection.

@TrickSumo
Copy link
Contributor

@ironaraujo

Yes, that library is awesome.

Thanks to @mobizt

@nheoo
Copy link

nheoo commented Apr 24, 2019

@nheoo
Check if your Arduino Library is updated, google fingerprint have change a couple days ago.
So I would reinstall Arduino lib, if you want continue using that one...

I also would add an delay(1000) immediately after "Firebase.stream("/Myhome");" in setup. It will give more time to estabilish the connection.

thank u <3 I knew my problem. Are there any i/o pins to declare that I can use?

@AzwadAbid
Copy link

@FrankAndYoung Thanks man! It solved the problem for me.

@kevalshah1223
Copy link

not able to connect NodeMCU to firebase right now help me please

@kevalshah1223
Copy link

can see any value which is fetched from a database from firebase to nodemcu

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants