Programming the DJI Ryze Tello drone with Python
Fleet Flyer
Drones are more fun if you can program the unmanned aerial vehicle yourself. The DJI Ryze Tello and Python make this possible.
In this article, I work with the DJI Ryze Tello drone, which is available on Amazon [1] and from other vendors for around $99 (£99/EUR100). Why this model? The drone was designed for educational use and has open interfaces for that purpose. In other words, you can develop programs for the drone in Scratch or Python.
To familiarize yourself with the drone's capabilities, you first need to download the app that gives you manual control of the drone. The drone's battery lasts about 13 minutes, and the control range is about 100 meters. Because it is intended for operation inside buildings, this range is fine. If you get lost, the built-in 720p camera with electronic image stabilizer lets you view your current location.
For more intensive use, a Tello with the indispensable boost combo add-on adds $49 (£39/EUR45) to the price. Among other things, you get two extra batteries and a propeller protection set. During your first programming attempts, the propeller guards will definitely help prevent serious damage (Figure 1). Further information about the DJI Ryze Tello can be found on the manufacturer's website [2]; the essential technical data is shown in Table 1.
Table 1
DJI Ryze Tello Overview
Feature | Spec |
---|---|
Dimensions |
98.0x92.5x41.0mm |
Weight |
80g, including propeller and battery |
Battery |
1.1Ah/3.8V (removable) |
Connector |
Micro-USB port for charging |
Other |
Rangefinder, barometer, LED, vision system, WiFi 802.11n, 720p live streaming |
Performance |
|
Max. flight range |
100m |
Max. flight altitude |
30m |
Max. speed |
8m/s (18mph) |
Max. flight time |
13 min |
Camera |
|
Field of view (FOV) |
82.6 degrees |
Photography |
5Mpx (JPG, 2592x1936px) |
Video |
HD720p30 (MP4) |
Software Installation
To download the app for the drone, search for Tello in the Google or Apple app store. The app also lets you update the drone's firmware. Instructions on how to do this can be found in the "Updating the Firmware" box.
Updating the Firmware
You never know exactly how long the drone has been sitting around in a warehouse, so before doing anything else, it's a good idea to update the device's firmware from the app on your smartphone. To begin, connect to the drone and then switch to the app's settings with the gear icon. When you get there, tap More, then the three dots (Figure 2), and Update in the Firmware Version line. You will then see the release notes and can start the update process by tapping Update.
To connect to the drone in the app, first turn on the drone and wait until the LED flashes, which indicates it is starting a separate WiFi network to which you need to connect. Now launch the Tello app and connect to the drone. The app tells you the steps required. If everything worked, you will see the camera image in the app. The drone can now be launched with the lift-off icon at top left.
You can control four degrees of freedom in the app: forward and backward, left and right, up and down, and rotation about the z axis in both directions. You will encounter these four degrees of freedom again when creating programs. To make sure everything is working properly, go on a small test flight before you try controlling the drone with Python.
Before you start programming, you might want to install a suitable integrated development environment (IDE). PyCharm Community by JetBrains is a good choice for this project. You will find versions for different operating systems on the project website [3]. The installation completes the preparations, and you can now proceed to write your first program for the drone.
Connection Test
To create a program with PyCharm, select File | New Project. Leave all the default settings as is except for Location: Enter a meaningful project name in this field as the last component of the path. After pressing Create, the IDE directly creates a main.py
file, where you will save your own program after deleting the sample code in the file.
To use your scripts, you need to include a drone control library [4] in your projects by selecting File | Settings | Project:<name> | Python Interpreter and pressing the plus icon to install the djitellopy library (Figure 3).
The program in Listing 1 connects to the drone and displays the temperature and battery level. These two readings are very important for drone operations. If the charge level is too low, you do not want to fly. If the electronics or the battery are overheating, it's time for a short break. To start the program, just click the green arrow at the top of the IDE. Listing 2 shows the program output.
Listing 1
Opening a Connection
Listing 2
Connection Output
Depending on your computer's feature set, if nothing is working you might only see an error message. The program must connect to the drone's WiFi to achieve control. Most desktop PCs do not have a WiFi interface. A simple and inexpensive solution to this problem is a USB WiFi adapter. I had one [5] in my tinkering box that worked perfectly with Ubuntu.
Ready to Start
You now know how to connect the computer to the drone and query simple status information, so it's time for a small test flight. With the program in Listing 3, launch the drone, let it fly forward a few centimeters, and then land. Controlling the drone always follows the same pattern. You create an object for the drone and call its methods to perform the specific actions.
Listing 3
Flying the Drone
To discover what actions the object supports, mouse over a method and press Ctrl+Left mouse button to access the library's source code, where you can snoop around a bit. Alternatively, type drone. and scroll through the menu (Figure 4). I did look for better documentation for the library, but my search turned up nothing.
I need to talk about one more special method for the drone object: send_rc_control
specifies motion speeds for the drone's individual degrees of freedom. The permissible values range from -100
to 100
. The method supports four parameters:
- Speed left or right
- Speed forward or back
- Speed up or down
- Rotational speed clockwise or counterclockwise
This method is a simple way to control the drone remotely.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.