Theb-1 / ESP8266-wifi-light-dimmer

MIT License
66 stars 33 forks source link

Timer does not work for ESP8266 Arduino Core layer than 2.4.1 #8

Open lspaula opened 5 years ago

lspaula commented 5 years ago

Dear,

Unfortunately the board keeps rebooting if using ESP8266 Arduino cores later than version 2.4.1. I have found out this is related to the timer and interruption, but still did not figured out why. If anybody could help with this, it would be much appreciated.

Regards,

Luciano

shrimantpatel commented 5 years ago

I did not see reboots but I did see the Wifi reconnecting after almost every 1-5 minutes as below, I started printing the current time from the ZeroCross detector method:

`Tue Aug 6 00:34:31 2019

Tue Aug 6 00:35:02 2019

state: 5 -> 2 (3c0) rm 0 reconnect state: 2 -> 0 (0) scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 2 cnt

connected with chottu, channel 7 dhcp client start... ip:10.10.10.2,mask:255.255.255.0,gw:10.10.10.254 Tue Aug 6 00:35:33 2019

Tue Aug 6 00:36:04 2019

Tue Aug 6 00:36:35 2019

Tue Aug 6 00:37:06 2019

Tue Aug 6 00:37:37 2019

Tue Aug 6 00:38:08 2019

Tue Aug 6 00:38:39 2019

Tue Aug 6 00:39:10 2019

Tue Aug 6 00:39:41 2019

Tue Aug 6 00:40:12 2019

state: 5 -> 2 (3c0) rm 0 reconnect state: 2 -> 0 (0) scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 2 cnt

connected with chottu, channel 7 dhcp client start... ip:10.10.10.2,mask:255.255.255.0,gw:10.10.10.254 Tue Aug 6 00:40:43 2019

Tue Aug 6 00:41:14 2019

Tue Aug 6 00:41:45 2019

Tue Aug 6 00:42:16 2019

Tue Aug 6 00:42:47 2019

`

AndreasMaverick commented 4 years ago

Hello Luciano, did you found a solution for the reboot issue? Since I observe the same phenomenon. Kind regards, Andreas

lspaula commented 4 years ago

Hello Luciano, did you found a solution for the reboot issue? Since I observe the same phenomenon. Kind regards, Andreas

Yes. Just make sure you update to the latest version and declare your interruption at the start of your sketch, just before the Setup, like that: void ICACHE_RAM_ATTR dimTimerISR(); Also declare the following at the end of your setup:

hw_timer_init(NMI_SOURCE, 0); hw_timer_set_func(dimTimerISR);

It solves the problem.

Regards