Telegram Controlled Drone

by crisdeodates in Circuits > Arduino

2005 Views, 15 Favorites, 0 Comments

Telegram Controlled Drone

_kddbc7G4kO.jpeg

Introduction

The term “drone” usually refers to any unpiloted aircraft. Sometimes referred to as “Unmanned Aerial Vehicles" (UAVs), these crafts can carry out an impressive range of tasks, ranging from military operations to package delivery. Drones can be as large as an aircraft or as small as the palm of your hand. Originally developed for the military and aerospace industries, drones have found their way into the mainstream because of the enhanced levels of safety and efficiency they bring. These robotic UAVs operate without a pilot on board and with different levels of autonomy. A drone’s autonomy level can range from remotely piloted (a human controls its movements) to advanced autonomy, which means that it relies on a system of sensors and detectors to calculate its movement. Because drones can be controlled remotely and can be flown at varying distances and heights, they make the perfect candidates for taking on some of the toughest jobs in the world. They can be found assisting in a search for survivors after a hurricane, giving law enforcement and the military an eye-in-the-sky during terrorist situations, and advancing scientific research in some of the most extreme climates on the planet. Drones have even made their way into our homes and serve as entertainment for hobbyists and a vital tool for photographers.

Drones are used for various purposes:

  • Military
  • Delivery
  • Emergency Rescue
  • Outer Space
  • Wildlife and Historical Conservation
  • Medicine
  • Photography etc.

Here we introduce a novel method of controlling drones via Telegram. Using this feature, a user will be able to control a drone from virtually anywhere in the world with the help of an internet connection and Telegram application.

Supplies

1. DJI Tello Drone

2. M5Stack FIRE module

3. Arduino IDE

Motivation

The main motivation behind this project is my curiosity to explore the various control schemes for small-scale drones. The paper "Design and Development of Voice Control System for Micro Unmanned Aerial Vehicles" talks about various drone control methodologies such as Radio, GCS, Gesture, Voice, Joystick, PC, FPV, and Autonomous. It is observed that situational awareness is at a medium level for Radio and Gesture UAV control methods, whereas situational awareness is high for the voice control method. In this project, we will work on Telegram-based controlling, and later we will go up to voice control and also other advanced controls. The motivation for this project also raised from the need to implement these different control methods in a low-cost portable and scalable embedded platform with computation at the edge, without relying on external resources for its working.

Preparation - Drone

image_nv4Xax2pYw.jpeg

The DJI Tello is a small-sized drone that combines powerful technology from DJI and Intel Into a very tiny package. It is a lightweight, fun, and easy-to-use drone that is the perfect tool for learning the ropes of drone piloting before investing in a more expensive option. Tello boasts a 14-core processor from Intel that includes an onboard Movidius Myriad 2 VPU (Video Processing Unit) for advanced imaging and vision processing. It is equipped with a high-quality image processor, for shooting photos and videos. The camera features 5MP (2592x1936) photos and HD720 videos. The drone has a maximum flight time of 13 minutes. This incredibly small drone fits in your palm and only weighs approximately 80g (propellers and battery included). You can control Tello directly via the Tello app or with a supported Bluetooth remote controller connected to the Tello app. The drone is programmable via Python, C++, Scratch, and DroneBlocks.

Preparing Tello Drone for the project

The Tello drone SDK provides ample information on how to program the drone to achieve the tasks via Tello commands, but are somewhat limited in the features. The Tello SDK connects to the aircraft through a Wi-Fi UDP port, allowing users to control the aircraft with text commands. We use Wi-Fi to establish a connection between the Tello and the M5Stack module. Once powered on Tello acts as Soft AP Wi-Fi (192.168.10.1) to accept commands via port 8889.


The Tello SDK includes three basic command types.

  • Control Commands (xxx)

Returns “ok” if the command was successful.

Returns “error” or an informational result code if the command failed.

  • Set Command (xxx a) to set new sub-parameter values

Returns “ok” if the command was successful.

Returns “error” or an informational result code if the command failed.

  • Read Commands (xxx?)

Returns the current value of the sub-parameters.

Even though Tello is pretty maneuverable, with a number of different axes on which we can control the drone, in this project, we will use the following commands.

takeoff : Auto takeoff.
land : Auto landing.up x : Ascend to “x” cm.
down x : Descend to “x” cm.
left x : Fly left for “x” cm.
right x : Fly right for “x” cm.
forward x : Fly forward for “x” cm.
back x : Fly backward for “x” cm.

Please refer to the SDK for a full set of commands. As a safety feature, if there is no command for 15 seconds, the Tello will land automatically. Tello API As we are using Arduino as the platform, we need an API that can translate our commands to UDP packets to be sent using the Arduino program. TelloArduino is an Arduino library for controlling DJI Tello through ESP32 Module. This library controls the Tello by sending commands via UDP as mentioned in the SDK documentation.

To download, go to https://github.com/akshayvernekar/telloArduino.git... and click the "DOWNLOAD ZIP" button.

Place the "tello" folder in your Arduino sketch folder/libraries/ folder.

Now Restart the IDE.the "tello" folder in your Arduino sketch folder/libraries/ folder. Now Restart the IDE.

In your Arduino IDE, go to Sketch > Include Library > choose "tello" to include this library in your sketch.

Preparation - M5Stack Module

image_Mc0Q5lFK7M.jpeg
image_qW8lyx3bKY.jpeg
image_MkRY0pkjpi.jpeg
image_LXznbyZFUe.jpeg
image_W652N4juA6.jpeg
image_MMdNfWyOyr.jpeg
image_gl9FuuTEKF.jpeg
image_vDmZb110V7.jpeg
image_A1GiJBVGGX.jpeg
image_Bog1w5uBWb.jpeg
image_yQcYy3UH9l.jpeg
image_a0HWOYBPW2.jpeg

M5Stack FIRE is one of the M5Stack developing kits, providing a 9-Axis IMU sensor(6-Axis posture acceleration measurement + 3-Axis magnetic measurement), 16M Flash + 4M PSRAM, enhanced Base, larger battery, etc. With an IMU posture sensor, there are a lot of situations to which you can apply this kit, like detecting acceleration, angulation, and trajectory. You can make relative products like sports data collectors, 3D remote gesture controllers, etc. It is a modular, stackable, scalable, and portable device is powered with an ESP-32 core, which makes it open-source, low cost, full-function, and easy for developers to handle new product development on all stages include circuit design, PCB design, software, mold design, and production.

M5Stack Fire comes with three separable parts. The top part has the processors, chips, sockets, 2.4G antenna, ESP32, power management IC, an LCD screen, and some other interface components.

The middle part is called the M5GO base which provides a lithium battery, M-BUS socket, LED bar, and three more GROVE Ports. The bottom part is a charge table, which can be connected to the M5GO base via POGO pins.

M5Stack development boards are highly efficient, covered with industrial-grade case and ESP32-based development board. It integrates with Wi-Fi & Bluetooth modules and contains a dual-core and 16MB of SPI Flash. Together with 30+ M5Stack stackable modules, 40+ extendable units, and different levels of program language, you can create and verify your IoT product in a very short time.
It supports programming in Arduino, Blockly language with UIFlow, Micropython.

Preparing M5StackFIRE for the project

  • Download Arduino IDE
  • Open up your browser, and visit Arduino's official website.
  • Download and install the version according to your operating system.
  • Install ESP32 Boards Manager Open up the Arduino IDE, and navigate to File -> Preferences -> Settings
  • Add the following ESP32 Boards Manager URL to Additional Boards Manager: https://dl.espressif.com/dl/package_esp32_index.j...
  • Hit OKNavigate to Tools -> Board: -> Boards Manager
  • Search ESP32 in the Boards Manager window, and click Install
  • Install M5Stack Library Open Arduino IDE, then Select Sketch->Include Library->Manage Libraries
  • Search M5Stack and install it
  • For Windows machines, an additional USB to serial Driver needs to be installed. Arduino port Configuration Choose the correct board, baud rate, and serial port.
  • Once set up, you can try an example sketch or our code from the Code section below to verify if everything is working.
  • Click Upload, to flash the code to the device
  • Once successfully flashed, the M5Stack module will show the corresponding output on its display as well as Arduino Serial Monitor

Preparation - Telegram

image_mg8yJUR8Ww.jpeg

Telegram is a freeware, cross-platform, cloud-based instant messaging (IM) software. Telegram accounts are tied to telephone numbers and are verified by SMS. Users can add multiple devices to their accounts and receive messages on all of them. Connected devices can be removed individually or all at once. The associated number can be changed at any time and when doing so, the user's contacts will receive the new number automatically. In addition, a user can set up a username as an alias that allows them to send and receive messages without exposing their phone number.

For our drone control, we will be using a custom Telegram Bot.

Bots are simply Telegram accounts operated by software – not people – and they'll often have AI features. They can do anything – teach, play, search, broadcast, remind, connect, integrate with other services, or even pass commands to the Internet of Things. They can respond to messages or mentions, can be invited into groups, and can be integrated into other programs. There are also inline bots, which can be used from any chat screen. In order to activate an inline bot, the user needs to type in the message field a bot's username and query. People can use Internet Of Things (IoT) services with two-ways interaction for IFTTT implemented within Telegram.

Preparing Telegram for the project

It is easy to set up Telegram Bots. There are a lot of tutorials available. https://core.telegram.org/bots - BotFather

https://core.telegram.org/bots - General API We used BotFather and the Telegram API to develop our custom Telegram bot named @DroneTellobot.

Our custom bot is developed in such a way that it can be accessed directly using its unique name @DroneTellobot or by adding the bot into a group. If added to a group, all the members of the group can simultaneously use the bot to control the drone. This is very useful in a case for eg. testing the drone as a team.

At the time of this writing, the following commands are programmed into the custom telegram bot.

/takeoff - drone takeoff
/land - drone land
/forward - drone forward
/back - drone back
/up - drone up
/down - drone down
/left - drone left/
right - drone right
/battery - drone battery
/shutdown- close comm
/status - bot info

There is the possibility to add more commands which are available with the help of DJI Tello SDK, which will be incorporated soon.

Integration

telegram_drone_RuTelHpfuj.jpeg

A middleware is required to interact between the telegram API and the drone. If the M5Stack module is connected to the drone via WiFi, it won't be able to access the Telegram API calls due to the absence of internet connectivity. To overcome this we use a laptop as middleware for accessing the telegram API calls and sending the commands to the M5Stack module via a serial connection.

Code: Github Link

Testing

Telegram Controlled Drone
image_JpWV5hxM8D.jpeg

Let's see the telegram @DroneTellobot in action.

Conclusion

The Tello drone was able to receive the commands issued via our custom-made Telegram Bot @DroneTellobot. Despite the shortcomings to add a middleware communication for accessing Telegram data, the implementation is application rich.

If any of the readers want to try the Telegram Tello drone control LIVE using our custom-developed @DroneTellobot, please reach out to us in DM.

​What Next !!

  • Make the middleware redundant.
  • Add more options to the @DroneTellobot.

References

https://arc.aiaa.org/doi/10.2514/6.2018-4231

https://dl-cdn.ryzerobotics.com/downloads/Tello/Tello%20SDK%202.0%20User%20Guide.pdf

https://store.dji.com/product/tello

https://github.com/akshayvernekar/telloArduino

https://docs.m5stack.com/en/quick_start/m5core/m5stack_core_get_started_Arduino_Windows

https://www.arduino.cc/reference/en/libraries/m5stack/

https://shop.m5stack.com/products/fire-iot-development-kit?variant=16804798169178

https://docs.m5stack.com/

https://core.telegram.org/bots

https://core.telegram.org/bots/api