Ajeet Raina Docker Captain, ARM Innovator & Docker Bangalore Community Leader.

How to control DJI Tello Mini-Drone using Python

3 min read

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.
Photo Quality Setting in Tello App
  • Tello comes with sensors that helps it finding obstacles and during the landing
DJI Tello Calibration Settings
  • 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.

Getting Started

Hardware Required:

Unboxing DJI Tello Drone
  • DJI Tello Drone (Buy)
  • Charging Cable
  • Battery (Buy)

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.

Pre-requisite:

  • Linux System( Desktop or Edge device)
  • Python3
  • 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

API Reference

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()

tello.connect()
tello.takeoff()

tello.move_left(100)
tello.rotate_counter_clockwise(90)
tello.move_forward(100)

tello.land()

Step 2. Take a Picture

import cv2
from djitellopy import Tello

tello = Tello()
tello.connect()

tello.streamon()
frame_read = tello.get_frame_read()

tello.takeoff()
cv2.imwrite("picture.png", frame_read.frame)

tello.land()

Step 3. Recording a Video


# source https://github.com/damiafuentes/DJITelloPy
import time, cv2
from threading import Thread
from djitellopy import Tello

tello = Tello()

tello.connect()

keepRecording = True
tello.streamon()
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:
        video.write(frame_read.frame)
        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)
recorder.start()

tello.takeoff()
tello.move_up(100)
tello.rotate_counter_clockwise(360)
tello.land()

keepRecording = False
recorder.join()

Step 4. Control the drone using Keyboard

# source https://github.com/damiafuentes/DJITelloPy
from djitellopy import Tello
import cv2, math, time

tello = Tello()
tello.connect()

tello.streamon()
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
        break
    elif key == ord('w'):
        tello.move_forward(30)
    elif key == ord('s'):
        tello.move_back(30)
    elif key == ord('a'):
        tello.move_left(30)
    elif key == ord('d'):
        tello.move_right(30)
    elif key == ord('e'):
        tello.rotate_clockwise(30)
    elif key == ord('q'):
        tello.rotate_counter_clockwise(30)
    elif key == ord('r'):
        tello.move_up(30)
    elif key == ord('f'):
        tello.move_down(30)

tello.land()

In my next blog post, I will showcase how to implement object detection and analytics using Deep Learning, DJI Tello, Jetson Nano and DeepStream.

References:

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Docker Captain, ARM Innovator & Docker Bangalore Community Leader.

67 Replies to “How to control DJI Tello Mini-Drone using Python”

  1. There are definitely a number of details like that to take into consideration. That may be a nice point to deliver up. I provide the ideas above as basic inspiration however clearly there are questions like the one you bring up where a very powerful factor shall be working in sincere good faith. I don?t know if greatest practices have emerged round issues like that, however I’m sure that your job is clearly identified as a good game. Both girls and boys feel the affect of just a moment’s pleasure, for the remainder of their lives.

  2. Hello, you used to write fantastic, but the last few posts have been kinda boring?K I miss your tremendous writings. Past several posts are just a little out of track! come on!

  3. You actually make it seem really easy along with your presentation however I find this matter to be actually one thing which I believe I’d never understand. It seems too complex and extremely wide for me. I’m having a look forward on your next publish, I?¦ll attempt to get the grasp of it!

  4. I have been browsing online greater than three hours nowadays, yet I by no means discovered any interesting article like yours. It is pretty value sufficient for me. In my opinion, if all web owners and bloggers made just right content material as you did, the internet will likely be a lot more useful than ever before.

  5. hi!,I like your writing so much! proportion we keep up a correspondence more approximately your post on AOL? I require an expert in this area to solve my problem. Maybe that is you! Looking forward to look you.

  6. I’m not that much of a online reader to be honest but your sites really nice, keep it up! I’ll go ahead and bookmark your website to come back later. Cheers

  7. Sweet blog! I found it while browsing on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Cheers

  8. Nice post. I learn one thing more difficult on totally different blogs everyday. It can at all times be stimulating to learn content material from different writers and practice a bit something from their store. I’d choose to use some with the content on my weblog whether you don’t mind. Natually I’ll offer you a hyperlink in your net blog. Thanks for sharing.

  9. Thank you, I have recently been searching for information approximately this topic for a long time and yours is the best I’ve came upon till now. However, what in regards to the conclusion? Are you sure about the supply?

  10. Thank you for another excellent post. The place else may just anybody get that type of information in such an ideal approach of writing? I’ve a presentation subsequent week, and I’m at the search for such information.

  11. Thanks for your whole labor on this web page. My mum really likes making time for investigation and it’s easy to see why. I hear all regarding the powerful mode you convey informative suggestions via your web blog and as well cause response from others on that topic so my daughter is discovering a lot of things. Take advantage of the remaining portion of the new year. You are doing a really good job.

  12. Howdy just wanted to give you a quick heads up and let you know a few of the images aren’t loading properly. I’m not sure why but I think its a linking issue. I’ve tried it in two different internet browsers and both show the same results.

  13. Having read this I thought it was very informative. I appreciate you taking the time and effort to put this article together. I once again find myself spending way to much time both reading and commenting. But so what, it was still worth it!

  14. I haven¦t checked in here for some time as I thought it was getting boring, but the last few posts are good quality so I guess I¦ll add you back to my everyday bloglist. You deserve it my friend 🙂

  15. Hello would you mind sharing which blog platform you’re working with? I’m planning to start my own blog in the near future but I’m having a tough time choosing between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for something unique. P.S Apologies for being off-topic but I had to ask!

  16. I loved as much as you’ll receive carried out right here. The sketch is tasteful, your authored subject matter stylish. nonetheless, you command get got an nervousness over that you wish be delivering the following. unwell unquestionably come more formerly again since exactly the same nearly very often inside case you shield this increase.

  17. Nice post. I study something tougher on completely different blogs everyday. It can always be stimulating to learn content material from different writers and follow somewhat one thing from their store. I’d prefer to make use of some with the content material on my blog whether or not you don’t mind. Natually I’ll provide you with a link on your net blog. Thanks for sharing.

  18. I just couldn’t depart your web site prior to suggesting that I extremely enjoyed the standard info a person provide for your visitors? Is going to be back often in order to check up on new posts

  19. What i don’t understood is actually how you are not actually much more smartly-preferred than you might be right now. You’re so intelligent. You understand thus considerably on the subject of this subject, produced me in my view believe it from a lot of numerous angles. Its like women and men are not interested until it is something to do with Girl gaga! Your own stuffs great. At all times care for it up!

  20. I am usually to blogging and i actually recognize your content. The article has actually peaks my interest. I’m going to bookmark your website and hold checking for brand new information.

  21. Howdy I am so happy I found your blog page, I really found you by accident, while I was browsing on Bing for something else, Nonetheless I am here now and would just like to say many thanks for a fantastic post and a all round thrilling blog (I also love the theme/design), I don’t have time to go through it all at the moment but I have book-marked it and also added in your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the awesome work.

  22. Hi, I think your site might be having browser compatibility issues. When I look at your website in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, fantastic blog!

  23. Good day! I know this is kind of off topic but I was wondering if you knew where I could locate a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having problems finding one? Thanks a lot!

  24. We’re a group of volunteers and starting a new scheme in our community. Your site offered us with valuable information to work on. You have done a formidable job and our whole community will be thankful to you.

  25. Good post and straight to the point. I am not sure if this is truly the best place to ask but do you folks have any thoughts on where to hire some professional writers? Thanks in advance 🙂

  26. Great V I should definitely pronounce, impressed with your site. I had no trouble navigating through all tabs as well as related information ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Quite unusual. Is likely to appreciate it for those who add forums or something, website theme . a tones way for your customer to communicate. Nice task..

  27. Today, I went to the beach with my children. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is completely off topic but I had to tell someone!

  28. I know this if off topic but I’m looking into starting my own weblog and was wondering what all is needed to get set up? I’m assuming having a blog like yours would cost a pretty penny? I’m not very web savvy so I’m not 100 sure. Any suggestions or advice would be greatly appreciated. Thank you

  29. One thing I’ve noticed is that often there are plenty of fallacies regarding the lenders intentions any time talking about property foreclosures. One fantasy in particular is the fact that the bank wishes to have your house. The lender wants your dollars, not the home. They want the money they lent you with interest. Keeping away from the bank will only draw some sort of foreclosed conclusion. Thanks for your article.

  30. Hey there! This is my first comment here so I just wanted to give a quick shout out and tell you I truly enjoy reading through your posts. Can you suggest any other blogs/websites/forums that go over the same subjects? Thanks!

Leave a Reply

Your email address will not be published.

© Copyright Collabnix Inc

Built for Collabnix Community, by Community