Hello.
I'm developing an automated fertilizing system: once a day a pump activate itself for some seconds.
I use a trimmer to set how many seconds.
The system is an outdoor system and is driven by an Arduino 3v3 pro mini (maybe a simple ATtiny45 in future) and a lipo battery,
I want this system to be low power then.
So i think it is necessary to use a sleep mode library.
My question is: -how i can make Arduino able to count the time even if i'm using the sleep mode?
You can get a PCF8563 RTC clock module delivered for less than $1, with battery.
Use it to wake up the Pro Mini from deep sleep with an alarm interrupt, it can be set up to a month ahead.
A lot of Pro Minis will need modifying for very low power sleep.
I have been testing one here on the bench, I use it to turn off the power to an ESP32 based LoRa receiver via a MOSFET. In sleep mode the power consumption is less than 1nA. Replace the RTC battery maybe once a year to be safe.
Without a lot more detail, I doubt we can help you, which is why a solution using an RTC would be suggested, since its possible to achieve accurate timing, with very low power using a very low cost RTC module.
(Almost joking)
Put a GSM modem in, and derive the time from the cell network.
Wake and refresh when needed to check the time, or add a cheap, tiny RTC to make everything simple.
of course the modem will blow your low-power idea out of the water.
if the timing isn’t particularly specific (or time-of-day locked), use a WDT timeout and count the wake cycles to approximate th3e period calculation...
accuracy: after 30 day it is ok to have the pump activated between 29 and 31 times (so 30days +-1).
srnet:
What is the capacity of the battery ?
capacity of the battery: i will use 2x1,5V AAA 1000mAh
srnet:
How long must the battery last ?
expected battery life: minimum 6months, 9-12 months are welcome. Pump drain is 100mA x 4 sec x day.
I'm building a very low cost, very low sized and weighted device, so i need to check how much error i could have in order to decide if using a RTC or not.
How can i calculate the daily cumulative error using a watchdog (8sec) + for cycle as a timer?
How can i calculate the daily cumulative error using a watchdog (8sec)
The processor data sheet gives the expected range of timing parameters, which depends on the temperature and supply voltage. May be larger than +/- 3%.
A far more accurate option would be to use a 32 kHz crystal connected to Timer2, which can be used as an RTC in sleep mode.
The motor would draw (4/3600)*100 = 0.111 mAhr per day or 20mAhr over 6 months, not a problem for a 1000mAhr battery.
Is the +/- 3% expected from the watchdog timer accurate enough ?
If it was you could then put the Arduino into deep sleep in units of 8 seconds (the max watchdog time).
The processing time on wakeup from deep sleep (counting the 8 second steps) is very short, around 1mS, so little power used there, maybe 0.015mAhr per day.
However what I am not sure of is what is the time from the watchdog wakeup going active that the processor then waits for the clock to be stable before running code. That time is presumably the processor at idle current and could be significant.
srnet:
The motor would draw (4/3600)*100 = 0.111 mAhr per day or 20mAhr over 6 months, not a problem for a 1000mAhr battery.
Exactly dear srnet.
srnet:
Is the +/- 3% expected from the watchdog timer accurate enough ?
+-3% it is accurate enough. It means in a month the pump has been activated 29 or 30 or 31 times.
srnet:
If it was you could then put the Arduino into deep sleep in units of 8 seconds (the max watchdog time).
Yes i can.
srnet:
The processing time on wakeup from deep sleep (counting the 8 second steps) is very short, around 1mS, so little power used there, maybe 0.015mAhr per day.
Yes i know.
srnet:
However what I am not sure of is what is the time from the watchdog wakeup going active that the processor then waits for the clock to be stable before running code. That time is presumably the processor at idle current and could be significant.
I have undestoo until "that time is presumably the processor... ..significant". Can you explain me better?
Well, my doubts are that around the web i read people saying there could be an error of 10%.
And if the rate is like this, i should really consider if adding an RTC or not. The fact is that i'm going to build like 100 of this project and so create a thing which is as simple and cheap as possible.
The processor will take a while to wake up from deep sleep, stabilise, run some counting code and go back to sleep.
Imagine that takes 100mS, current consumed will be maybe 5mA, and you need to do it every 8 seconds, 10,800 times a day. So thats 0.1 x 5 x 10,800 = 5,400mAsecs a day or 1.5mAhr per day.
What the stablise time is, I dont know, I guess you would actually need to measure it for your setup.
You would not have this problem, and the timing would be much more accurate using a $1 RTC module.