FirebaseExtended / firebase-arduino

Arduino samples for Firebase.
Apache License 2.0
945 stars 494 forks source link

ESP8266 not connecting to firebase! #373

Open JaysArtworks opened 6 years ago

JaysArtworks commented 6 years ago

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

ghost commented 6 years ago

Same for me, it fails to read and write. Although Firebase.begin gives success. I am using DB Secret.

ghost commented 6 years ago

try this : https://github.com/firebase/firebase-arduino/issues/369

JaysArtworks commented 6 years ago

I'll try this solution later.

JaysArtworks commented 6 years ago

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

santoshn547 commented 6 years ago

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

heriveltogabriel commented 6 years ago

I Changing the firebase fingerprint, nothing. I'm try get new firebase library complete, but don't work. Help-us!!

@prj-x @JaysArtworks @adamrabbani

adamrabbani commented 6 years ago

@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

santoshn547 commented 6 years ago

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

adamrabbani commented 6 years ago

@santoshn547 can i see the code ?

santoshn547 commented 6 years ago

@adamrabbani `#include

include

include

include

include

include

include

include //https://github.com/esp8266/Arduino

//needed for library

include

include

include //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.

kabir1995 commented 6 years ago

Hi everyone here is the solution that is working for me.

  1. download the file from the link : https://github.com/firebase/firebase-arduino/files/2268787/firebase-arduino-master.zip
  2. extract the zip file.
  3. copy everything from the file and paste and replace into the location C:\Users\hossa\Documents\Arduino\libraries\firebase-arduino-master
  4. now download this file from the link https://github.com/firebase/firebase-arduino/files/2268800/FirebaseHttpClient.zip
  5. extract it and paste and replace the file into C:\Users\hossa\Documents\Arduino\libraries\firebase-arduino-master\src
  6. image image

adamrabbani commented 6 years ago

@santoshn547 sorry the old library doesn't work for stream function but basic function like "get" and "set" is work.

santoshn547 commented 6 years ago

@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 ?

JaysArtworks commented 6 years ago

@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 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!

santoshn547 commented 6 years ago

@JaysArtworks What code are you using for reading data from firebase ?

JaysArtworks commented 6 years ago
 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.

santoshn547 commented 6 years ago

@JaysArtworks How do you begin connection to firebase ? How do you give path of where your string is located in firebase ?

adamrabbani commented 6 years ago

@santoshn547 you can see in this example=> https://github.com/firebase/firebase-arduino/blob/master/examples/FirebaseRoom_ESP8266/FirebaseRoom_ESP8266.ino

karan13421 commented 6 years ago

@kabir1995 Thank you so much friend. Your solution worked and saved my project.

Wagnerviana commented 6 years ago

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

Wagnerviana commented 6 years ago

@adamrabbani I do not understand why my copila is not what is being the mistake? here in mine of the board error

karan13421 commented 6 years ago

@Wagnerviana apply @kabir1995 solution written above. I am also facing similar problem and finally kar it's solution work.

proppy commented 6 years ago

Can you confirm that was fixed with #368 ?

Wagnerviana commented 6 years ago

@karan13421 let me ask you ? Are you using ESP 8266? THE ARDUINO

Wagnerviana commented 6 years ago

@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?

Wagnerviana commented 6 years ago

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

adamrabbani commented 6 years ago

@Wagnerviana CAN YOU SHARE THE CODE ?

ViniciusRicciChamps commented 6 years ago

@kabir1995
MUITO OBRIGADO MUITO OBRIGADO MESMO SALVOU MEU TRABALHO DE CONCLUSÃO DE CURSO MUITO OBRIGADO FUNCIONOU SUA DICA

AbdelrahmanElazhary commented 5 years ago

@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();

narzullaev commented 5 years ago

Thanks @kabir1995 . In my case it worked.

zcittadin commented 5 years ago

@kabir1995 Works like a charm. Thank you.

ypegua commented 5 years ago

@AbdelrahmanElazhary im having the same issue, were you able to solve it?

leozhoushu commented 5 years ago

I tried the old library but with the new fingerprint, but still no use... I am going crazy now, what's wrong with my setting???

narzullaev commented 5 years ago

@leozhoushu perhaps you can try with this updated library. Worked for me. https://drive.google.com/drive/folders/1JtDqKWEGgUi0mp0No9LPBBD_KLZK4BYI?usp=sharing

Chriton commented 5 years ago

@leozhoushu these steps worked for me: https://github.com/Chriton/Firebase-Arduino/tree/master/Arduino%20Project#troubleshooting

ypegua commented 5 years ago

In my case, 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)

josacore2017 commented 5 years ago

same problem when i read data this works fine but then stops connections with firebas, someone can help us? please.

ypegua commented 5 years ago
      same problem when i read data this works fine but then stops connections with firebas, someone can help us? please.

Did you find the problem?

bangnguyendev commented 5 years ago

Tôi củng thế. Bị dừng stream khi hoạt động được 2 giờ. Và không biết kết nối lại như thế nào

mathDias commented 5 years ago

I've tryed many times, but only work when I changed on Arduino IDE > TOOLS > DEBUG LEVEL > SSL + HTTP_CLIENT

felossimon commented 5 years ago

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

kabir1995 commented 5 years ago

https://github.com/FirebaseExtended/firebase-arduino/issues/373#issuecomment-468881058 @felossimon for me, new fingerprint is not working. but the previous fingerprint ("6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26") still working. firebasehttpclient

felossimon commented 5 years ago

@kabir1995, maybe it start to change by country, yesterday my 6 esp8266 fail to connect to firebase until I change for the new fingerprint. I live in Mexico.

kabir1995 commented 5 years ago

@felossimon maybe. anyway thank you for your information. In the future, if we face problem we can use the new fingerprint.

NguyenHuyHiep commented 5 years ago

i used new fingerprint but my nodemcu work for 30 minute, then it's not working, sorry for my bad English

felossimon commented 5 years ago

@NguyenHuyHiep check this post: https://github.com/FirebaseExtended/firebase-arduino/issues/388#issuecomment-457472175

Nicybru commented 5 years ago

Hello, I've fixed the problem permanently following Mr mikrodunya guide....great!!!! In my case I dont care to skip fingerprint verification...so skipping this step in the WiFiClientSecureAxTLS.cpp everything starts working fine again...Nice because my distributed esp8266 HW won't be affected by firebase fingerprint changes. I've just include:

bool WiFiClientSecure::verify(const char fp, const char domain_name) { return true; <---- include this line to skip verification

Again thaks to mikrodunya great job!!! regards

NguyenHuyHiep commented 5 years ago

@NguyenHuyHiep check this post: #388 (comment) thankyou so much, it's work for me !

kiralikbeyin commented 5 years ago

@Nicybru i dont know where did you find his guide but here is the link https://github.com/mikrodunya/Firebase-Arduino-Skip-fingerprint-Verification @mikrodunya thank you.

Please can anyone add this "fingerprint" like a variable so we can define in setup?

  Firebase.beginer(FIREBASE_HOST, FIREBASE_AUTH, "E2 34 53 7A 1E D9 7D B8 C5 02 36 0D B2 77 9E 5E 0F 32 71 17");
bluecorei3 commented 5 years ago

help me, i can connect to firebase 2019