Hello,
The project I am working on is basically a lamp that is powered by a battery. There is a manual swithch to turn On/Off the light and the trick is that the device should be activated only for 24 hours and if the voltage is higher that a treshold. When the activation time is over, it can be reactivated by USART connection. There are actually other features, but for simplicity, we can keep it to the simple lamp configuration.
To do that I use an arduino nano with the switch on pin D2 and the LED on D10. I don't give all the hardware details because I think it is not usefull for my question, but i can give you more details if you want. The battery is a 3.4V LFP with 6000 mAh capacity.
So the challenge is to diminish the arduino consumption to allow the LED to work for the longest time possible (at the moment, light can be emit for 10 hours and if not used, the device use the whole battery after ~4 days). An other important point is the precision of the activated time. For 24 hours, a +/- 10min would be okay, but not more.
To lower the consumption, I started reading the topic about Power on gammon.com. Seeing that the microcontroller has no work to do for long period (no one will use the lamp to make a manual stroboscope for hours I guess), put the arduino to sleep seems to be a good option to me. I would also try other ideas from Gammon i think, but I started with the sleep. I have also already check a lot on the forum for this topic and found some good answers for previous issues, but I reach a point where a I am stucked even with what I have found.
Below I present the 3 main steps I tried with my conclusion for each of them:
-
Firstly, I have used the Power-Down mode with a PinInterrupt on the switch (D2) and a Watchdog to have a voltage check every 8 seconds and keep track of activated time. But two main drawback occurs : Firstly the watchdog is not precise enough and secondly, we decided that USART communication for the activation of the device should be instantaneous. To solve the USART problem, I have tried option 2.
-
I have used the IDLE mode using power_all_disable() + power_usart0_enable() (to maximize power saving) and keep the 8s watchdog for the moment. It works pretty well to wakeup the arduino as soon as something was sent by USART. But again watchdog is not precise enough, which lead to next option.
-
To have a more precise track of time, I decided to keep Timer0 enabled to use millis(). The problem is that the device wake up every millisecond due to the Timer0 interrupt. Which is not really usefull to have a proper sleep.
After this introduction, which I hope is clear and present correctly what I have already tried, here are my questions :
-
Is it possible to deactivated the timer0 interrupt only (so keep the Pin ans WDT interrupt) while being able to use millis() ? and if so, how ?
-
If answer to question 1 is negative, I immagine that I would have to use an external RTC. I check for available RTC, and many have a battery backup and are quite expensive. Seeing that I don't want any other battery than the main one and keep the electronic system as cheap as possible (less than 1$ for extra RTC device), I saw that the brand Microchip seems to make some RTC that would suit my requirements. Do you thing it is a good idea to try one of those ? I found some project using them, but if you have some good examples, I would be glad to see them !
If you have any other ideas, feel free to make sugestions ! Just keep in mind that any options with a supplementary battery or that is more than 1$ are not an option, and that a maximum of +/-10 min out of 24h is necessary !
Hope it was clear and thanks in advance for your help ! if you need any information, I will be pleased to give you more details.
Manuel