gw.sleep() and millis()

9 years 23 hours ago - 8 years 11 months ago #1192 by PaulRB
Hi, hopefully a quick question:

My MySensors sketches contain calls such as
gw.sleep(60000);
for 1 minute low-power sleeps. This command also allows for waking on a hardware interrupt, e.g. on pin 3 on atmega328.

Will millis() continue to update normally during low power sleeps? I want to use it for measuring the time between interrupt events. If not, how can I measure how long the sleep was before the interrupt occurred?

I ask because I want to connect up an anemometer. The anemometer contains a reed switch, activated by a magnet, which is closed twice per revolution. By timimng the period between switch closed or open events, or by counting the number of such events over a fixed period, I will be able to calculate wind speed (I have calibration data to use in that calculation). Either way, I need to measure time intervals accurately, while keeping the atmega in low power sleep as much as possible.


Thanks,

Paul

Please Log in or Create an account to join the conversation.

9 years 6 hours ago #1202 by EasyIoT
Replied by EasyIoT on topic gw.sleep() and millies()

PaulRB wrote: Hi, hopefully a quick question:

My MySensors sketches contain calls such as

gw.sleep(60000);
for 1 minute low-power sleeps. This command also allows for waking on a hardware interrupt, e.g. on pin 3 on atmega328.

Will millis() continue to update normally during low power sleeps? I want to use it for measuring the time between interrupt events. If not, how can I measure how long the sleep was before the interrupt occurred?

I ask because I want to connect up an anemometer. The anemometer contains a reed switch, activated by a magnet, which is closed twice per revolution. By timimng the period between switch closed or open events, or by counting the number of such events over a fixed period, I will be able to calculate wind speed (I have calibration data to use in that calculation). Either way, I need to measure time intervals accurately, while keeping the atmega in low power sleep as much as possible.


Thanks,

Paul


If I remember correctly mils() doesn't work correctly during gw.sleep. Some ideas to solve this:
-change MySensors library to use different sleep library. Some sleep libraries allow mils()
-use external RTC to measure time
-send pulses to EasyIoT server and let the server do the calculation

Please Log in or Create an account to join the conversation.

Time to create page: 0.275 seconds

Forum latest

  • No posts to display.