-->
Page 1 of 1

ESP8266 nodemcu sometimes restart after http get

PostPosted: Thu Nov 19, 2020 1:38 am
by svicar
Hello to all
I have ESP8266 nodemcu connected to wifi and geting two values from web. Sometimes it restart with this error:
Exception 9: LoadStoreAlignmentCause: Load or store to an unaligned address
PC: 0x402090d4: HTTPClient::connected() at C:\Users\Matej\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 475
EXCVADDR: 0x00000069

Decoding stack results
0x40205994: Print::println(char const*) at C:\Users\Matej\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\Print.cpp line 198
0x402011a3: SendData1() at C:\Users\Matej\Documents\Arduino\ESP8266_php_1/ESP8266_php_1.ino line 199
0x40201376: loop() at C:\Users\Matej\Documents\Arduino\ESP8266_php_1/ESP8266_php_1.ino line 127
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Matej\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x40206c2c: loop_wrapper() at C:\Users\Matej\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 197

this is part of the program that is called every 20seconds
void GetData()
{
HTTPClient http;
http.begin("http://192.168.0.101/printer_state.txt");
int httpCode = http.GET();
if (httpCode > 0)
{
const String& payload = http.getString(); //Get the request response payload
Serial.println(payload); //Print the response payload
if (payload.length() > 3 and httpCode==200)
{
crne_s = payload.substring(0, payload.indexOf(','));
barvne_s = payload.substring(payload.indexOf(',') + 1, payload.length());
}
}
if (http.connected()) http.end();
delay(1000);
}

the restart comes around http.end()
Does somebody have some idea to try?

Thanks

Re: ESP8266 nodemcu sometimes restart after http get

PostPosted: Tue Nov 24, 2020 1:34 am
by svicar
Has enybody any idea what will solve the problem..the ESP is restarting every few minuts

Re: ESP8266 nodemcu sometimes restart after http get

PostPosted: Wed Nov 25, 2020 3:17 am
by Bonzo
If this code is running every 20 seconds why stop and restart the HTTP connection?

You could put the http.begin in the start loop and just check there is still an http connection in the loop if you wanted.