Chat freely about anything...

User avatar
By Soumyak_Dutta
#87267 Hi,
I am fairly new in ESP8266. I am currenly trying to make a home automation system using thunkable and nodemcu. I need to fetch data from a firebase node using nodemcu - which will be updated by thunkable made app. I have encountered a problem - while fetching data from firebase using nodemcu, after a certain time (around 60 s) the board gets reset with Exception(9).

my code:

Code: Select alllong int T1, T2, T3, T4, T5;
int T1_on, T2_on, T3_on, T4_on, T5_on;

void setup() {
  Serial.begin(115200);

  // connect to wifi.
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("connecting");
  while (WiFi.status() != WL_CONNECTED) { Serial.println(".") ;
  delay(300);
  }
  Serial.println(); Serial.print("connected: "); Serial.println(WiFi.localIP());

  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);

  //firebase tree for WBXSS00001
  Firebase.setString("WBXSS00001/EMAIL", "x");
  Firebase.setInt("WBXSS00001/OnStat", 0);
  Firebase.setInt("WBXSS00001/PIN", 1234);
  Firebase.setString("WBXSS00001/QR", "WBXSS00001A");
  Firebase.setInt("WBXSS00001/T_1", 0);
  Firebase.setInt("WBXSS00001/T_2", 0);
  Firebase.setInt("WBXSS00001/T_3", 0);
  Firebase.setInt("WBXSS00001/T_4", 0);
  Firebase.setInt("WBXSS00001/T_5", 0);
}

void loop() {
 
  //get Timer_1,2,3,4,5 input from fbase and isolate it

  if (Firebase.getInt("WBXSS00001/T_1") != 0)  {  T1 = Firebase.getInt("WBXSS00001/T_1");  T1_on == 1;  } 
else if (Firebase.getInt("WBXSS00001/T_1") == 0) { T1_on == 0; }
 
  Serial.println(millis());

}

The idea is whenever WBXSS00001/T_1 changes its value, will be saved to T1.

Now after 50 to 60 seconds the board resets itself with following msg:

Code: Select allException (9):
epc1=0x4020c850 epc2=0x00000000 epc3=0x00000000 excvaddr=0x463a336b depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffc70 end: 3fffffc0 offset: 0190
3ffffe00:  00000000 00000000 3ffffec8 3ffeea28 
3ffffe10:  0000000b 3ffee9f0 3fff04c8 40206354 
3ffffe20:  00000000 000001bb 3fff04c8 402077f0 
3ffffe30:  3ffe8890 0000003b 3fff04c8 40207d0e 
3ffffe40:  0000003b 3ffee9f0 0000002e 40203974 
3ffffe50:  3ffffe98 0000003b 3ffffe80 402087a4 
3ffffe60:  3ffee9ec 3ffffe80 3ffe8890 3fff0244 
3ffffe70:  3ffee9ec 3ffffec8 3fff04c8 402056da 
3ffffe80:  3fff07ac 003b003f 00fffec8 3fff0754 
3ffffe90:  0042004f 00ff0870 3fff055c 0028002f 
3ffffea0:  00feec04 00000010 3fff0342 3fff0244 
3ffffeb0:  3ffee9ec 3ffe880d 3fff0244 40202e96 
3ffffec0:  3fffdad0 00000000 3fff0858 3fff0244 
3ffffed0:  3fffff00 3fffff00 3ffe8826 40203938 
3ffffee0:  3fffff08 00000000 3fff0334 3fff0244 
3ffffef0:  3ffee9ec 3ffee9f0 3ffee9e8 4020441a 
3fffff00:  3ffeea28 3fff0290 3fffff90 4020866e 
3fffff10:  3fffff90 00000000 3fffff40 402085e0 
3fffff20:  0000000b 0000027e 0000027e 3ffeeb78 
3fffff30:  00000000 3ffe86bc 3ffee9e8 40204485 
3fffff40:  3ffe86bc 0000000e 3fffff90 4020875b 
3fffff50:  0000000e 00000001 3fffff40 40208000 
3fffff60:  007a1200 0000000e 3fffff90 402087a4 
3fffff70:  00000000 3fffff90 3ffe86bc 402087da 
3fffff80:  00000000 3ffe86bc 3ffee9e8 40201088 
3fffff90:  3fff0334 000e000f 00feeb38 4010019d 
3fffffa0:  3fffdad0 00000000 3ffeeb38 40209738 
3fffffb0:  feefeffe feefeffe 3ffe8580 40100cb9 
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3456, room 16
tail 0
chksum 0x84
csum 0x84
va5432625
~ld


I have decoded the stack using ESP Exception decoder :
Code: Select allException 9: LoadStoreAlignmentCause: Load or store to an unaligned address
PC: 0x4020c850: HTTPClient::connected() at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 471
EXCVADDR: 0x463a336b

Decoding stack results
0x40206354: HTTPClient::disconnect(bool) at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 434
0x402077f0: HTTPClient::end() at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 425
0x40207d0e: HTTPClient::begin(String, unsigned short, String, String) at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 379
0x40203974: std::string::_Rep::_M_destroy(std::allocator  const&) at c:\users\soumyak\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
0x402087a4: String::copy(char const*, unsigned int) at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\WString.cpp line 214
0x402056da: FirebaseHttpClientEsp8266::begin(std::string const&, std::string const&) at C:\ARDUINO_INSTALLED\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp line 51
0x40202e96: FirebaseRequest::sendRequest(std::string const&, std::string const&, char*, std::string const&, std::string const&) at C:\ARDUINO_INSTALLED\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp line 73
0x40203938: std::basic_string  , std::allocator  >::basic_string(char const*, std::allocator  const&) at c:\users\soumyak\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
0x4020441a: FirebaseArduino::getRequest(String const&) at C:\ARDUINO_INSTALLED\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp line 101
0x4020866e: String::changeBuffer(unsigned int) at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\WString.cpp line 187
0x402085e0: String::~String() at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\WString.cpp line 125
0x40204485: FirebaseArduino::getInt(String const&) at C:\ARDUINO_INSTALLED\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp line 115
0x4020875b: String::reserve(unsigned int) at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\WString.cpp line 146
0x40208000: IPAddress::fromString(char const*) at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\IPAddress.cpp line 68
0x402087a4: String::copy(char const*, unsigned int) at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\WString.cpp line 214
0x402087da: String::String(char const*) at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\WString.cpp line 36
0x40201088: loop() at C:\Users\Soumyak\Desktop\HA-01\HA-01_code_trial\HA-01_fbase_test/HA-01_fbase_test.ino line 46
0x4010019d: esp_schedule() at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\core_esp8266_main.cpp line 125
0x40209738: loop_wrapper() at C:\Users\Soumyak\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\cores\esp8266\core_esp8266_main.cpp line 197


Please help me understand this error and how to overcome it. Is my approach to code is a problem, or something else...?

my board setup as tool section:
Image
https://ibb.co/JKbGKkX