Lizard Habitat Monitoring
After the family goldfish passed, my kids talked me into buying a pet lizard. We settled on a Green Iguana named “Spike”. Spike was easy to care for, but did have some strict environmental needs for positive health such as a constantly high cage temperature, and a UV light lamp. Poor spike (RIP) got sick and passed away about 1 year after we adopted him – I fear it may have been due to a bit of neglect. We mended our broken hearts by accepting Molly (a Mali Uromastyx – aka “spiny tailed lizard”) into our family. I was determined to have her stay with us longer than Spike, so I decided to integrate some monitoring features into Watchdog for Molly.
The two main things I wanted to monitor in Molly’s habitat:
1. The temperature
2. Is she being fed daily
To do this, I decided to leverage my new skills with an Arduino. I stacked a Network shield on top and bought a nice molded case from Sparkfun to enclose the electronics. I attached an LM335 temperature sensor to the side of Molly’s cage by the heat lamp. I also attached a simple magnetic reed sensor to the cage lid. I already had an Ethernet port near Molly’s cage, so I just extended a wire from the outlet to the Arduino, and also gave it a 9V power supply from the UPS.
The logic of the module was quite simple. It just sits and waits for a connection on port 8888. Once connected, it sends information about the temperature and if the magnetic sensor has been tripped since the last time a connection was made. I was then able to integrate this into Watchdog. Every 5 mintues, I attempt to connect to the module over the house LAN. Watchdog then has the information it needs to take action, if necessary.
If the temperature level ever drops below 83 degrees, Watchdog makes an audio broadcast throughout the house: “Attention, the lizard habitat is too cold”.
Watchdog also checks if Molly has been fed daily. On weekdays, it checks 3 times between 8:10 and 8:20 (I also set it for later on the weekends so we can sleep in a bit) to see if the cage has been opened (you must open the cage to feed her). If it has not, Watchdog makes an audio broadcast throughout the house: “Attention, please feed Molly”. It checks again at 10:30 and if Molly still has not been fed, Watchdog gets a bit snippy: “Ok, seriously? Molly is starving! Stop what you’re doing and feed her now!”. It checks a third time at 10:45 and if she has still not been fed, it sends an SMS text message to my wife and I. Using this system, I’m happy to report that Molly has never gone without food. She’s been with us now for 2.5 years and still going strong.
Adding all this logic into Watchdog was starting to make it bloat a bit. So, I decided to create a new module called NetChecker. I use NetChecker to perform any kind of activity involving interfacing over the LAN via sockets, HTTP or other protocols. This helps off-load the workload from Watchdog and let’s me liberally add retry logic and other time-consuming features so it did not threaten to slow down Watchdog.