Intro: Photos to Telegram on Burglary Using Raspberry Pi, PIR and Web Camera
In this Tutorial will see how to send photos to Telegram on Human Detection. In short PIR on Raspberry pi will Detect Motion , photo is taken using web camera and sent to Telegram. The process is kept in Init.d folder so starts as soon as raspberry pi boots up.
Step 1: You Need
Raspberry pi with latest Raspbian
PIR (motion) sensor
Step 2: Installation
Telegram should be configured on pi, Steps to install telegram and these should work ideally if any difficulties can comment below.
Update the pi with two steps
1) update the list of available packages and their versions
2)install newer versions of the packages you have
this may take long time depending on your Internet speed
sudo apt-get update
sudo apt-get upgrade
Install libs: readline or libedit, openssl and (if you want to use config) libconfig and liblua. If you do not want to use them pass options --disable-libconfig and --disable-liblua respectively.
sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev libevent-dev make
sudo apt-get install libjansson*
Clone GitHub Repository
git clone --recursive <a href="https://github.com/vysheng/tg.git" rel="nofollow"> https://github.com/vysheng/tg.git </a> && cd tg
comment out lines 101 and 115 in /home/pi/tg/tgl/mtproto-utils.c then compile the code
Running this command takes a little time and after install is done.
Navigate to the folder tg
bin/telegram-cli -k tg-server.pub -W
The first time we start telegram we must enter the phone number, including land code (for Italy is +39). You should receive on your phone a sms message with a code, enter it and hit "Enter" Now we are ready to use telegram, if you send a message from your smartphone you can see it on terminal. To send a message type
msg Name_Lastname My message from Raspberry
send_photo Name_Lastname /folder/photo.jpg
Step 5: Writing Scripting
Here it goes when pir is triggered, camera should take image and send to telegram.
PIR (motion) Sensor
motion gives high pulse when it is triggered, so we active the camera when we get raising edge (0 to 1).
image is taken and stored in a folder /home/pi/ with name image.img
send image to telegram
now send the /home/pi/image.img to telegram
git clone https://github.com/Murali0923/Telegram-camera-pir.git
open the file pirCameraTelegram.py
and edit line 41, by replacing user_Number with your contact
Step 6: Backup
Its good thing to backup your OS frequently, so that no need to do rework all the time. Here is the command to back up your OS into a zip file.
sudo dd bs=4M if=/dev/sdb | gzip > raspbianTelegramPIR.img.gz
Step 7: Demo
The demo of this project at below link
Step 8: Reference
The best refernce i got is