Due to various stability issues on the Core, I hacked together a little Watchdog Timer this afternoon for fun.
I’ve got a small USB charger plugged into a Belkin Wemo Outlet, which powers the Spark Core. Using ouimeaux give me command line access to the Wemo, I’ve written a bash script to curl the Cloud API and check to make sure a variable is regularly being updated. My script loops every 60 seconds; if the variable hasn’t changed the script immediately checks it two more times, waiting 10 seconds between checks. If the variable hasn’t changed at this point, we turn the Wemo Outlet off, wait 5 seconds and turn it back on. At this point, the script sleeps for 3 minutes and starts the process over again!
So, what other interesting things can we do with the Spark Core and Belkin Wemo? Well, the Wemo has the ability to automatically turn the outlet off and on based on user set times. We could use this to save energy by allowing the Core to set a “deep sleep” timer, which would command the Wemo to turn the outlet off for X minutes. In this case, the Wemo would power up the outlet (that the Core is plugged into), allowing the Core to perform whatever tasks are needed, at which point it would set int deepsleep with however minutes it wanted to be turned off, rinse, lather, repeat.
Once UDPClient is working, we could actually talk to the Wemo directly, without having to rely on an externally running script or program.
Once I get the code cleaned up a bit I’ll post the bash script and a picture or two.
Anyway, this was just a fun little exercise. Perhaps someone will find it useful.