Daily Archives: February 21, 2015

Telegram, Raspberry Pi and Remote Control

People from an older generation may still recall the days the postman would land on the doorstep and deliver a slip of paper with some message in it. Those were the days of Telegrams associated with Morse Code, the dots and dashes way of communicating with far-off places. Mobiles and instant messaging services have now replaced that and other such slow modes of communication. As a result, you can always remain in instant contact with people across the globe.

Similar to the WhatsApp messenger service, Telegram is another application that allows you to chat and share documents with your contacts. Telegram surfaced when WhatsApp crashed about a year back. Being a cross-platform messenger app from Berlin, it gained above five million users within 24 hours and more, since Facebook purchased WhatsApp.

Although at first introduction Telegram and WhatsApp seem identical, there are interesting differences. Both require the telephone number of the recipient for sending them a message. In addition, chatting to individual contacts or to groups is possible. Both have a single and double track system for knowing if the recipient has received your message and has read it.

However, unlike WhatsApp, Telegram allows you to send your messages, videos and photos with a self-destruct timer. Once the set time ends, all your shared documents disappear within a ‘secret chat’. This has a huge advantage. Under secret chat, all documents, locations, videos and images remain encrypted end-to-end and only the sender and the recipient can read them; nobody else can read them, not even the staff at Telegram. The timer can be programmed to activate either after two seconds or up to a week.

Using Telegram on the RBPi is fun and you can use the versatile instant messaging service on the same phone number with different devices simultaneously. Apart from simply using the messaging service to exchange messages, it is also possible to make the RBPi take specific actions automatically, based on the message received by it. For example, if the text message sent is say, “photo”, the RBPi responds by taking a snap of the surroundings with its camera and sends the image to the sender. Similarly, if the message says “lamp”, RBPi can turn on a lamp or open a garage door if the message says “open”.

For using Telegram for remote control, it is best to use the RBPi model B or B+ and have the latest version of the Raspbian as the operating system. However, you can also use the pre-installed Raspbian on the 8GB Class 10 Micro SD card available here. Follow the configuration given in this tutorial as a starting point.

RBPi will be intercepting new incoming messages with Lua, a lightweight, fast, powerful and embeddable scripting language application. Lua uses extensible semantics and associative arrays by combining the simple procedural syntax to powerful data description constructs. That means Lua has the capability to understand text and interpret the action to be taken. In fact, Lua uses a lookup file “action.lua”, much as we use a dictionary, to correlate specific text messages received and the actions that RBPi will take. For details of programming, refer to this blog.