Usha Saha

Aug 19, 20203 min

Controlling Raspberry Pi's GPIOs using the Telegram bot

Updated: Apr 4

This article Controlling Raspberry Pi's GPIOs using the Telegram bot is all about how one can control the Raspberry Pi's #GPIOs(General Purpose Input/Output's) with a telegram bot. Let's have some idea about what is a Telegram bot. The Telegram bot is basically a platform provided by telegram where the #telegram is controlled by software rather than manually. The bot can perform functions like search, remind, teach, broadcast, and many more. So let's get headed towards the article and the codes implemented.

Hardware used

The list of components used are shown below;

Raspberry Pi 3 Model B+

The Raspberry Pi is a series of small single-board computers. Here 3 Model B+ indicates the generation of the RPi board. The Raspberry Pi is also written as RPI or RPi or Raspberry Pie. The Raspberry Pi Model B+ is of the nearby size of a credit card.

Raspberry Pi 3 Model B+

Bread Board:- A breadboard is a rectangular board with small holes in it which are used for connecting elements. The connections are not fixed and can be varied. In a breadboard, all the holes in one horizontal line are in series connection with each other. Breadboards are made from plastic and come in all shapes, sizes, and even different colors, the most common sizes are "full-size," "half-size," and "mini" breadboards.

Bread Board

Jumper wires:- Jumper wires are used to establish a connection between different elements in the circuit and #Raspberrypi board. There are two types of wire, male and female. The male wires have the ends that can be connected to other ends and the female wires are the ones that have the receiving end.

Jumper Wires

USB Cable

This cable is used to connect the RaspberryPi to the power supply. It also helps in the transmission of data.

USB Cable

LED:- A Light Emitting Diode is a semiconductor device that emits light when current flows through it.

LED's

Circuit Connections

The circuit connections are very easy to understand. Here the GPIO pins are connected to the anode of the two LEDs. The #GPIO 17 and 27 pins are connected to the two anode pins of the green and red led respectively. The cathode terminal of the diodes is grounded on the breadboard along with the negative terminal of the Raspberrypi board.

Download the codes from here

Working

To start with download the telegram application form the play store, sign in making an account, and search for the #BotFather account. Under this click on start and this will initiate the process of creating the bot. On the left-hand side on can see the control commands from there choose the /newbot to create a new bot and furnish a few details like the name, username for the bot, and done with the bot creation process.

In this article, the working is based on fetching the keywords form the text that had been entered in the application. The next step is to open the newly created bot and start the session. With the program running in the background enter text like turn on/off any specific led and see the output on the led. Let us have a view on the implementation part.

For a better understanding lets understand with the help of images. The first image command to turn on the green led.

GREEN led on command

As a response to the command, the green led turns on.

GREEN led glowing

Similarly, the next command would be to turn on the red led.

RED led on command

Responding to the command the red led turns on.

RED led Glowing

Turn off all the led command.

All led off command

Both the LEDs are turned off.

All leds off

Turn on both the LED's command.

All on command

Both the LEDs are turned ON.

All leds on

In the same way, one can design for any other commands also like turn off one led. Turn off green led, or turn off red led and check for the outputs. If having any doubt go through the video configuration, the link is given below.

Check the project working video here - Controlling Raspberry Pi's GPIOs using the Telegram bot | Raspberry Pi Board | Learn Electronics

To sum up, through the article #Controlling Raspberry Pi's GPIOs using the Telegram bot one would learn how to connect the telegram bot in the mobile with the Raspberry Pi's along with how to command the Raspberry Pi's GPIOs and make actions more automated.


To learn more of such similar projects visit the links below

Interfacing servo motor with RPi

Interfacing Water/Rain Sensor with Arduino

Interfacing DHT11 sensor with Raspberry pi and LCD

    4082
    2