WiFiManager (ESP8266) Problems

I'm working on a project where I have to use WiFiManager with the ESP8266, and I'm having issues with the connection. At first, everything works normally, but after a while the connection drops, and the following errors appear:

10:59:03.885 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
10:59:03.885 ->
10:59:03.885 -> Exception (0):
10:59:03.885 -> epc1=0x40241950 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
10:59:03.966 ->
10:59:03.966 -> >>>stack>>>
10:59:03.966 ->
10:59:03.966 -> ctx: sys
10:59:03.966 -> sp: 3fffedd0 end: 3fffffb0 offset: 0150
10:59:03.966 -> 3fffef20: 00000000 3ffeb0b2 4024129b 40241209
10:59:03.966 -> 3fffef30: 3ffecf90 3ffeb09c 3fffdcc0 3ffe9568
10:59:03.966 -> 3fffef40: 00000000 3ffecf90 00000000 3fffdcb0
10:59:03.966 -> 3fffef50: 40240b5f 3fffdab0 00000000 4020dfe2
10:59:03.966 -> 3fffef60: 3ffe9568 40000f49 ffffff00 40000f49
10:59:03.966 -> 3fffef70: 40000e19 00057683 bff00000 0000bfff
10:59:05.132 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------

10:59:05.132 ->

10:59:05.132 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)

10:59:05.171 ->

10:59:05.171 -> load 0x4010f000, len 3424, room 16

10:59:05.171 -> tail 0

10:59:05.171 -> chksum 0x2e

10:59:05.171 -> load 0x3fff20b8, len 40, room 8

10:59:05.171 -> tail 0

10:59:05.171 -> chksum 0x2b

10:59:05.171 -> csum 0x2b

10:59:05.171 -> v00057690

10:59:05.171 -> ~ld


In addition to this error, I'm getting exception(0), rst cause:4, boot mode (3,6), and wdt reset.
If anyone can help me, I'd appreciate it.

#include <ESP8266WiFi.h>
#include <WiFiManager.h>

class WiFiHandler {
private:
    WiFiManager wm;
    const long reconnectInterval = 10000; // 10 segundos
    unsigned long lastCheckTime = 0;
    bool setupCompleted = false;

public:
    void connect() {
        
        wm.setConfigPortalBlocking(false);  // Modo não bloqueante
        wm.setConfigPortalTimeout(180);     // Timeout de 3 minutos
        
        // Configuração de callbacks para debug
        wm.setAPCallback([](WiFiManager* wm) {
            Serial.println(F("Modo AP ativado"));
        });
        
        wm.setSaveConfigCallback([]() {
            Serial.println(F("Configuração salva"));
        });

        Serial.println(F("Iniciando conexão WiFi..."));
        if (wm.autoConnect("AcquaLink-AP", "Acquanativa")) {
            Serial.print(F("Conectado! IP: "));
            Serial.println(WiFi.localIP());
            setupCompleted = true;
        } else {
            Serial.println(F("Falha na conexão inicial"));
        }
    }

    void checkConnection() {
        unsigned long currentMillis = millis();
        
        
        if (currentMillis - lastCheckTime >= reconnectInterval) {
            lastCheckTime = currentMillis;
            
            if (WiFi.status() != WL_CONNECTED) {
                Serial.println(F("Conexão perdida. Reconectando..."));
                
                
                unsigned long startAttemptTime = millis();
                while (WiFi.status() != WL_CONNECTED && 
                      millis() - startAttemptTime < 5000) {  // Timeout de 5s
                    delay(100);
                    yield();
                }
                
                if (WiFi.status() != WL_CONNECTED) {
                    Serial.println(F("Falha na reconexão. Reiniciando..."));
                    delay(100);
                    ESP.restart();
                }
            }
        }
    }

    void process() {
        wm.process();  
    }

    bool isConnected() {
        return WiFi.status() == WL_CONNECTED;
    }
};

WiFiHandler wifiHandler;

void setup() {
    Serial.begin(115200);
    Serial.println(F("\nIniciando sistema..."));
    
    
    unsigned long startTime = millis();
    while (!wifiHandler.isConnected() && 
          millis() - startTime < 30000) {  // Timeout de 30s
        wifiHandler.connect();
        delay(1000);  // Pausa entre tentativas
        yield();
    }
    
    if (!wifiHandler.isConnected()) {
        Serial.println(F("Falha crítica na conexão inicial. Reiniciando..."));
        delay(1000);
        ESP.restart();
    }
}

void loop() {
    wifiHandler.process();
    wifiHandler.checkConnection();
    
    
    
    delay(100);  
    yield();
}

What is the output of the exception decoder?

Hello, I apologize for the delay in responding. I ended up changing the code, and a few things happened that made me modify it (I added the MQTT AWS Amazon IoT to the firmware and created two classes: one for WiFi and one for MQTT). If you can help me, I’d appreciate it.

Here’s the situation: I have two ESP8266 boards (NodeMCU 1.0 - ESP-12E Module; LOLIN (Wemos) D1 R1), and I’m testing the same code on both. The NodeMCU ESP8266 works fine, but the Wemos D1 R1 keeps giving me errors (which I’ll list below). Unfortunately, I’m using a version of the Arduino IDE that doesn’t allow me to use the decoding plugin (I believe that’s what you were asking about). Anyway, I’m having trouble identifying the errors that the Wemos ESP is showing. I have a few suspicions, but I’m not entirely sure what’s really causing the issue.

  • Whether the ESP8266 boards are different in terms of hardware/firmware since they come from different manufacturers (besides the pinout).

  • Whether it could be issues with delay() and yield() in the code due to the libraries I’m using (I saw in a forum that some libraries might already have delay and yield programmed, and adding them to the code could cause errors).

  • Whether the Wemos ESP8266 I’m using has a physical defect (but to confirm that, I’d need to rule out all possible hardware-related causes).

Firmware used on both ESP8266 boards:

#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>
#include <WiFiClientSecure.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include <time.h>
#include "env.h" // Arquivo com certificados

// wifimanager
#define RECONNECT_TIMEOUT 300000 // 5 minutos

// Configurações AWS
const char THINGNAME[] = "basicPubSub";
const char MQTT_HOST[] = "a3ew2u22nso37k-ats.iot.sa-east-1.amazonaws.com";
const char AWS_IOT_PUBLISH_TOPIC[] = "esp8266/pub";
const char AWS_IOT_SUBSCRIBE_TOPIC[] = "esp8266/sub";
const long PUBLISH_INTERVAL = 5000; // Intervalo de publicação

// Estrutura segura para mensagens
struct SafeMessage {
  char topic[64];
  uint8_t payload[128];
  uint16_t length;
  volatile bool received;
};

// ----------------------------------------------
// classe AWS
// ----------------------------------------------
class AWSHandler 
{
private:
  WiFiClientSecure net;
  PubSubClient client;
  SafeMessage incomingMsg;
  unsigned long lastPublish = 0;
  BearSSL::X509List cert;
  BearSSL::X509List client_crt;
  BearSSL::PrivateKey key;

  void NTPConnect() {
    configTime(-3 * 3600, 0, "pool.ntp.org", "time.nist.gov"); // Fuso -3h
    time_t now = time(nullptr);
    while (now < 1510592825) {
      delay(500);
      now = time(nullptr);
    }
  }

  void connectAWS() {
    if (WiFi.status() != WL_CONNECTED) return;
    
    net.setTrustAnchors(&cert);
    net.setClientRSACert(&client_crt, &key);
    client.setServer(MQTT_HOST, 8883);
    client.setCallback([this](char* topic, byte* payload, unsigned int length) {
      if (incomingMsg.received) return;
      strncpy(incomingMsg.topic, topic, sizeof(incomingMsg.topic)-1);
      length = min(length, sizeof(incomingMsg.payload));
      memcpy(incomingMsg.payload, payload, length);
      incomingMsg.length = length;
      incomingMsg.received = true;
    });

    while (!client.connect(THINGNAME)) {
      Serial.print(".");
      delay(1000);
    }
    client.subscribe(AWS_IOT_SUBSCRIBE_TOPIC);
    Serial.println("\nAWS IoT Connected!");
  }

public:
  AWSHandler() : 
    cert(cacert), 
    client_crt(client_cert), 
    key(privkey), 
    client(net) 
  {
    incomingMsg.received = false;
  }

  void begin() {
    net.setBufferSizes(1024, 512);
    NTPConnect();
  }

  void loop() {
    if (WiFi.status() != WL_CONNECTED) return;
    
    if (!client.connected()) {
      connectAWS();
    }
    client.loop();

    // Publicação periódica
    if (millis() - lastPublish >= PUBLISH_INTERVAL) {
      publishMessage();
      lastPublish = millis();
    }

    // Processamento seguro de mensagens
    if (incomingMsg.received) {
      Serial.print("[AWS] Received: ");
      Serial.write(incomingMsg.payload, incomingMsg.length);
      Serial.println();
      incomingMsg.received = false;
    }
  }

  void publishMessage() {
    StaticJsonDocument<200> doc;
    doc["heap"] = ESP.getFreeHeap(); // Inclui memória livre
    doc["rssi"] = WiFi.RSSI();
    doc["ssid"] = WiFi.SSID();

    char jsonBuffer[200];
    serializeJson(doc, jsonBuffer);
    client.publish(AWS_IOT_PUBLISH_TOPIC, jsonBuffer);
    Serial.printf("[AWS] Published: %s\n", jsonBuffer);
  }
};

AWSHandler awsHandler; // Instância global

// ----------------------------------------------
// Classe WiFiManager
// ----------------------------------------------
class WiFiHandler 
{
private:
  WiFiManager wifiManager;
  unsigned long lastReconnectAttempt = 0;
  bool portalActive = false;

  void connectToWiFi() {
    portalActive = false;
    Serial.println("\nConectando à WiFi...");
    if (wifiManager.autoConnect("ESP-Config")) {
      connectionSuccessful();
    } else {
      handleConnectionFailure();
    }
  }

  void connectionSuccessful() {
    Serial.println("\nConectado com sucesso!");
    Serial.print("SSID: "); Serial.println(WiFi.SSID());
    Serial.print("IP: "); Serial.println(WiFi.localIP());
    Serial.print("RSSI: "); Serial.print(WiFi.RSSI()); Serial.println(" dBm");
    portalActive = false;
    lastReconnectAttempt = 0;
  }

  void handleConnectionFailure() {
    Serial.println("\nFalha na conexão WiFi");
    if (portalActive) Serial.println("Timeout do portal de configuração");
    portalActive = false;
    lastReconnectAttempt = millis();
  }

public:
  void begin() {
    Serial.begin(115200);
    while (!Serial) delay(10);
    
    wifiManager.setDebugOutput(true);
    wifiManager.setConnectTimeout(30);
    wifiManager.setConfigPortalTimeout(180);
    
    wifiManager.setAPCallback([this](WiFiManager *wm) {
      Serial.println("\n--- MODO CONFIGURAÇÃO ATIVO ---");
      Serial.print("SSID: "); Serial.println(wm->getConfigPortalSSID());
      Serial.print("IP: "); Serial.println(WiFi.softAPIP());
      portalActive = true;
    });

    Serial.println("\nComandos: 'r' (Reset), 'c' (Configuração)");
    connectToWiFi();
    awsHandler.begin(); // Inicia AWS apos conexao WiFi
  }

  void loop() {
    if (Serial.available()) handleSerialCommand(Serial.read());
    
    if (WiFi.status() != WL_CONNECTED && !portalActive && 
        (millis() - lastReconnectAttempt > RECONNECT_TIMEOUT)) {
      Serial.println("\nTentando reconexão automática...");
      connectToWiFi();
    }
    awsHandler.loop(); // Mantém conexão AWS
    yield(); // Previne WDT reset
  }

  void handleSerialCommand(char cmd) {
    switch(cmd) {
      case 'r': 
        Serial.println("\nResetando configurações WiFi...");
        wifiManager.resetSettings();
        Serial.println("Reiniciando...");
        delay(1000);
        ESP.restart();
        break;
        
      case 'c': 
        Serial.println("\nForçando modo configuração...");
        startPortal();
        break;
        
      default:
        Serial.println("\nComandos: 'r' (Reset), 'c' (Configuração)");
        break;
    }
  }

  void startPortal() {
    Serial.println("\nIniciando portal de configuração");
    if (!wifiManager.startConfigPortal("ESP-Config")) {
      Serial.println("Portal falhou! Reiniciando...");
      delay(1000);
      ESP.restart();
    }
  }
};

WiFiHandler wifiHandler; // Instância global única

void setup() 
{
  wifiHandler.begin();
}

void loop() 
{
  static unsigned long lastCheck = 0;
  if (millis() - lastCheck >= 5000) 
  { // Verifica a cada 5 segundos
    lastCheck = millis();
    Serial.printf("Memória livre: %d bytes\n", ESP.getFreeHeap());
  }

  wifiHandler.loop();
}

Error messages on the ESP8266 (Wemos D1 R1):

*wm:Connect to new AP [SUCCESS] 
*wm:Got IP Address: 
*wm:10.156.4.211 
*wm:config portal exiting 

Successfully connected!
SSID: GalaxyA21sHS
IP: 10.156.4.211
RSSI: -47 dBm
Free memory: 34688 bytes

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (3):
epc1=0x4022dadb epc2=0x00000000 epc3=0x00000000 excvaddr=0x4022daa0 depc=0x00000000

>>>stack>>>

ctx: bearssl
sp: 3fff1610 end: 3fff1ae0 offset: 0150
3fff1760:  63617465 20417574 686f7269 7479202d  
3fff1770:  20473230 1e170d31 35303532 35313230  
3fff1780:  3030305a 170d3337 31323331 30313030  
3fff1790:  30305a30 39310b30 09060355 04061302  
3fff17a0:  ed46b013 209b565e 433e089b 0f5acd1b  
3fff17b0:  c178cc13 d5cb2cfb e3325842 d4c0af41  
3fff17c0:  d7dfe1e4 85518af1 77f24fa2 569c0aa1  
3fff17d0:  99cc5dfb cc5c183e 0373cea5 01883dbc  
3fff17e0:  7ee50c69 6ebef6c7 46336d18 5b71388f  
3fff17f0:  8f3f9209 a4302dac d302b120 921dfc47  
3fff1800:  e63c7f17 e70de4d2 ce8af5dd 281b7e3f  
3fff1810:  c4800ff0 29f31fc4 13263d6d 7210ddff  
3fff1820:  7dce4c4d 95b2db16 b9fa61e0 3d3a2c02  
3fff1830:  7cba3409 0272ea50 8424af5d 651cf4f4  
3fff1840:  fe6ef47a a54178b4 552f7063 3320795f  
3fff1850:  67b815e9 ecb8d6b9 49276996 47ee2827  
3fff1860:  e0aad526 3fff1760 2db879e6 40268218  
3fff1870:  3fff1960 14895026 8cc70208 90befffa  
3fff1880:  a4506ceb bef9a3f7 c67178f2 3fff1860  
3fff1890:  d519670d dcbff8f2 aad78aa7 088c937b  
3fff18a0:  534d6c16 bee91d4d 690cdb72 189737cb  
3fff18b0:  18163071 c73bb62a 3fff1960 65014886  
3fff18c0:  02020403 48866009 04036501 00000000  
3fff18d0:  00000040 3fff4e2c 00000040 4022df90  
3fff18e0:  3fff1914 3fff1960 00000000 3fff1910  
3fff18f0:  00000c80 00000000 13e1a68d 3fff4dec  
3fff1900:  3fff4f68 3fff4eb8 00000004 4023c448  
3fff1910:  00000000 65746163 74754120 69726f68  
3fff1920:  2d207974 30324720 310d171e 32353035  
3fff1930:  30323135 5a303030 37330d17 31333231  
3fff1940:  30303130 305a3030 300b3139 55030609  
3fff1950:  02130604 20646c65 00000d00 00000000  
3fff1960:  df77890d 8c9cd7e1 6003dd94 907350dc  
3fff1970:  2d6f5113 87818dd0 528e85a9 558684ce  
3fff1980:  69767265 20736563 746f6f52 72654320  
3fff1990:  69666974 deadbeef 00000c80 00000000  
3fff19a0:  caacff90 ca77e2ab 035c8b0b 4a346b71  
3fff19b0:  369ef18c 98b77fe4 bd5370c8 f0b96139  
3fff19c0:  00769d3a bf2b11e8 5e0b44bf 82a9db92  
3fff19d0:  8d8de1a1 b8523372 9b29e5c7 4989b400
3fff19e0:  3fff2d8e 000000c7 402680e0 deadbeef  
3fff19f0:  deadbeef 3fff4885 3fff594c 3fff4ae4  
3fff1a00:  000008f0 3fff4dc0 3fff4ac0 40231184  
3fff1a10:  deadbeef deadbeef deadbeef deadbeef  
3fff1a20:  402683e1 deadbeef deadbeef deadbeef  
3fff1a30:  deadbeef deadbeef deadbeef deadbeef  
3fff1a40:  deadbeef deadbeef deadbeef deadbeef  
3fff1a50:  deadbeef deadbeef 40268a5c deadbeef  
3fff1a60:  3fff42dc 3fff4b70 3fff4ae0 3fff4adc  
3fff1a70:  deadbeef deadbeef 3fff42c0 00000100  
3fff1a80:  00000100 deadbeef deadbeef deadbeef  
3fff1a90:  deadbeef deadbeef deadbeef 3fff4ddc  
3fff1aa0:  00000430 3fff4cdc 3fff42dc 4022f78c  
3fff1ab0:  3fff4ac0 deadbeef 3fff42dc 4022fb79  
3fff1ac0:  000000fa deadbeef deadbeef 3ffef480  
3fff1ad0:  00003a98 00000000 3fff01d4 402026c8  

ctx: cont
sp: 3ffffe20 end: 3fffffd0 offset: 0000
3ffffe20:  00003a98 00000000 00000000 40205c92  
3ffffe30:  00000540 3fff4cdc 3fff42dc 4022f78c  
3ffffe40:  00000008 00000001 0000b3ba 00000000  
3ffffe50:  3fff47dc 402308e4 3fff42dc 00000000  
3ffffe60:  3fff47dc 3ffe8b20 3fff42dc 3ffe8b20  
3ffffe70:  00000000 00000001 3fff01d4 40205ce7  
3ffffe80:  00000000 00000001 3fff01d4 40205ed3  
3ffffe90:  00000000 0000b2ee 40c49ba5 00cee37a  
3ffffea0:  00000000 00000000 00000034 0000b2ee  
3ffffeb0:  00003a98 3fff3ffc 3fff1e08 40204fe7  
3ffffec0:  3fff42dc 3ffffefd 3ffef408 40214830  
3ffffed0:  1cc2e184 00000008 3ffef028 3ffef290  
3ffffee0:  000022b3 3ffe8b20 3fff01d4 40205f75  
3ffffef0:  40217cc4 2ced8c03 40217cc4 2ced8c03  
3fffff00:  00000000 00000000 00000000 4020f398  
3fffff10:  c36d654d 616972b3 76696c20 203a6572  
3fffff20:  00000000 3ffe8b4e 00000000 00000000  
3fffff30:  00000001 3ffef290 3ffef2b4 4020f640  
3fffff40:  00000000 00000000 00000000 3ffef5e4  
3fffff50:  3fffdad0 3ffef290 3ffef408 4020f584  
3fffff60:  00000000 00000000 00000001 4020f682  
3fffff70:  402612fb 3ffef290 3ffef268 4020152e  
3fffff80:  3ffef268 40204220 40216a70 4020109c  
3fffff90:  3fff54dc 3ffef290 3ffef268 4020245c  
3fffffa0:  3fffdad0 3ffef408 3ffef02c 4020259f  
3fffffb0:  feefeffe 00000000 3ffef5b8 402137fc  
3fffffc0:  feefeffe feefeffe 3fffdab0 40100e89  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

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

load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
tail 0
chksum 0x2b
csum 0x2b
v000759e0
~ld
����g��s��g|�l�d`c��|s�d�'��n�$`��s�l�le��*wm:v2.0.17  D:2

Commands: ‘r’ (Reset), ‘c’ (Configuration)

Connecting to WiFi...
*wm:AutoConnect 
*wm:Connecting to SAVED AP: GalaxyA21sHS
*wm:AutoConnect: SUCCESS 
*wm:STA IP Address: 10.156.4.211
Successfully connected!
SSID: GalaxyA21sHS
IP: 10.156.4.211
RSSI: -46 dBm

AWS IoT Connected!
[AWS] Published: {"heap":31496,"rssi":-49,"ssid":"GalaxyA21sHS"}
Memória livre: 31384 bytes
[AWS] Published: {"heap":30992,"rssi":-49,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes
[AWS] Published: {"heap":30992,"rssi":-49,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes

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

wdt reset
load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
tail 0
chksum 0x2b
csum 0x2b
v000759e0
~ld
���e�g�s��n|�$�l`c��|s�d�g��'�d`��r�l�d��*wm:v2.0.17  D:2

Commands: ‘r’ (Reset), ‘c’ (Configuration)
Connecting to WiFi...
*wm:AutoConnect 
*wm:Connecting to SAVED AP: GalaxyA21sHS
*wm:AutoConnect: SUCCESS 
*wm:STA IP Address: 10.156.4.211

Successfully connected!
SSID: GalaxyA21sHS
IP: 10.156.4.211
RSSI: -48 dBm

AWS IoT Connected!
[AWS] Published: {"heap":30824,"rssi":-48,"ssid":"GalaxyA21sHS"}
Memória livre: 31384 bytes
[AWS] Published: {"heap":30992,"rssi":-49,"ssid":"GalaxyA21sHS"}
Memória livre: 30320 bytes
[AWS] Published: {"heap":30992,"rssi":-49,"ssid":"GalaxyA21sHS"}
Memória livre: 30320 bytes
[AWS] Published: {"heap":30320,"rssi":-49,"ssid":"GalaxyA21sHS"}
Memória livre: 30768 bytes
Memória livre: 30992 bytes
[AWS] Published: {"heap":30992,"rssi":-50,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes
[AWS] Published: {"heap":30992,"rssi":-48,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes
[AWS] Published: {"heap":30992,"rssi":-50,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes
[AWS] Published: {"heap":30992,"rssi":-50,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes
[AWS] Published: {"heap":30992,"rssi":-49,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (0):
epc1=0x40204b06 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffd90 end: 3fffffd0 offset: 0150
3ffffee0:  00000411 0000012c 3fff307c 3fff1b04  
3ffffef0:  00000000 00000000 3fff01d4 3fff1b04  
3fffff00:  00000000 00000002 3fff01d4 40206238  
3fffff10:  00000200 00000000 3fff01d4 40205fe7  
3fffff20:  00000000 00000002 16872b02 01034a1a  
3fffff30:  00000010 3ffef290 3ffef290 3ffef5e4  
3fffff40:  00000001 0000e040 3ffef290 4020f190  
3fffff50:  00000000 3fffff60 00000008 3ffef5e4  
3fffff60:  00000000 00000000 3fff01d4 40205fe7  
3fffff70:  402612fb 3ffef290 00000000 40205470  
3fffff80:  3ffefedc 3ffef290 3ffef268 3ffef5e4  
3fffff90:  3fffdad0 3ffef290 3ffef268 40202461  
3fffffa0:  3fffdad0 3ffef408 3ffef02c 4020259f  
3fffffb0:  00000000 00000000 3ffef5b8 402137fc  
3fffffc0:  feefeffe feefeffe 3fffdab0 40100e89  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

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

wdt reset
load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
RSSI: -45 dBm

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (0):
epc1=0x4022c9b6 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

>>>stack>>>

ctx: bearssl
sp: 3fff17c0 end: 3fff1ae0 offset: 0150
3fff1910:  00000000 ce1ef0cc 3ba41873 66ce78f0  
3fff1920:  694dd5a3 5036a2ce b79d0127 c39aefab  
3fff1930:  b8f792f2 b6a4058d 3232bc70 e9126012  
3fff1940:  ad003a89 27fd4b58 7e984076 81cf2574  
3fff1950:  e61c99ed 978215d3 00000700 00000000  
3fff1960:  ac788939 32ed7d75 c1257f21 6548a489  
3fff1970:  67793332 c7791003 dd016393 9245af2a  
3fff1980:  dff0d42a 5f0bcd2b 211d62ac 150be6ad  
3fff1990:  ed6e014a deadbeef 00000680 00000000  
3fff19a0:  e7a42dc7 ba172931 cdaa8514 f5e3af58  
3fff19b0:  843ee104 72fccdaf cad28874 b6b03291  
3fff19c0:  e332d235 4c0b529f 9991945c 16716b1e  
3fff19d0:  2c347511 f719e5ae 474c43ed ab16799a  
3fff19e0:  3fff3e49 0000005a 40267dc0 deadbeef  
3fff19f0:  deadbeef 3fff3625 3fff45ac 3fff3884  
3fff1a00:  00000926 3fff3b60 3fff3860 40231184  
3fff1a10:  deadbeef deadbeef deadbeef deadbeef  
3fff1a20:  402684b2 deadbeef deadbeef deadbeef  
3fff1a30:  deadbeef deadbeef deadbeef deadbeef  
3fff1a40:  deadbeef deadbeef deadbeef deadbeef  
3fff1a50:  deadbeef deadbeef 40268a5c deadbeef  
3fff1a60:  3fff307c 3fff3910 3fff3880 3fff387c  
3fff1a70:  deadbeef deadbeef 3fff3060 000000ca  
3fff1a80:  000000ca deadbeef deadbeef deadbeef  
3fff1a90:  deadbeef deadbeef deadbeef 3fff3b7c  
3fff1aa0:  00000103 3fff3a7c 3fff307c 4022f78c  
3fff1ab0:  3fff3860 deadbeef 3fff307c 4022fb79  
3fff1ac0:  000000fa deadbeef deadbeef 3ffef480  
3fff1ad0:  00003a98 00000000 3fff01d4 402026c8  

ctx: cont
sp: 3ffffe20 end: 3fffffd0 offset: 0000
3ffffe20:  00003a98 00000000 00000000 40205c92  
3ffffe30:  00000540 3fff3a7c 3fff307c 4022f78c  
3ffffe40:  00000008 00000001 00000bce 00000000  
3ffffe50:  3fff357c 402308e4 3fff307c 00000000  
3ffffe60:  3fff357c 3ffe8b20 3fff307c 3ffe8b20  
3ffffe70:  00000000 00000001 3fff01d4 40205ce7  
3ffffe80:  00000000 00000001 3fff01d4 40205ed3  
3ffffe90:  00000000 00000af1 eb020c49 000ca7b7  
3ffffea0:  00000000 00000000 00000034 00000af1  
3ffffeb0:  00003a98 3fff2e7c 3fff1e08 40204fe7  
3ffffec0:  3fff307c 3ffffefd 3ffef408 40214830  
3ffffed0:  2265bddd 00063c15 000f4240 3ffef290  
3ffffee0:  000022b3 3ffe8b20 3fff01d4 40205f75  
3ffffef0:  40217cc4 7a4d7612 40217cc4 7a4d7612  
3fffff00:  00000000 00000000 00000000 4020f398  
3fffff10:  00005bdd 000c27f1 3ffef5bc 0000f424  
3fffff20:  00000000 3ffe8b4e 00000000 00000000  
3fffff30:  00000001 3ffef290 3ffef2b4 4020f640  
3fffff40:  00000000 00000000 00000000 3ffef5e4  
3fffff50:  3fffdad0 3ffef290 3ffef408 4020f584  
3fffff60:  00000000 00000000 00000001 4020f682  
3fffff70:  402612fb 3ffef290 3ffef268 4020152e  
3fffff80:  3ffef268 40204220 40216a70 4020109c  
3fffff90:  3ffefedc 3ffef290 3ffef268 4020245c  
3fffffa0:  3fffdad0 3ffef408 3ffef02c 4020259f  
3fffffb0:  feefeffe 00000000 3ffef5b8 402137fc  
3fffffc0:  feefeffe feefeffe 3fffdab0 40100e89  
<<<stack<<<
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

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

wdt reset
load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
tail 0
chksum 0x2b
csum 0x2b
v000759e0
~ld
���e�n�{��o<�$�l`c��|;�l�n��o�l`��s�l�le��*wm:v2.0.17  D:2

Commands: ‘r’ (Reset), ‘c’ (Configuration)

Connecting to WiFi...
*wm:AutoConnect 
*wm:Connecting to SAVED AP: GalaxyA21sHS
*wm:AutoConnect: SUCCESS 
*wm:STA IP Address: 10.156.4.211

Successfully connected!
SSID: GalaxyA21sHS
IP: 10.156.4.211
RSSI: -46 dBm

AWS IoT Connected!
[AWS] Published: {"heap":31496,"rssi":-48,"ssid":"GalaxyA21sHS"}
Memória livre: 31384 bytes
[AWS] Published: {"heap":30992,"rssi":-48,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes
[AWS] Published: {"heap":30992,"rssi":-49,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes
Memória livre: 30992 bytes
[AWS] Published: {"heap":30992,"rssi":-50,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes
[AWS] Published: {"heap":30992,"rssi":-50,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes
[AWS] Published: {"heap":30992,"rssi":-50,"ssid":"GalaxyA21sHS"}
Memória livre: 30992 bytes
[AWS] Published: {"heap":30992,"rssi":-49,"ssid":"GalaxyA21sHS"}

If you have not already done so, then nstall the Exception decoder and copy/paste the indicated section to it. Full details are in the link:

https://github.com/dankeboy36/esp-exception-decoder

Its really useful and should pinpoint the line of code that the problem occurs in.

Check the WiFi can carefully on both boards, are they the same?

thank you for sending this decoder, I've been looking for it for weeks and couldn't find one for the latest version of the IDE, which is what I use. I'll test it here and get back to you with any questions.

Regarding Hardware:

  • ESP-12E (NodeMCU)
    • ESP8266MOD
    • ISM 2.4GHz
    • PA +25dBm
    • 802.11b/g/n
  • ESP LOLIN D1 R1 WEMOS
    • ESP8266MOD
    • ISM 2.4GHz
    • PA +25dBm
    • 802.11b/g/n

When I bought the NodeMCU, I relied on these specs printed on the chip’s protective casing.

Regarding Firmware/Connection:

  • I used the same code, the same access point, at the same time, with both boards placed at the same distance from the router. Yet, the error keeps occurring.
ESP Exception Decoder
Sketch: MQTT_AcquaLink FQBN: esp8266:esp8266:d1

3fff1b48:  00003a98 00000000 3fff024c 402026ec  

ctx: cont
sp: 3ffffe10 end: 3fffffd0 offset: 0000
3ffffe10:  00003a98 00000000 00000000 40205cb6  
3ffffe20:  0000002c 3fff3cec 3fff32ec 4022f7ac  
3ffffe30:  00000008 00000001 000040b8 00000000  
3ffffe40:  3fff37ec 40230904 3fff32ec 00000000  
3ffffe50:  3fff37ec 3ffe8b92 3fff32ec 3ffe8b92  
3ffffe60:  00000000 00000001 3fff024c 40205d0b  
3ffffe70:  00000000 00000001 3fff024c 40205ef7  
3ffffe80:  00000000 00003fbf e6666666 0049b5e2  
3ffffe90:  00000000 00000000 00000034 00003fbf  
3ffffea0:  00003a98 3fff2ef4 3fff1e80 4020500b  
3ffffeb0:  3fff32ec 00000000 3fff024c 40205fc5  
3ffffec0:  40217ce4 00000000 3fffff90 3ffef2fc  
3ffffed0:  000022b3 3ffe8b92 3fff024c 40205f99  
3ffffee0:  40217ce4 39ac8c03 40217ce4 39ac8c03  
3ffffef0:  00000000 00000000 00000000 4020fb54  
3fffff00:  40217ce4 00000000 00000020 40100b10  
3fffff10:  00000000 3ffe8bc0 00000000 00000000  
3fffff20:  00000001 3ffef2fc 3ffef320 4020fdfc  
3fffff30:  00000000 00000000 00000000 3fff024c  
3fffff40:  3ffef3d4 3ffef2fc 3ffef2d4 4020fd40  
3fffff50:  00000000 00000000 00000001 3fff024c  
3fffff60:  3ffef3d4 3ffef2fc 3ffef2d4 402023dc  
3fffff70:  3ffef2d4 3ffef098 40216a90 4020109c  
3fffff80:  4026131b 00000000 3ffe864c 3ffef480  
3fffff90:  3ffeff54 40204244 3ffef098 3ffef65c  
3fffffa0:  3fffdad0 3ffef480 3ffef098 4020260a  
3fffffb0:  00000000 00000000 3ffef630 40213fa8  
3fffffc0:  feefeffe feefeffe 3fffdab0 40100e89  
<<<stack<<<

PC -> ??
Fault -> ??

0x402026ec: ??
0x40205cb6: BearSSL::WiFiClientSecureCtx::_run_until (unsigned int, bool) at C:\Users\PICHAU\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp:586
0x4022f7ac: jump_handshake () at src/inner.h:2211
0x40230904: br_ssl_hs_client_run () at src/ssl/ssl_hs_client.c:960
0x40205d0b: BearSSL::WiFiClientSecureCtx::_wait_for_handshake () at C:\Users\PICHAU\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp:609
0x40205ef7: BearSSL::WiFiClientSecureCtx::_connectSSL (char const*) at C:\Users\PICHAU\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp:1194
0xe6666666: ??
0x4020500b: WiFiClient::connect (IPAddress, unsigned short) at C:\Users\PICHAU\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\coredecls.h:69
0x40205fc5: BearSSL::WiFiClientSecureCtx::connect (IPAddress, unsigned short) at C:\Users\PICHAU\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp:212
0x40217ce4: ??
0x40205f99: BearSSL::WiFiClientSecureCtx::connect (char const*, unsigned short) at C:\Users\PICHAU\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp:228
0x40217ce4: ??
0x4020fb54: PubSubClient::connect (char const*, char const*, char const*, char const*, unsigned char, bool, char const*, bool) at c:\Users\PICHAU\OneDrive\Documentos\Arduino\libraries\PubSubClient\src\PubSubClient.cpp:196
0x40217ce4: ??
0x40100b10: malloc (size_t) at C:\Users\PICHAU\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\umm_malloc\umm_malloc.cpp:912
0x4020fdfc: std::function<void () at char*, unsigned char*, unsigned int)>::operator=(std::function<void (char*, unsigned char*, unsigned int)> const&) (c:\users\pichau\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits/move.h:189
0x4020fd40: PubSubClient::connect (char const*) at c:\Users\PICHAU\OneDrive\Documentos\Arduino\libraries\PubSubClient\src\PubSubClient.cpp:166
0x402023dc: AWSHandler::loop () at C:\Users\PICHAU\Downloads\MQTT_AcquaLink\AcquaLinkHandler.h:112
0x40216a90: std::_Function_handler<void () at char*, unsigned char*, unsigned int), AWSHandler::loop()::{lambda(char*, unsigned char*, unsigned int)#1}>::_M_manager(std::_Any_data&, std::_Function_handler<void (char*, unsigned char*, unsigned int), AWSHandler::loop()::{lambda(char*, unsigned char*, unsigned int)#1}> const&, std::_Manager_operation) (c:\users\pichau\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.1.0-gcc10.3-e5f9fec\xtensa-lx106-elf\include\c++\10.3.0\bits/std_function.h:268
0x4020109c: std::_Function_handler<void () at char*, unsigned char*, unsigned int), AWSHandler::loop()::{lambda(char*, unsigned char*, unsigned int)#1}>::_M_invoke(std::_Any_data const&, char*&&, unsigned char*&&, unsigned int&&) (C:\Users\PICHAU\Downloads\MQTT_AcquaLink/AcquaLinkHandler.h:99
0x4026131b: ??
0x40204244: ESP8266WiFiSTAClass::status () at C:\Users\PICHAU\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp:558
0x4020260a: WiFiHandler::loop () at C:\Users\PICHAU\Downloads\MQTT_AcquaLink\AcquaLinkHandler.h:244
0x40213fa8: loop_wrapper () at C:\Users\PICHAU\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp:258
0x40100e89: ?? () at C:\Users\PICHAU\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\cont.S:81