How to fix Guru Meditation Error: Core 1 panic'ed (LoadProhibited) error


I am trying to write code for the ESP32 chip where it takes in readings from a DHT22 sensor, packages it into a json file, and then sends it to a Flask server. Everything works just fine up until I try to POST, where I get the following error:

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x400d3488  PS      : 0x00060030  A0      : 0x800d355c  A1      : 0x3ffb1bb0  
A2      : 0x00000000  A3      : 0x3ffb1bff  A4      : 0x00000001  A5      : 0x00000001  
A6      : 0x00000000  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x00000000  
A10     : 0x00000000  A11     : 0x3ffcb8fc  A12     : 0x00000050  A13     : 0x00000001  
A14     : 0x00000000  A15     : 0x00000000  SAR     : 0x0000000a  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000008  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff

I have tried an exhaustive search on this issue to no avail, and I have no idea what is going on. Would anyone be able to give insight on how to fix this issue?

This is my Arduino code:

#include <HTTPClient.h>
#include <WiFi.h>
#include <DHT.h>
#include <ArduinoJson.h>

#define DHTTYPE DHT22

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

uint8_t sensor = 16;
DHT dht(sensor, DHTTYPE);

void setup() {
  WiFi.begin(ssid, password);

  while(WiFi.status() != WL_CONNECTED) {

void loop() {
  if(WiFi.status() == WL_CONNECTED) {
    HTTPClient http;
    http.addHeader("Content-Type", "text/plain");
    Serial.println("Began http on Flask");

    const int cap = JSON_OBJECT_SIZE(2);
    StaticJsonDocument<cap> doc;
    Serial.println("Created json document");

    doc["temperature"] = dht.readTemperature();
    doc["humidity"] = dht.readHumidity();
    Serial.println("Read temperature and humidity correctly");

    char output[256];
    serializeJsonPretty(doc, output);
    //Code will give back error after trying to POST
    int httpCode = http.POST(output);
    Serial.println("Got httpCode");
    if(httpCode > 0) {
    } else Serial.println("Error in Connection");

There are print statements here that will print out various things depending on how far it gets into the code. It prints out the json document just fine, but does not print out "Got httpCode". Below is my code for the Flask server:

from flask import Flask, request
app = Flask(__name__)

@app.route('/', methods = ['POST'])
def hello():
    req = request.get_json()
    return "Thanks", 200

if __name__ == "__main__": = '', port = 8090)

Thank you in advance for the help.

asked on Stack Overflow Aug 13, 2020 by bigblueman

2 Answers


I also got this error while using WebSockets.

It turned out that the buffer(declared globally) that I used for receiving messages was appending new messages instead of overwriting the pre-existing contents in it. So, an illegal memory-write attempt was made and the device panicked and rebooted.

Solution: I simply declared the buffer locally inside the onWebSocketEvent() function and the problem of overwriting was solved as the buffer was getting re-declared on every event preventing illegal memory-write attempt. The device never panicked ever again.

answered on Stack Overflow Nov 19, 2020 by MOHAMMAD RIDWAN KABIR Lecturer • edited Nov 19, 2020 by Dharman

I experienced a Guru error in the middle of a callback, the reason for that is because the micro is running out of memory. The solution was getting rid of unused libraries and using pointers instead of creating local variables.

answered on Stack Overflow Aug 13, 2020 by sirDeniel

User contributions licensed under CC BY-SA 3.0