Background
Ever left your freezer door open, only to find you spoiled your entire stock of frozen strawberries? This project aims to prevent that.
I decided to do this when the CHIP appeared on Kickstarter, it was cheap enough and requires very little power. I was thinking of doing it with a Raspberry Pi, but didn´t have any extra ones laying around.
The main idea of this project is to utilize existing off the shelf components, both in hardware and software.
As I have been using Linux monitoring software like Nagios and Monit, I decided to go with Monit as it is simple to install, setup and use. More information about Monit can be found here:
As for reading GPIO and Playing a sound file, I used the CHIP documentation from:
There are sections for GPIO and also for playing a wav or mp3-file in there.
How-to
Basically I connected a normally open switch (magnet sensor) that opens the circuit when the magnet is moved away and closes the circuit when the magnet is close to the sensor. The sensor is connected between the GND pin and one of the GPIO pins.
Then I made a bash script that reports the state of that GPIO pin using exit codes, because monits "Check program" understands exit codes.
Lastly I configured Monit to run my script and check the exit code, if it "fails" (which means the exit code was something other than zero) ten times in a row, then I execute the command to play a sound.
Using monit gives you the added bonus of automatic e-mail notifications.
You could also change the alert function to also send an sms using any sms-gateway that supports a http(s)-request.
Demo
Here is a video that show me moving the magnet away to simulate the door opening.
Comments