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