Raspberry remote control with Telegram

Telegram is a very versatile instant messaging software that can be used with the same phone number on different devices simultaneously.
In this tutorial we saw how to install it, and we tried to send text and media messages.
We have also seen that it is possible to set the Raspberry to send messages automatically.
In this tutorial we will ask Raspberry to take a specific action as a function of the received message, for example, we could send a text message with the word “photo” and Raspberry will sends us a photo of the apartment, or “lamp” to turn a lamp, or “open” to open the garage door.
Well, let's start

You need:

a Raspberry Pi B or B+, with the latest version of Raspbian, or our MIcroSD Card 8GB Class 10 Raspbian preinstalled.Raspberry remote control with Telegram

Step 1: Installation

Installation:

Installation:

Read this tutorial, we use this configuration as start point.

To intercept a new incoming message we create a file action.lua

“Lua is a powerful, fast, lightweight, embeddable scripting language.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.” From http://www.lua.org.

with this content

Save and exit, when incoming text message is “ping”, Telegram answers us with a text message containing “pong”.

move in tg

then type

Try to send a message, if all goes well, Telegram answers only on “ping” and not “PING”, we should see something like this

Ok, let's do something more interesting.

Install the Raspberry Camera, see this tutorial, then create a new folder where we will save the captured photos.

create a new file camera.sh

with this content

save and exit, give it execution permissions

Edit action.lua

add this lines in function on_msg_receiveRaspberry remote control with Telegram schematic

Step 2: Test

Test it

Now if you send a text message with “photo”, Raspberry answer with a photo

To enter additional commands simply change the file action.lua inserting a new if block , for example, we could activate a relay or ask the status of a sensor.

In the next tutorials will achieve some other example of use.

Follow us on social to stay informed.

www.emmeshop.eu

 

For more detail: Raspberry remote control with Telegram


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top