Not sure what's causing Guru Meditation Error

Not sure what's going on here, I'm fairly new to Arduino so I'm not sure were to start to diagnose this error. My Code is:

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <ESP32Time.h>
#include "WiFi.h"
#include "time.h"

Adafruit_BME280 bme;
const char* ssid = "xxxxxxx";
const char* password = "xxxxxxx";
float temperature, humidity;

const long gmtOffset_sec = -18000;
const int daylightOffset_sec = 3600;
const char* ntpServer = "pool.ntp.org";
const int freq = 5000;
const int ledChannel = 0;
const int resolution = 8;

const int led_pin = 6;

void printLocalTime() {
  struct tm timeinfo;
  if (!getLocalTime(&timeinfo)) {
    Serial.println("Failed to obtain time");
    return;
  }
  Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
}

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

  Serial.begin(115200);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi..");
  }

  Serial.println("Connected to the WiFi network");
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
  printLocalTime();

  delay(1000);
  ledcSetup(ledChannel, freq, resolution);
  ledcAttachPin(led_pin, ledChannel);
  pinMode(2, OUTPUT);
  bme.begin(0x76);
}

void loop() {

  humidity = bme.readHumidity();
  temperature = bme.readTemperature();
  if (humidity >= 90) {
    digitalWrite(2, HIGH);
  } else if (humidity <= 82) {
    digitalWrite(2, LOW);
  }



  if ("%H:%M" == "8:00") {
    for (int dutyCycle = 0; dutyCycle <= 255; dutyCycle++)
      ledcWrite(ledChannel, dutyCycle);
    delay(15000);
    Serial.println("Day light on");
  }

  else if ("%H:%M" == "21:00") {
    for (int dutyCycle = 255; dutyCycle >= 0; dutyCycle--)
      ledcWrite(ledChannel, dutyCycle);
    delay(15000);
    Serial.println("Day light off");
  }

  Serial.print("Current humidity = ");
  Serial.print(humidity);
  Serial.print("%  ");
  Serial.print("temperature = ");
  Serial.print(temperature);
  Serial.println("C  ");
  printLocalTime();
  delay(10000);
}

And the complete error is as follows:

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
Connecting to WiFi..
Connecting to WiFi..
Connecting to WiFi..
Connecting to WiFi..
Connecting to WiFi..
Connected to the WiFi network
Thursday, August 11 2022 12:56:59
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x400d3aff  PS      : 0x00060a30  A0      : 0x800d0740  A1      : 0x3ffb1f60  
A2      : 0x00000006  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x00000000  
A6      : 0x3ff59000  A7      : 0x00000000  A8      : 0x800d3af5  A9      : 0x3ffb1f40  
A10     : 0x3ff44098  A11     : 0x00000047  A12     : 0x3ffcb6e0  A13     : 0x00000000  
A14     : 0x00000000  A15     : 0x3ffc1b8c  SAR     : 0x0000001a  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x800d0740  LBEG    : 0x400029ac  LEND    : 0x400029cb  LCOUNT  : 0x00000000  

ELF file SHA256: 0000000000000000

Backtrace: 0x400d3aff:0x3ffb1f60 0x400d073d:0x3ffb1f80 0x400d4f22:0x3ffb1fb0 0x4008a02e:0x3ffb1fd0

You can use the ESP Stack Trace Decoder to find the specific location in the code where the error happens. If you cannot find the reason for the GME, please post the output of the exception decoder here.

Or you could take the typical debugging approach: strip your code of everything except the simplest "connect to wifi" part, and then add small pieces of code back in until you get it to crash.

This is the output I received from the tool

Decoding stack results
0x400d3aff: _arduino_event_cb(void*, esp_event_base_t, int32_t, void*) at C:\Users\GRahn\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.4\libraries\WiFi\src\WiFiGeneric.cpp line 512
0x400d4f22: pinMatrixInDetach at C:\Users\GRahn\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\2.0.4\cores\esp32\esp32-hal-matrix.c line 55
0x4008a02e: strcat at /builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/string/strcat.c line 67

here is your setup-function with some more serial output to narrow down the problem
let's see which is the last line that gets printed

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

  Serial.begin(115200);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi..");
  }

  Serial.println("Connected to the WiFi network");
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
  Serial.println("configTime(... done");
  printLocalTime();
  Serial.println("printLocalTime()... done");

  delay(1000);
  Serial.println("delay(1000) done");
  ledcSetup(ledChannel, freq, resolution);
  Serial.println("ledcSetup(ledChannel done");
  ledcAttachPin(led_pin, ledChannel);
  Serial.println("ledcAttachPin(led_pin done");
  pinMode(2, OUTPUT);
  bme.begin(0x76);
  Serial.println("bme.begin(0x76) done");
}

best regards Stefan

Looks like the last line to get printed is LedcSetup

Connecting to WiFi..
Connected to the WiFi network
configTime(... done
Thursday, August 11 2022 14:56:55
printLocalTime()... done
delay(1000) done
ledcSetup(ledChannel done
Guru Meditation Error: Core  1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x400d443c: 80bb3020 00000000 ffffff0a
Core 1 register dump:
PC      : 0x400d4440  PS      : 0x00060a30  A0      : 0x800d095c  A1      : 0x3ffb1f60  
A2      : 0x00000006  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x00000000  
A6      : 0x3ff59000  A7      : 0x00000000  A8      : 0x800d442d  A9      : 0x3ffb1f40  
A10     : 0x3ff44098  A11     : 0x00000047  A12     : 0x00000000  A13     : 0x00000000  
A14     : 0x00000000  A15     : 0x3ffc1c7c  SAR     : 0x0000001a  EXCCAUSE: 0x00000000  
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffff  

ELF file SHA256: 0000000000000000

Backtrace: 0x400d4440:0x3ffb1f60 0x400d0959:0x3ffb1f80 0x400d5956:0x3ffb1fb0 0x4008a0f6:0x3ffb1fd0

hm strange

no experience with that just a wild guessing
how about a test with

const int freq = 1000; //5000;
const int ledChannel = 1; //0;
const int resolution = 8;

const int led_pin = 4;  //6;

I haven't researched what IO-pin 6 exactly is. But as IO-pin 6 is usually not in ESP32-pin-outs
maybe this is causing the reset

Great Catch!

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