The result Github repo: Link

What does it do?

Senses when your door was opened

Sends a chat message in a rocket chat channel of your coice (own servers supported)

Tells you how long the door was opened

Tells you how much time has passed since the door was last closed so you know how long you were out or in

Requirements

Raspberry Pi

Reed Switch

1x 10k ohm resistor

Channel ID of the channel your bot is going to post the message

Build it yourself - It's pretty easy

Step 1: Connect the Reed switch to the Raspberry Pi

Connect the reed switch acording to these schematics:

diagram

The reed switch is activated by a magnet. You can glue the magnet to the door and put the sensor on the frame like this: reed switch on the door

The reed switch only lets through the current when the magnet is close. If the door opens, the script will detect that and send a chat message reed switch on the open door

You don't need a bread board or something like that, you can just solder the resistor to the reed switch directly and connect it to the Pi. The resistor is under the black shrink tube: reed switch on the open door

Step 2: Install php and the "gpio" command

apt-get install wiringpi php5-cli echo 'w1-gpio' >> /etc/modules modprobe w1-gpio

Step 3: Get the script

wget https://raw.githubusercontent.com/chrisiaut/raspberry_doorbot/master/door_chatbot.php

Step 4:

Edit the settings in the door_chatbot.php file and add your channel, server and login credentials

settings in door_chatbot.php

Final step: Run script on startup

crontab -e

insert this at the end of the crontab

@reboot php /path/to/your/door_chatbot.php >> /var/log/doorbot.log

And then start once (or reboot)

nohup php /path/to/your/door_chatbot.php >> /var/log/doorbot.log &

Should be working now

Bot in action

Things to consider