0

Exception(28) intermitent, apparently caused by low quality connection, when connecting to WiFi. Seems like it has something to do with WiFi.status(). Is this caused by a problem with WiFi,status() ? Or something else?

relevant code:

line 252

bool flagUpload = uploadAgrigis(post);
...
bool uploadAgrigis(const char* postStr) {
  bool flag = false;
  Serial.print("uploadAgri with postStr: ");
  Serial.println(postStr);
  bool flagWifi = (WiFi.status() == WL_CONNECTED);
  if (!flagWifi) {
    flagWifi = connectWifiOk();
  }
...
bool connectWifiOk() {

  // WiFi network parameters
  const char* ssid2 = "choco2";                                  //fill in your wifi name
  const char* password2 = "123qweasd";  
  const char* ssid = "fazenda";                                  //fill in your wifi name
  const char* password = "";  
  const char* ssid3 = "vivowifi";                                  //fill in your wifi name
  const char* password3 = "vivowifi";   

  //char* ssidFav = "";                                  //fill in your wifi name
  //char* passwordFav = "";  

  bool flagWifi = false;
  int counter = 0;
  int counterLoop = 0;

  Serial.println("connectWifiOk");

  while (WiFi.status() != WL_CONNECTED && counter < 30) {
    Serial.print("while loop ");
    if (counterLoop >= 5) {
      if (counterLoop == 5) {
    WiFi.disconnect();
    WiFi.begin(ssid2, password2);
      } else {
    if (counterLoop == 10) {
      WiFi.disconnect();
      WiFi.begin(ssid3, password3);
    } else if (counterLoop == 15) {
      counterLoop = -1;
    }
      }
    } else if(!counterLoop) {
      WiFi.disconnect();
      WiFi.begin(ssid, password);
    }
    Serial.print(counterLoop);
    Serial.print("  SSID() ");
    Serial.print(WiFi.SSID());

    delay(1800);
    counter++;
    counterLoop++;
    Serial.print("  status ");
    Serial.println(WiFi.status());
  }

  Serial.print("WiFi connection flag:");
  flagWifi = (WiFi.status() == WL_CONNECTED);
  Serial.println(flagWifi);
  return flagWifi;

}

Debug Messages

connectWifiOk

while loop 0 SSID() fazenda status 6

while loop 1 SSID() fazenda

Exception (28): epc1=0x40205c46 epc2=0x00000000 epc3=0x00000000 excvaddr=0x0000002c depc=0x00000000

ctx: sys sp: 3fffed30 end: 3fffffb0 offset: 01a0

Decoding stack results
0x40204e9c: ESP8266WiFiGenericClass::_eventCallback(void*) at /home/tony/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/c++/4.8.2/bits/range_access.h line 48
0x40204fd0: ESP8266WiFiSTAClass::status() at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 498
0x40100579: realloc at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/umm_malloc/umm_malloc.c line 1499
0x4020969b: String::changeBuffer(unsigned int) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/WString.cpp line 156
0x40209101: Print::printNumber(unsigned long, unsigned char) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/Print.cpp line 260
0x4020969b: String::changeBuffer(unsigned int) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/WString.cpp line 156
0x402096e7: String::reserve(unsigned int) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/WString.cpp line 146
0x40209719: String::copy(char const*, unsigned int) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/WString.cpp line 175
0x40209766: String::String(char const*) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/WString.cpp line 36
0x40209101: Print::printNumber(unsigned long, unsigned char) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/Print.cpp line 260
0x40205194: ESP8266WiFiSTAClass::SSID() const at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 522
0x4020519c: ESP8266WiFiSTAClass::SSID() const at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 523
0x40204fa7: ESP8266WiFiSTAClass::disconnect(bool) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 311
0x40209101: Print::printNumber(unsigned long, unsigned char) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/Print.cpp line 260
0x40209d5c: esp_yield() at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/core_esp8266_main.cpp line 91
0x40201c1b: delay at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/core_esp8266_wiring.c line 51
0x40203d34: connectWifiOk() at /home/tony/Arduino/sketches/tempo1_vs13e_Master_NodeMCU_Rain_Wind/tempo1_vs13e_Master_NodeMCU_Rain_Wind.ino line 1355
0x40208fed: Print::write(char const*) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/Print.h line 60
0x40209018: Print::println() at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/Print.cpp line 178
0x402040a8: uploadAgrigis(char const*) at /home/tony/Arduino/sketches/tempo1_vs13e_Master_NodeMCU_Rain_Wind/tempo1_vs13e_Master_NodeMCU_Rain_Wind.ino line 344
0x4010654a: millis at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/core_esp8266_wiring.c line 183
0x40208fed: Print::write(char const*) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/Print.h line 60
0x40209018: Print::println() at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/Print.cpp line 178
0x40204abf: timeCheck() at /home/tony/Arduino/sketches/tempo1_vs13e_Master_NodeMCU_Rain_Wind/tempo1_vs13e_Master_NodeMCU_Rain_Wind.ino line 252
0x40203b0c: setup() at /home/tony/Arduino/sketches/tempo1_vs13e_Master_NodeMCU_Rain_Wind/tempo1_vs13e_Master_NodeMCU_Rain_Wind.ino line 183
0x40204c94: loop() at /home/tony/Arduino/sketches/tempo1_vs13e_Master_NodeMCU_Rain_Wind/tempo1_vs13e_Master_NodeMCU_Rain_Wind.ino line 187
  • what is your question? – jsotola Aug 6 at 4:46
  • is this caused by a problem with WiFi,status() ? – tony gil Aug 6 at 10:05
  • @GMc - blaming environmental conditions as causing exceptions is missing the whole point. Connections get lost in the real world and this should not cause an exception. – tony gil Aug 6 at 11:25
  • 1
    what is on line tempo1_vs13e_Master_NodeMCU_Rain_Wind.ino line 252? – Juraj Aug 6 at 15:52
  • i think you have something wrong with the statement of the variable flagWifi . it cannot have expression for comparing – saad zabari Aug 7 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.