Secondary Menu

Photos to Telegram on Burglary Using Raspberry Pi, PIR and Web Camera

Introduction: 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

webcamera

PIR (motion) sensor

wire strippers

Multimeter

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.

comment out lines 101 and 115 in /home/pi/tg/tgl/mtproto-utils.c then compile the code

sudo ./configuremake

make

Running this command takes a little time and after install is done.

Navigate to the folder tg

cd tg

then

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 3:

Step 4:

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).

Camera

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

cd /home/pi<br>

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.