|Software apps and online services:|
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.
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.
Here is a video that show me moving the magnet away to simulate the door opening.
Proxy script called by monitSH
#!/bin/bash . /home/chip/gpio/gpio.sh gpio_disable 7 gpio_enable 7 gpio_mode 7 in retval=$(gpio_read 7) echo $retval exit $retval
Monit check-program configPlain text
check program freezer_door with path /home/chip/gpio/check_freezer_door.sh if status != 0 for 10 cycles then #alert exec "/usr/bin/aplay /media/chime.wav"
Shell function library for gpio by Jeff Larkin
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!