My door sends me chat messages

Raspberry Pi powered door sensor and Rocket.Chat bot with some neat info

The result
Github repo: Link

What does it do?


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:


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


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

Tags: raspberry pi diy bot chat

Comment using SSH! Info


Get new posts by email
(~ one email every couple of months & no spam)