Get notified any time your door is opened and closed.
- 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.
Test on a breadboard before soldering things together.
- Install the reed switch on the door (make sure the door opens cleanly with the switch in place)
- Final assembly, with resistor connected and plugged in to the GPIO pins on the Pi:
- Login to the Pi and install this Software:
git clone firstname.lastname@example.org:Banrai/OpenSesamePi.git
- 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.
- 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 = ['email@example.com', 'firstname.lastname@example.org']
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.
- 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 &
Just change the implementation of the notify(door_state) function to something more elaborate.