I have a breadboard Arduino that I work it with 8MHz external crystal. I need it to go to sleep and wake up every 30 minutes or so, measure the temperature with the on board temperature sensor and go back to sleep. I’m doing this project for school’s garden where we want to monitor the soil temperature.
The question here is how to make it go to sleep and wake up every 30 minutes. I’ve checked the WDT which I don’t think is a good fit for my purpose because they say that it is inaccurate. And since the max it could go is 8 seconds, I need to loop it to achieve 30 mins which also seems like a power waste somehow if I’m not mistaken. And by the way I need this system to be low-power.
I’ve checked the Timer/Counter 0,1 and 2. Timer 1 which is 16-bit can also only count up to approximately 8.3 seconds with the highest prescalar. Please do correct me if my math is wrong below.
((X seconds) x 8MHz) /1024 = 65.535
x= 8.3 secs
Also I’ve found a comment in this post (https://forum.arduino.cc/index.php?topic=425483.msg2931650#quickreply),
- It most likely uses the watchdog timer, which sucks for accuracy. If you want good timekeeping, you need to clock off a crystal. The Timer2 peripheral can have a separate crystal attached to drive it. It’s designed to use a 32.768 kHz crystal, which is the standard value used by real-time clocks and will keep very good time (0.001% accurate instead of 10%). Timer2 is left on if you use Power-save mode instead of Power-down.]
From this post I understand that Timer1 could be used with a 32kHz external clock. But can that count up to 30 minutes accurately and efficiently?
Or should I just use a RTC chip like DS1302? Would that be low-power?
So could you please guide this not very experienced avr programmer to find a suitable low-power way to make Atmega328p go to sleep and wake up every 30 mins or so.
I have no problems putting it to sleep and turning off the unnecessary peripherals thanks to Nick Gammon’s blog post. All I need is to find a suitable way to count and wake the MCU up in determined long periods like 30 mins or more and do this with as little power as possible.