FirebaseExtended / firebase-arduino

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

Firebase throws exceptions 9 and 28 on ESP8266? #460

Closed SirArlo closed 5 years ago

SirArlo commented 5 years ago

Hi the following code keeps throwing exceptions and I do not know why? It connects perfectly to the WiFi and I am able to access my firebase data but every minute or so it crashes with an exception 9.

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

#define WIFI_SSID "SSID"
#define WIFI_PASSWORD "pass"
#define WIFI_LED LED_BUILTIN
#define HEADBOARD_LED D5
#define UNDER_BED_LED D7

#define FIREBASE_HOST "xxxxxxxxx.firebaseio.com"           //link of api
#define FIREBASE_AUTH "xxxxxxxxxxxxxxxxxxxxxxxxxx"           //database secret
#define HEADBOARD_LED_STATUS "/url/more/url"
#define UNDERBED_LED_STATUS "/url/more/url"
#define HEADBOARD_NIGHT_MODE_STATUS "/url/more/url"
#define UNDERBED_NIGHT_MODE_STATUS "/url/more/url"

const long utcOffsetInSeconds = 7200;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds);

void connectToWiFi(){

  //set up the wifi connection
  Serial.print("Connecting: ");
  WiFi.disconnect();
  WiFi.setSleepMode(WIFI_NONE_SLEEP);
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID,WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED){
    delay(500);
    Serial.print(".");
   }
  Serial.println("Ready to rumble!");
  Serial.print("Wifi connected with IP address: ");
  Serial.println(WiFi.localIP());
  digitalWrite(WIFI_LED,LOW);
}

void connectToFireBase(){
   Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);             //connect to Database
}

void setup(){
  Serial.begin(9600);
  Serial.println("Booting");

  //Setup the pinmodes for the various in and outputs
  pinMode(WIFI_LED, OUTPUT);
  pinMode(HEADBOARD_LED, OUTPUT);
  pinMode(UNDER_BED_LED, OUTPUT);

  connectToWiFi();
  timeClient.begin();
  connectToFireBase();
}

void loop(){
  if( WiFi.status() != WL_CONNECTED ){
     connectToWiFi();
     return;
  }
  timeClient.update();
  handleNightModeUnderBed();
  handleNightModeHeadBoard();
}

String firebaseGet(String s){
    String x =Firebase.getString(s);
    yield();
    delay(100);
    return x;
    delay(100);
}

void manageHeadBoardLEDStatus(){
  String LEDStatus = firebaseGet(HEADBOARD_LED_STATUS);
    if (Firebase.failed()) {
      return;
    }
    if (LEDStatus == "ON"){
      digitalWrite(HEADBOARD_LED,HIGH); 
    }else{
      digitalWrite(HEADBOARD_LED,LOW); 
    }
}

void manageUnderBedLEDStatus(){
  String LEDStatus = firebaseGet(UNDERBED_LED_STATUS);
  if (Firebase.failed()) {
      return;
  }
    if (LEDStatus == "ON"){
      digitalWrite(UNDER_BED_LED,HIGH); 
    }else{
      digitalWrite(UNDER_BED_LED,LOW); 
    }

}

void handleNightModeHeadBoard(){
  String NightMode = firebaseGet(HEADBOARD_NIGHT_MODE_STATUS);
    if (Firebase.failed()) {
      return;
  }
    if (NightMode == "ON" && timeClient.getHours() >= 22){
      digitalWrite(HEADBOARD_LED,LOW); 
    }else{
      manageHeadBoardLEDStatus(); 
    }

}

void handleNightModeUnderBed(){
  String NightMode = firebaseGet(UNDERBED_NIGHT_MODE_STATUS);
  if (Firebase.failed()) {
      return;
  }
    if (NightMode == "ON" && timeClient.getHours() >= 22){
      digitalWrite(UNDER_BED_LED,LOW); 
    }else{
      manageUnderBedLEDStatus(); 
    }
}
Exception (9):
epc1=0x40206b4a epc2=0x00000000 epc3=0x00000000 excvaddr=0x65646f4d depc=0x00000000

>>>stack>>>

PC: 0x4020b4a4: HTTPClient::connected() at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 472
EXCVADDR: 0x00000038

Decoding stack results
0x4020591c: HTTPClient::disconnect(bool) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 435
0x402067f4: HTTPClient::end() at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 425
0x40206c20: HTTPClient::begin(String, unsigned short, String, String) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 379
0x40201f38: std::string::_Rep::_M_destroy(std::allocator  const&) at c:\users\arlo\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 452
0x402075b8: String::copy(char const*, unsigned int) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\WString.cpp line 214
0x402037c3: FirebaseHttpClientEsp8266::begin(std::string const&, std::string const&) at C:\Users\Arlo\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp line 51
0x4020157c: FirebaseRequest::sendRequest(std::string const&, std::string const&, char*, std::string const&, std::string const&) at C:\Users\Arlo\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp line 73
0x40201efc: std::basic_string  , std::allocator  >::basic_string(char const*, std::allocator  const&) at c:\users\arlo\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 218
0x402027ed: FirebaseArduino::getRequest(String const&) at C:\Users\Arlo\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp line 101
0x40201d45: FirebaseObject::~FirebaseObject() at C:\Users\Arlo\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseObject.h line 37
0x4020282e: FirebaseArduino::getString(String const&) at C:\Users\Arlo\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp line 132
0x4020756f: String::reserve(unsigned int) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\WString.cpp line 146
0x40208393: esp_yield() at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\core_esp8266_main.cpp line 107
0x402089ae: __delay(unsigned long) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\core_esp8266_wiring.cpp line 57
0x402075b8: String::copy(char const*, unsigned int) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\WString.cpp line 214
0x40201157: firebaseGet(String) at D:\Jarvis\Bed_Control/Bed_Control.ino line 99
0x4020118b: manageHeadBoardLEDStatus() at D:\Jarvis\Bed_Control/Bed_Control.ino line 106
0x402047c8: ESP8266WiFiSTAClass::status() at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 634
0x4010017c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\core_esp8266_main.cpp line 159
0x40201227: loop() at D:\Jarvis\Bed_Control/Bed_Control.ino line 94
0x402084c0: loop_wrapper() at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\core_esp8266_main.cpp line 179```

Exception (28): epc1=0x4020b7ac epc2=0x00000000 epc3=0x00000000 excvaddr=0x00004684 depc=0x00000000

stack>>>

PC: 0x4020b4a4: HTTPClient::connected() at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 472 EXCVADDR: 0x00000038

Decoding stack results 0x4020591c: HTTPClient::disconnect(bool) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 435 0x402067f4: HTTPClient::end() at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 425 0x40206c20: HTTPClient::begin(String, unsigned short, String, String) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 379 0x40201f38: std::string::_Rep::_M_destroy(std::allocator const&) at c:\users\arlo\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 452 0x402075b8: String::copy(char const, unsigned int) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\WString.cpp line 214 0x402037c3: FirebaseHttpClientEsp8266::begin(std::string const&, std::string const&) at C:\Users\Arlo\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp line 51 0x4020157c: FirebaseRequest::sendRequest(std::string const&, std::string const&, char, std::string const&, std::string const&) at C:\Users\Arlo\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp line 73 0x40201efc: std::basic_string , std::allocator >::basic_string(char const, std::allocator const&) at c:\users\arlo\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2\bits/basic_string.tcc line 218 0x402027ed: FirebaseArduino::getRequest(String const&) at C:\Users\Arlo\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp line 101 0x40201d45: FirebaseObject::~FirebaseObject() at C:\Users\Arlo\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseObject.h line 37 0x4020282e: FirebaseArduino::getString(String const&) at C:\Users\Arlo\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp line 132 0x4020756f: String::reserve(unsigned int) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\WString.cpp line 146 0x40208393: esp_yield() at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\core_esp8266_main.cpp line 107 0x402089ae: __delay(unsigned long) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\core_esp8266_wiring.cpp line 57 0x402075b8: String::copy(char const, unsigned int) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\WString.cpp line 214 0x40201157: firebaseGet(String) at D:\Jarvis\Bed_Control/Bed_Control.ino line 99 0x4020118b: manageHeadBoardLEDStatus() at D:\Jarvis\Bed_Control/Bed_Control.ino line 106 0x402047c8: ESP8266WiFiSTAClass::status() at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 634 0x4010017c: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\core_esp8266_main.cpp line 159 0x40201227: loop() at D:\Jarvis\Bed_Control/Bed_Control.ino line 94 0x402084c0: loop_wrapper() at C:\Users\Arlo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.1\cores\esp8266\core_esp8266_main.cpp line 179```

It keeps happening and it is only when I use the arduino Firebase library. If I don't touch firebase the code works just fine.

proyectosAndroid12 commented 4 years ago

Did you fix it? I have the same problem

99bit commented 4 years ago

@proyectosAndroid12 i Found that if you're using old Node Mcu You Should have to downgrade the Esp Board Driver , i tried to downgrade to 2.3.0 and it worked perfectly fine no more exception

I thought that it is because of old driver in old Mcu

image

fabianrosales commented 4 years ago

Thank you very much!...since my code has several libraries, I was going around trough so many topics trying to figure out what was the problem....you should listen all theories about to solve this problem....delays, power supply, capacitors, etc, etc, etc.

ivansheva commented 4 years ago

@proyectosAndroid12 i Found that if you're using old Node Mcu You Should have to downgrade the Esp Board Driver , i tried to downgrade to 2.3.0 and it worked perfectly fine no more exception

I thought that it is because of old driver in old Mcu

image

Thank you very much !, i try to downgrade ESP Board Driver from 2.6.1 to 2.3.0 worked for me, no error exception 9 again, nice !

NguyenVTruong commented 4 years ago

Thanks you very much!

gnanasreekar commented 4 years ago

❤❤❤❤❤❤❤❤❤❤❤❤

jashvithlani commented 4 years ago

@proyectosAndroid12 i Found that if you're using old Node Mcu You Should have to downgrade the Esp Board Driver , i tried to downgrade to 2.3.0 and it worked perfectly fine no more exception

I thought that it is because of old driver in old Mcu

image

you are greatttt man thank you so much i was fucked up since 3 hours trying to solve this. Thank you sooooooooooo much

junaidiqbal10 commented 4 years ago

I tried to downgrade my board to 2.3 but code is not uploading. Error compling for board nodemcu

RukshanJS commented 4 years ago

I tried to downgrade my board to 2.3 but code is not uploading. Error compling for board nodemcu

I also got the same issue after downgrading to 2.3, but I got it working after selecting the board NodeMCU 0.9 (instead of NodeMCU 1.0) in the Arduino IDE.

Ashishdatley commented 4 years ago

Thank you so much for help for this exception lol i was going to buy new nodemcu but you guys save me lol hehe

thilina15 commented 4 years ago

@proyectosAndroid12 i Found that if you're using old Node Mcu You Should have to downgrade the Esp Board Driver , i tried to downgrade to 2.3.0 and it worked perfectly fine no more exception

I thought that it is because of old driver in old Mcu

image

OMFG thanks dude. it worked for me.. thank you very much

Nadir98s commented 4 years ago

https://arduinojson.org/v6/error/jsonbuffer-is-a-class-from-arduinojson-5/ Downgrade arduinoJson library to 5.13.5 image

pratheeshskammath commented 3 years ago

Thank you so much, I got the same problem after downgrading code works without any problem.

Sakib6813 commented 3 years ago

I tried to downgrade my board to 2.3 but code is not uploading. Error compling for board nodemcu

I also got the same issue after downgrading to 2.3, but I got it working after selecting the board NodeMCU 0.9 (instead of NodeMCU 1.0) in the Arduino IDE.

I selected that but I still have the same problem of error compiling

attaqi commented 2 years ago

same here did not work

Ramzi-dr commented 2 years ago

me to

pratheeshskammath commented 2 years ago

Use mobizt firebase library, it works on updated nodemcu boards I'm using 2.7.4 version of esp8266 : https://github.com/mobizt/Firebase-ESP8266