Patrik Norrgård
Published © GPL3+

Open Door Alarm with GPIO and Monit

Ever left your freezer door open, only to find you spoiled your entire stock of frozen strawberries? This project aims to prevent that.

EasyFull instructions provided2 hours3,361
Open Door Alarm with GPIO and Monit

Things used in this project

Hardware components

Any kind of Reed sensor / Magnetic switch
Any normally open sensor or switch will work.
Speaker with 3.5mm earphone plug

Software apps and online services

monit (Tildeslash Ltd)
I use monit to poll the gpio via a bash script. Monit can be installed via apt-get: "sudo apt-get install monit"


Read more


Proxy script called by monit

Wrote this script to call Jeff Larkin´s shell function from monit.

First it registers the shell functions and later I call them to enable input for pin 8, and read it´s state. Then I exit with success if the door is closed or with an error (1) if it is closed.

. /home/chip/gpio/

gpio_disable 7
gpio_enable 7
gpio_mode 7 in
retval=$(gpio_read 7)
echo $retval
exit $retval

Monit check-program config

Plain text
I wrote this config to make monit execute the shell script that reads the sensor state. I included put this file in /etc/monit/conf.d so it as automatically included.

This check calls the shell script to determine the status of the door. If it is "open" 10 times in a row, then we play a wav-file through the speaker. Note that I have set the monitoring interval of monit to be once every second. So this config gives me 10 seconds to close the freezer door.
check program freezer_door with path /home/chip/gpio/
       if status != 0 for 10 cycles then
exec "/usr/bin/aplay /media/chime.wav"

Shell function library for gpio by Jeff Larkin

Found this on github after making my own, but ended up using Jeff´s as it more clean and nice


Patrik Norrgård

Patrik Norrgård

1 project • 1 follower
Coder/Maker with too little time on my hands.


Add projectSign up / Login