Having a first set of batteries empty wasn’t funny.. they lasted only 7 weeks! Way to short. And i kept on thinking that it might not have been caused by a bad battery.. what could i do next? Wait another 7 weeks to find out that I’m wrong? Neh.. that didn’t feel the right thing to do; Power down as much as possible and use an external interrupt would possibly give the best results anyway, so why not start with that right now!
I started with attaching a push-button to an Arduino, using a pull-up resistor to keep the input high when the button isn’t pressed:
After that i started reading about interrupts. Here’s a table that shows the Wake-up sources that are available in the various sleep modes:
Both things i need are available: INT0 and/or INT1 and the Watchdog Timer, so it was time to start sketching
After 5 different sketches with all the same miserable results (freezing Arduino), i finally found a sleep library that did exactly what i wanted. I combined this library with code i had found earlier regarding setting up and using the Watchdog Timer, and what i have now, is just what i need. Below a sample of the Serial Monitor output and here is the sketch that produced it.
39171 I'm awake, caused by the WDT 39205 Sleeping... 39327 I'm awake, caused by the WDT 39362 Sleeping... 39484 I'm awake, caused by the WDT 39519 Sleeping... 39640 I'm awake, caused by the WDT 39674 Sleeping... 39796 I'm awake, caused by INT0 Doing some work...finished! 40257 Sleeping... 40377 I'm awake, caused by INT0 Doing some work...finished! 40839 Sleeping... 40960 I'm awake, caused by INT0 Doing some work...finished! 41421 Sleeping... 41542 I'm awake, caused by the WDT 41577 Sleeping... 41698 I'm awake, caused by INT0 Doing some work...finished! 42160 Sleeping... 42280 I'm awake, caused by the WDT 42315 Sleeping... 42437 I'm awake, caused by the WDT 42472 Sleeping... 42593 I'm awake, caused by the WDT 42628 Sleeping... etc. etc.
Cool stuff!
Let’s see how we can change the motion sensor to make use of this!










The enclosure i used this time is a bit different from the enclosure i used on a 




This reduces the visible size of a motion sensor with more than a half and there’s no more antenna, yippee !