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


PIR (motion) sensor

wire strippers


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="" rel="nofollow"> </a> && cd tg

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

sudo ./configuremake

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

Navigate to the folder tg

cd tg


 bin/telegram-cli -k -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).


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

open the file

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

clink here

Step 8: Reference

Be the First to Share


    • Pocket-Sized Speed Challenge

      Pocket-Sized Speed Challenge
    • Audio Challenge 2020

      Audio Challenge 2020
    • Maps Challenge

      Maps Challenge

    5 Discussions


    2 years ago

    how to change webcam to pi camera ? thanks


    3 years ago

    Can you put the hardware installation instruction please?

    Thanks a lot


    3 years ago

    I'm sorry but where's step 3&4?


    3 years ago

    Thank you, very interesting project !