Getting the Raspbery pi connected to Wifi and Messenger

The Telegramic Alarm Kit is designed to allow enthusiasts to create, use and improve easy to build alarm system with communication over a Telegram messenger with no additional software installed on your smartphone or computer. Such a system can act as a part of Smart Home solution.

Kit content:

  1. Raspberry Pi
  2. SD Card with Rasbpian OS and relevant software
  3. Raspberry Pi Camera Module
  4. PIR Motion sensor
  5. Temperature DS18B20 "1-wire" Sensor & 3 resistors (just 1 required)
  6. Connection wires
  7. Breadboard

What you'll need on top of that:

  1. Wired or wireless Internet access
  2. Computer or smart phone
  3. Own Telegram account installed (if not – mobile phone number)
  4. Two Mobile phone numbers, one for Raspberry Pi Telegram account and one for yours.
  5. Headset to hear error/success messages
  6. Micro USB Cable and 5V 1.5A power supply (separate PSU or high power USB port on your computer)

Desirable, but not necessary (you'll need this for troubleshooting):

  1. Very short HDMI cable
  2. HDMI Display
  3. USB Keyboard


The kit is based on a small, but very powerful computer – Raspberry Pi (RPi). It runs under Linux based operating system – Raspbian, which derives from Debian distributive, and therefore has variety of tools and software.

Out of the box Raspbian supports many types of equipment. Raspberry Pi itself has several GPIO ports, so all this along with reasonable price makes it convenient platform to build Smart home solutions – for fun as well as for home and business applications.

Network & Telegram setup

Ensure that you have connected either WiFi dongle to USB socket:

or connect it with wire to you Ethernet LAN. LAN and WiFi should provide Internet access for connected devices.

There are 2 ways how to setup network access for Raspberry Pi.

First – Quick and easy setup using QR Code

Follow the next section of the manual – connect Camera Module and go with setup using QR Code.

Headless Raspberry Pi Network Setup

Requirements: Needs Raspberry & Camera + headset, no need of monitor or keyboard

Note: this method will work only with Hobbyist SD Card

Initially, RPi is configured with Ethernet set to DHCP mode, so if you have wired connection with DHCP server on the network – just plug Ethernet connector and skip to Telegram account setup.

Raspberry PI is a headless computer: no keyboard, no monitor.

However, the kit allows you to setup and run RPi without keyboard and Linux skills. Check the Raspi Camera Module: it should have the red light on when RPi had started. Now camera is looking for QR code with settings.

Plug your headset to RPi and listen at all the times what's happening. Having no display, that is your only feedback from the hardware

You should use QR code generator, e.g. using the specific text (just copy and paste from below to , then insert actual data).

Depending on size and resolution of your screen, you should keep camera 15 to 50 cm from the QR Code.

Plug headset and listen carefully. RPi will tell you:

  • When QR code is read
  • If data encoded is good or bad
  • All stages of network setup
  • When system is about to reboote
  • Started of Telegram registration
  • Failures (just start the process over)

Configuration strings

If you use wired connection with DHCP:

{"net": {"eth0":{"ip":"dhcp"}, "reboot":"yes"}

This is default configuration, so if you have DHCP and wired connection – just skip to Telegram setup.

Ethernet without DHCP:

{"net":{"eth0":{"ip":"IP_ADDRESS_TO_ASSIGN", "netmask":"YOUR_NETMASK","gateway":"YOUR_GATEWAY", "reboot":"yes"}

If you use WiFi connection with DHCP, go with the following:

{"net":{"wlan0":{"ssid":"YOUR_NETWORK_NAME","key":"NETWORK_KEY", "ip":"dhcp"}, "reboot":"yes"}

If you don't have DHCP on your network or want to use static IP address, use the following text with your LAN IP address and relevant data:

Replace bold text with your data

Place this configuration text into and point RPi's Camera Module to the generated QR code.

Once camera recognises QR-code, you'll hear voice message, and if data is correct, configuration will be updated and RPi rebooted. Omit "reboot":"yes" if you don't want to reboot the device (saves time, but might not work in some cases).

You can monitor where RPi went online with

ping -t <ip_address>

If you use DHCP and you want to know your IP address, proceed with Telegram account setup and send to it a simple command:


This will send you RPi's current IP address

For advanced networking configuration please consult Raspbian manual.

Register Telegram Account

Ensure, that you have your network connection up, and Raspberry Pi has internet access.

Now let's do the trick with QR code and camera to register Telegram account.

IMPORTANT. Before proceeding with registration of RPi's Telegram account, register your personal Telegram account on a smart phone and add RPi's phone number to the phone book on that smart phone. You can manually add this contact later, but without having this account in your contact list you cannot receive messages from RPi.

First step – create the account. You'll need a mobile phone number, which can receive SMS, first and last "names" of your Raspberry PI.

First, fill the following JSON with your real phone number, e.g.


Use this text to generate QR code and show it to the camera. Listen to your headset to know when code is read.

If you have Internet connection, within 2 minutes (usually) SMS with a code will come to the number you've provided. Be patient, sometimes it takes up to 10 minutes! Paste the code in the following JSON and give your personal Telegram account phone number.


Use this text to generate QR code and show it to the camera.

Once Telegram account is activated, you will receive a notification on you personal Telegram. If you don't, then add your RPI's phone number to your address book and add it manually using Telegram interface.

Send any command to it:

ip – to get you ip address (useful if you use DHCP)

alarm - for help

After, please reboot RPi with Telegram command:


If something goes wrong, who can always reset your Telegram settings with:


and then start over.

Second way requires basic knowledge of Linux command line, supposing you have USB keyboard, HDMI display and very short HDMI cable (<0,7 m) as well as basic Linux administration skills.

Connect display and keyboard, power Raspberry Pi on (plug micro USB connector in), wait until RPi boots and log on with user "pi" and password "pi".

Edit the file /etc/network/interfaces with command:

sudo nano /etc/network/interfaces

After you edit it, it should look like:

auto lo

iface lo inet loopback

auto wlan0

allow-hotplug wlan0

iface wlan0 inet dhcp



auto eth0

allow-hotplug eth0

iface eth0 inet dhcp

If you wish to use static IP address, replace relevant interface (eth0, wlan0) record with:

auto eth0

allow-hotplug eth0

iface eth0 inet static




To reload network configuration type:

sudo ifdown wlan0

sudo ifup wlan0

sudo ifdown eth0

sudo ifup wlan0

or reboot. Network should be up. You can test it with ping command:


Telegram Setup

You should be root to perform all further operations. Run:

sudo su -

Supposing you have installed Telegram on your smart phone, please make sure you have your another phone number in you phone book.

Launch telegram:


and follow instructions as they appear: first you'll need to enter your phone number (dedicated to this system!), then enter you Name and Last which this Telegram account will use (normally Raspberry Alarm), and a code from SMS.

Once registration procedure is complete, create file /home/pi/setup/stopit with a command:

echo yes > /home/pi/setup/stopit

This file prevents from starting QR-based setup process. Remove it if you want to proceed with QR-base setup, and reboot. Alternatively, you can send Telegram commands reset and then reboot to clean up configuration.

reboot you RPi to allow automatic scripts to start properly your smart phone will notify you, that Raspberry Pi has joined Telegram. Now you can send Telegram messages to your RPi, and some of them will be interpreted as commands:




When you've sent first command and got a response, you may use the Telegram Alarm system. Rebooting the RPi is highly recommended at this stage (Telegram command reboot).

Next: Assembling and Wiring

Zircon - This is a contributing Drupal Theme