神刀安全网

My door sends me chat messages – Raspberry Pi powered door sensor and Rocket.Chat bot with …

My door sends me chat messages - Raspberry Pi powered door sensor and Rocket.Chat bot with ... 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:

My door sends me chat messages - Raspberry Pi powered door sensor and Rocket.Chat bot with ...

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: My door sends me chat messages - Raspberry Pi powered door sensor and Rocket.Chat bot with ...

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 My door sends me chat messages - Raspberry Pi powered door sensor and Rocket.Chat bot with ...

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: My door sends me chat messages - Raspberry Pi powered door sensor and Rocket.Chat bot with ...

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

My door sends me chat messages - Raspberry Pi powered door sensor and Rocket.Chat bot with ...

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

My door sends me chat messages - Raspberry Pi powered door sensor and Rocket.Chat bot with ...

Things to consider

  • You can enable notifications on that bot channel so you get notified when your door is opened
  • Don’t let your bot post on public channels or you might just make the front page on PleaseRobMe
  • Make a private channel
  • If you host your own rocket.chat instance, use HTTPS. It’s free with let’sencrypt

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » My door sends me chat messages – Raspberry Pi powered door sensor and Rocket.Chat bot with …

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址