How to control DJI Tello Mini-Drone using Python
If you want to take your drone programming skills to the next level, DJI Tello is the right product to buy. Tello is $99 mini-drone that can be programmed using Python, Scratch and Swift. It is rightly called as an indoor quadcopter that comes equipped with an HD camera, giving you a bird’s-eye view of the world. It’s damn easy to fly. Start flying by simply tossing Tello into the air. Slide on your mobile screen to perform 8D flips cool aerial stunts. It’s quite lightweight and dimensions are 3.8 x 3.6 x 1.6 inches, weighing only 2.8 ounces. One of the amazing feature is its VR headset compatibility. You can fly it with a breathtaking first-person view.
Tello is a small quadcopter that features a Vision Positioning System and an onboard camera. Tello is a great choice if you want to learn AI analytics at the Edge. Imagine you’re building an application that captures video streaming from the drone and sends it to AI computers like Jetson Xavier or Nano for AI analytics, storing the time-series data in Redis running over Cloud and visualizing it over Grafana. There’s ample amount of learning opportunity using these affordable drones for researchers, engineers and students.
Notable Features of Tello Drone
- DJI Tello has an excellent flight time of 13 minutes. (enough for your indoor testing!)
- It comes with a 5MP camera. It can shoot 720p videos, and has digital image stabilization!
- Approximately 80 g (Propellers and Battery Included) in weight.
- This small drone has a maximum flight distance of 100 meters and you can fly it in various flight modes using your smartphone or via the Bluetooth controller!
- It has two antennas that make video transmission extra stable and a high-capacity battery that offers impressively long flight times.
- It comes with a Micro USB Charging Port
- Equipped with a high-quality image processor, Tello shoots incredible photos and videos. Even if you don’t know how to fly, you can record pro-level videos with EZ Shots and share them on social media from your smartphone.
- Tello height can be hacked . Check this out: http://protello.com/tello-hacking-height-limit/
- DJI Tello has a brushed motor, which is cheaper than the brushless motor, but it’s also less efficient. (Sadly, brushed motors are known to burn out sometimes due to low quality or poor implementation. They’re also susceptible to rough impacts).
- Being a Non-GPS drone, it is very stable. Video quality is quite decent and landing is also accurate. Also fly it during calm winds or no winds conditions otherwise it’ll sway away with he wind. Good for indoors as well and to click some good selfies.
- DJI Tello is controlled using an application on an iOS or Android mobile phone. It is also possible to control via Bluetooth joystick connected via application.
DJI Tello comes with a detachable Battery of 1.1Ah/3.8V. Insert the 26g battery into the aircraft and charge the battery by connecting the Micro USB port on the aircraft to a charger.
Ways of controlling Your DJI Tello
There are 2 ways you can control your DJI Tello. The first one is using your mobile device, you will need to download Tello or Tello EDU App first. You can also control your Tello via Python or Scratch programming. In this blog, we will see how to control Tello using Python.
- Linux System( Desktop or Edge device)
- Tello Mobile app
Press the “Power” button of Tello once. Once it start blinking, open up Tello Android app to discover Tello drone. Open settings and configure WiFi settings like username and password. Connect your laptop to the Tello WiFI network. Follow the below steps to connect via Python script.
Install using pip
pip install djitellopy
For Linux distributions with both python2 and python3 (e.g. Debian, Ubuntu, …) you need to run
pip3 install djitellopy
See djitellopy.readthedocs.io for a full reference of all classes and methods available.
Step 1. Connect, TakeOff, Move and Land
The below Python script allows you to connect to the drone, take off, make some movement — Left and Right and then Land smoothly.
from djitellopy import Tello
tello = Tello()
Step 2. Take a Picture
from djitellopy import Tellotello = Tello()
frame_read = tello.get_frame_read()tello.takeoff()
Step 3. Recording a Video
import time, cv2
from threading import Thread
from djitellopy import Tellotello = Tello()tello.connect()keepRecording = True
frame_read = tello.get_frame_read()def videoRecorder():
# create a VideoWrite object, recoring to ./video.avi
height, width, _ = frame_read.frame.shape
video = cv2.VideoWriter('video.avi', cv2.VideoWriter_fourcc(*'XVID'), 30, (width, height))while keepRecording:
time.sleep(1 / 30)video.release()# we need to run the recorder in a seperate thread, otherwise blocking options
# would prevent frames from getting added to the video
recorder = Thread(target=videoRecorder)
tello.land()keepRecording = False
Step 4. Control the drone using Keyboard
from djitellopy import Tello
import cv2, math, timetello = Tello()
frame_read = tello.get_frame_read()tello.takeoff()while True:
# In reality you want to display frames in a seperate thread. Otherwise
# they will freeze while the drone moves.
img = frame_read.frame
cv2.imshow("drone", img)key = cv2.waitKey(1) & 0xff
if key == 27: # ESC
elif key == ord('w'):
elif key == ord('s'):
elif key == ord('a'):
elif key == ord('d'):
elif key == ord('e'):
elif key == ord('q'):
elif key == ord('r'):
elif key == ord('f'):
In my next blog post, I will showcase how to implement object detection and analytics using Deep Learning, DJI Tello, Jetson Nano and DeepStream.
Originally published at https://collabnix.com on December 5, 2021.