Get notified any time your door is opened or closed: connect a reed switch to your door, wire the leads into the Raspberry Pi's' GPIO pins to complete the circuit, and get email alerts.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
schematic
.gitignore
DoorChecker.py
README.md
settings.py

README.md

OpenSesamePi

About

Get notified any time your door is opened and closed.

Connect a reed switch to your door, wire the leads into the Raspberry Pi's' GPIO pins to complete the circuit, and get email alerts.

Installation

Physical

  1. Create a circuit connecting the reed switch leads to the Pi's GPIO pins

In addition to the switch itself, you will need a single 330 ohm resistor, as shown here:

![Circuit schematic](schematic/RPi Reed Switch.png?raw=true "Circuit schematic")

Be sure to look at the [interactive schematic](schematic/RPi Reed Switch.fzz) using the Fritzing desktop application.

Breadboard test

Test on a breadboard before soldering things together.

  1. Install the reed switch on the door (make sure the door opens cleanly with the switch in place)

Reed switch on door

  1. Final assembly, with resistor connected and plugged in to the GPIO pins on the Pi:

Final assembly

In addition to running OpenSesamePi, this particular Pi is doing double duty as a PiScan implementation.

Software

  1. Login to the Pi and install this Software:
git clone git@github.com:Banrai/OpenSesamePi.git
  1. Configure the Pi to send email:
sudo apt-get update
sudo apt-get -y install ssmtp mailutils

Then edit the SSMTP configuration file:

sudo vi /etc/ssmtp/ssmtp.conf

You need these lines defined at a minimum, replacing the gmail coordinates with your own (you can of course use any other SMTP mailserver of your choice):

root=postmaster
mailhub=smtp.gmail.com:587
hostname=raspberrypi
AuthUser=YourGMailUserName@gmail.com
AuthPass=YourGMailPassword
UseSTARTTLS=YES

Note: if you do use gmail, you will also need to update the Allow less secure apps setting for this method to work.

  1. Define the list of email addresses that should get the opened/closed alerts

Create a new file called local_settings.py in the same folder where you cloned this repo (by default, it will be the /home/pi/OpenSesamePi/ folder), add a line like this, and save the file:

NOTIFY_LIST = ['me@myemail.com', 'myroommate@theiremail.com']

Each of the email addresses defined here will get an email alert when the DoorChecker script is triggered.

This file overrides the NOTIFY_LIST defined in the generic settings.py file.

  1. Have the DoorChecker script start automatically, every time the Pi does:
sudo crontab -e

Then add this line at the bottom, and save the file:

@reboot python /home/pi/OpenSesamePi/DoorChecker.py &

Extensibility

At the moment, the DoorChecker script's notification action is to send email, but that can be extended to triggering an alarm, taking a camera snapshot, etc.

Just change the implementation of the notify(door_state) function to something more elaborate.

Acknowledgements