Posts

Showing posts from March, 2019

Bash Garage Door Monitor on Raspberry Pi

This post describes the bash script that I use to enable my Raspberry Pi to Email updates on the state (open/closed) of each of my garage doors. This is a nice use of the bash 'trap' statement used to handle events, such as the garage door opening or closing. Note that 'trap' is a bash shell function, not a linux command. Although it may be fun to type in 'man trap' - you'll not get any help. Use 'man bash' to get help on the trap function. Firstly, we have the statement at the top of the file that says to use /bin/bash. If you miss this out, things tend to work OK while developing the script, but you'll run into issues once you try and automate things, as you could end up with running /bin/sh rather than bash, causing errors. #!/bin/bash Next we define the pin names. This is just the name for each garage door, or more specifically who uses the door and which GPIO pin is connected to the door. (I use a  Magnetic Reed Switch  for each GPIO