need a 12 hour sleep cycle for my arduino.

Hi all!

I'm extremely new to the Arduino space and I recently tackled a project where I need my Arduino to check soil moisture every 12 hours. After some research, I found that everyone said the best way to do this is to use an RTC and set a sleep cycle.

Now I just bought the only RTC available in my country which is the DS1302, I am able to get the DS3231, but at around $30 without shipping or import taxes which I am not willing to do. so I need a way to set up that sleep cycle with either the DS1302 or none at all.

any suggestions?

On the Arduino Uno and other ATmega boards, you can use the built in watchdog timer to wake up from sleep. The maximum timeout is about 8 seconds, so if you count 43200 wakeups, that will be very roughly 12 hours.

Adjust the count for best accuracy.

You can use an RTC, but if the timing is not critical, the indeed the watchdog is a simple solution, no additional hardware is needed.

If the sensor is standalone and recording data to SD card for instance, then maybe time accuracy is an issue for you.

If the data is being remotly collected via radio transmission then the accuracy of the timing is probably not important at all, just send it every couple of hours and have the data collector record the times received.

The DS1302 doesn't have the "alarm" function (or output) that would be needed to do the "obvious" "wake up the processor in 12 hours" function. However, you could use it to calibrate the less-accurate watchdog wakeup - somewhere around 40000 wakeups you could read the RTC and make a good guess at how many more wakeups would get you close to 12 hours, and then "near" then, read the RTC every wakeup looking for 12H +/- 8s...

I use an Uno to do something every 24 hours for an hour. No RTC. It isn't as accurate as a RTC but it is good enough. USB power from a wall wart so no sleeping.

The timing is based on the time that the Arduino gets power so no buttons.