Notifications
Clear all

ESP8266 timers with interrupts

2 Posts
1 Users
0 Likes
1,528 Views
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
Topic starter  

I'm looking for a mechanism for using timers on an ESP8266 to wake it from a light sleep every 15 minutes using an interrupt. A lot of topics point to a library called ESP8266TimerInterrupt, so I've been playing around with that. However, the accuracy of the timers leaves a lot to be desired.

I have a sample sketch running that configures a timer to interrupt the ESP8266 every 60s, but the timer is triggering at irregular intervals. I was under the impression this library was using the h/w timer1, so perhaps the ESP8266 can't guarantee accurate timers? Or it's actually a software timer?

19:22:53.677 -> Timer interrupt
19:23:20.545 -> Timer interrupt
19:23:47.390 -> Timer interrupt

My code is attached (ignore the references to the PIR).

Anyone trying to do something similar, and if so, what library or mechanism are you using?

 


   
Quote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
Topic starter  

Ah. The Timer library is probably using the h/w timer, but it's wrapping it in software to support longer timers. So that's probably why it's so inaccurate.

I've also been playing with an external RTC, so perhaps I'll learn I2C and play with that, unless someone can suggest another alternative.


   
ReplyQuote