ESP32 reboot when using wifi and timer iterrupt

Lukas1234
Posts: 1
Joined: Thu Mar 17, 2022 1:40 pm

ESP32 reboot when using wifi and timer iterrupt

Postby Lukas1234 » Thu Mar 17, 2022 1:54 pm

Hello community :)

I try to send via UDP data from my ESP32 to my laptop. Sending the data in the loop()-fuction works without any problems.
Now I want to send the data using an interrupt fuction (timer based).

void IRAM_ATTR onTimer()
{
Serial.println("test");
if(connected){
//Send a packet
udp.beginPacket(udpAddress,udpPort);
udp.printf("test");
udp.endPacket();
}
}

The timer starts and the ESP32 connects to my wifi, but after 2 seconds the ESP32 resets. Then the timer starts again and the ESP32 connects again and so on.
Without sending data via udp there is no reset.

DO you have any ideas what my problem is?

Thanks for you help

Yours Lukas

ESP_Sprite
Posts: 9746
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 reboot when using wifi and timer iterrupt

Postby ESP_Sprite » Fri Mar 18, 2022 12:29 am

There's a fair few things you can't do in an interrupt... and println and sending UDP data likely are not things that are allowed there. Suggest reworking your interrupt to simply set a flag or semaphore or something, and doing the actual printing and sending in a task (maybe your main loop function can do it?).

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 108 guests