Exception decoder ESP8266

My ESP8266 always resatrting and printing in the serial monitor

Exception (9):
epc1=0x40213dac epc2=0x00000000 epc3=0x00000000 excvaddr=0x000001b7 depc=0x00000000

stack>>>

ctx: cont
sp: 3ffffc70 end: 3fffffc0 offset: 0190
3ffffe00: 00000000 00000000 4bc6a7f0 00000000
3ffffe10: 3ffeebf4 00000000 40100205 00000000
3ffffe20: 0000363e 3ffefc50 00001a73 00000000
3ffffe30: 000000b9 000000b9 3ffe85e4 ffffffff
3ffffe40: 0000363e 3fffff44 3ffef724 40201f20
3ffffe50: 0000012c 00000020 3ffefc4c 3ffee828
3ffffe60: 3fffdad0 00000020 3ffef724 3ffee828
3ffffe70: 3fffdad0 3fffff44 00000001 402023b9
3ffffe80: 3ffee1a0 3ffee88c 000003e8 402023ed
3ffffe90: 3fffdad0 3ffffec0 3ffee798 40202414
3ffffea0: 40206845 000000c8 3ffee798 402028d8
3ffffeb0: 3fffdad0 000000c8 3ffee798 402014b4
3ffffec0: 3fffff44 3ffef6d4 001f001f 80000000
3ffffed0: ff010050 fe001388 3ffef6fc 0011001f
3ffffee0: 80000000 70747468 00000000 04000000
3ffffef0: 3ffefd7c 0000004f 80000000 3ffefa44
3fffff00: 0011001f 80000000 00000000 40207224
3fffff10: 00000000 00000000 00000000 00000000
3fffff20: ffffffff 1db79401 00000000 3ffe000a
3fffff30: 00000000 3ffe88e4 00000000 00000001
3fffff40: 00000000 40209338 00000000 00001388
3fffff50: 00003254 00000000 00000000 3ffef724
3fffff60: 00000000 00000000 000f000f 00000000
3fffff70: 00000000 000c000f 00000000 00000000
3fffff80: 000c000f 00000000 00000000 34414238
3fffff90: 00000000 00000000 3ffee814 40100185
3fffffa0: 3fffdad0 00000000 3ffee814 402062a8
3fffffb0: feefeffe feefeffe 3ffe85e0 40100c01
<<<stack<<<

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

what happen? can someone help?

the code is

#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h> 
#include <WiFiClient.h>
#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN D4  
#define RST_PIN D3 
MFRC522 mfrc522(SS_PIN, RST_PIN); 

#define ON_Board_LED 2


const char* ssid = "Khjkul";
const char* password = "k4mpr3t4j4";


ESP8266WebServer server(80);

int readsuccess;
byte readcard[4];
char str[32] = "";
String StrUID;

void setup() {
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();

  delay(500);

  WiFi.begin(ssid, password);
  Serial.println("");
    
  pinMode(ON_Board_LED,OUTPUT); 
  digitalWrite(ON_Board_LED, HIGH);


  Serial.print("Connecting");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    digitalWrite(ON_Board_LED, LOW);
    delay(250);
    digitalWrite(ON_Board_LED, HIGH);
    delay(250);
  }
  digitalWrite(ON_Board_LED, HIGH); 
  Serial.println("");
  Serial.print("connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  Serial.println("Tag a card");
  Serial.println("");
}

void loop() {
  // put your main code here, to run repeatedly
  readsuccess = getid();
 
  if(readsuccess) {  
  digitalWrite(ON_Board_LED, LOW);
    HTTPClient http;    //Declare object of class HTTPClient
      WiFiClient client;
 
    String uidSend, postData;
    uidSend = StrUID;
   
    //Post Data
    postData = "uid=" + uidSend;
  
    http.begin(client,"http://mellowed-bunk.000webhostapp.com/duino/getUID.php");  //Specify request destination
    http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //Specify content-type header
   
    int httpCode = http.POST(postData);   //Send the request
    String payload = http.getString();    //Get the response payload
  
    Serial.println(uidSend);
    Serial.println(httpCode);   //Print HTTP return code
    Serial.println(payload);    //Print request response payload
    
    http.end();  //Close connection
    delay(1000);
  digitalWrite(ON_Board_LED, HIGH);
  }
}

int getid() {  
  if(!mfrc522.PICC_IsNewCardPresent()) {
    return 0;
  }
  if(!mfrc522.PICC_ReadCardSerial()) {
    return 0;
  }
 
  
  Serial.print("THE UID IS : ");
  
  for(int i=0;i<4;i++){
    readcard[i]=mfrc522.uid.uidByte[i]; //storing the UID of the tag in readcard
    array_to_string(readcard, 4, str);
    StrUID = str;
  }
  mfrc522.PICC_HaltA();
  return 1;
}

void array_to_string(byte array[], unsigned int len, char buffer[]) {
    for (unsigned int i = 0; i < len; i++)
    {
        byte nib1 = (array[i] >> 4) & 0x0F;
        byte nib2 = (array[i] >> 0) & 0x0F;
        buffer[i*2+0] = nib1  < 0xA ? '0' + nib1  : 'A' + nib1  - 0xA;
        buffer[i*2+1] = nib2  < 0xA ? '0' + nib2  : 'A' + nib2  - 0xA;
    }
    buffer[len*2] = '\0';
}

here is what i get when i use ESP Exception decoder
Decoding stack results

0x40100205: millis() at C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 193

0x40201f20: ClientContext::wait_until_acked(int) at C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src/include/ClientContext.h line 347

0x402023b9: WiFiClient::flush(unsigned int) at C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\WiFiClient.cpp line 311

0x402023ed: WiFiClient::stop(unsigned int) at C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src\WiFiClient.cpp line 319

0x40202414: WiFiClient::stop() at C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src/WiFiClient.h line 75

0x40206845: __delay(unsigned long) at C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 55

0x402028d8: HTTPClient::~HTTPClient() at C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 60

0x402014b4: loop() at C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/WString.h line 79

0x40207224: uart_write(uart_t*, char const*, size_t) at C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\uart.cpp line 546

0x40100185: esp_schedule() at C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 128

0x402062a8: loop_wrapper() at C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 201

Exception(9) is Load or store to an unaligned address
See Exception Causes (EXCCAUSE) — ESP8266 Arduino Core 3.1.1-15-gbadb407b documentation

EDIT
As first troubleshooting steps, I'd:

  1. Ensure compiler warnings are switched on.
  2. Change this:
   array_to_string(readcard, 4, str);
   StrUID = str;

to:

   // array_to_string(readcard, 4, str);
   StrUID = String("A1FF0133");  // random selection

and see if the problem goes way.
The stack trace does not appear to refer directly to any line in your sketch which makes it more difficult to troubleshoot.

DId you also get a restart log as referred to here:
image
You may have change the baud rate to see it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.