Hardware Reference
In-Depth Information
ISR(WDT_vect) { Sleepy::watchdogEvent(); }
In the loop() function of the sketch, we switch the LED on and off, but the important
part here is that we use a special function to introduce some delay:
Sleepy::loseSomeTime(5000);
The difference with the delay() function of Arduino is that the Arduino controller is
put in the sleep mode during this time, whereas with the delay() function, the chip just
waits.
Note
The code for this part can be found inside the GitHub repository of the project at the fol-
lowing link:
https://github.com/openhomeautomation/arduino-home-automation/tree/master/chapter7
I performed some measurements to show you the difference with and without the library.
Without the use of the library, the system was using 6.7 mA when the LED was off. With
the use of the library, it was only consuming 43 uA, which is a 150x improvement over
the first case.
This means that for a system which is not active most of the time (such as a temperature
sensor or a motion sensor), it can work for years without changing the battery!
Search WWH ::




Custom Search