esp32 read timer wakeup remaining time

Hr.Mitrev
Posts: 4
Joined: Tue Sep 04, 2018 2:31 pm

esp32 read timer wakeup remaining time

Postby Hr.Mitrev » Fri Apr 23, 2021 1:39 pm

Hi!

I am currently developing application that reads a few sensors and uploads the data to a server. After I do that I want to enter deep sleep.
My problem is that the measuremets may take variable time or even more time than the interval between measurements which I can reconfigure. At the same time I want to keep this interval as consistent as possible. One way I can do that is by getting the time of wakeup and after upload to calculate the time it took to measure, substract that time from the interval to calculate how long to sleep.
But I want to make it simpler, so it would be nice to setup wakeup timer immidiately after wakeup and at the end get to sleep. Unfortunately there is the corner case when the timer expires before I enter deep sleep which is a big problem.

So my simple question is: Can I set a wakeup timer which will count while I'm awake and also read the remaining time at any point? Now I'm using esp-idf v4.2 and I cannot find a way to read the remaining time on the wakeup timer.

PS: I have though about xTaskGetTickCount() which will probably also help, but still I think in my case it will be better to just read the wakeup timer

Cheers!

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: esp32 read timer wakeup remaining time

Postby WiFive » Fri Apr 23, 2021 7:31 pm

No just use esp_timer_get_time. The wakeup timer is actually just an alarm and not a countdown timer.

Who is online

Users browsing this forum: Cemal5454 and 81 guests