Hello Tello Pilot!
Join our DJI Tello community & remove this banner.
Sign up

Testing the barometer

Does the barometer on your Tello work better than mine?

  • Yes, I get reasonable pressure values

    Votes: 1 14.3%
  • No, I get garbage too

    Votes: 0 0.0%
  • I have not tried yet (and I won't try soon)

    Votes: 1 14.3%
  • It works if you do it like this (please explain in a comment)

    Votes: 0 0.0%
  • I have not tried yet, but it sounds interesting....

    Votes: 5 71.4%

  • Total voters
    7

martinpi

Well-known member
Joined
Dec 15, 2019
Messages
111
Reaction score
54
Location
Vienna. Austria
Website
martinpi.at
Hi everybody,

I wanted to see if the barometer of my Tello produces reliable values.
I am writing a Python program to read the status string and test several functions.
This program is not yet ready to be published, so my program may be the source of trouble.

During the test I let Tello go up and down 200cm.
I read out selected values and copied them into a spreadsheet.
Along with the status string I record the commands given.

I calculated an additional curve which goes up and stays up when I climb
and goes down and stays down when I sink. It is related to the altitude.
In my diagram it is the red curve. When it is up, the pressure should be low and vice versa.

screenshot-baro-diagram.jpg

The blue curve is the baro value as obtained from Tello (in which units?).
The x-axis shows the time in seconds.
It does not look convincing at all.

You might ask if you can get meaningful values from a barometer when you move up and down 2 meters.
The answer is: Oh, yes!

For comparison, I attach a diagram I made with the pressure sensor of my mobile, holding it high and low with my hand,
i.e. approx. 2 meters as well.

Screenshot_20190901-205445_phyphox.jpg

(Luft = air, Druck = pressure, given in hPa which is approx. the same as the old millibar)
Btw, the app I used to make this diagram is phyhox, a really cool app.

So, the conclusion is:
Maybe my program is faulty, I keep looking for errors.
If it is OK, I will soon release it. It will be called TelloCommander.
And if it is OK, the baro sensor of my Tello produces garbage.

I would like to know if you get similar results.
 
Here is a simple test program so you see how I read out the status string (and find a bug, comments are very welcome)

--------------------------------------------------------------------------------------------------------
Python:
# tello demo by Ryze Robotics, modified by Martin Piehslinger

import threading
import socket
import sys
import time

#-----------------------------------------------------------------------------------
def recvBasic():
    global TimeSent
    global TelloReady
    global Running
    global DataDecoded
    global SockBasic
  
    print ("Tello recvBasic task started")
    count = 0
    while Running:
        RecvError = False
        data = "---"
        data = data.encode(encoding="utf-8")
        try:
            data, server = SockBasic.recvfrom(1518)
        except Exception as e:
            RecvError = True
            if (str(e) == 'timed out'):
                print (".", end = "") # python2 users, please remove this line
                pass
            else:
                print ('\n------------------- Exception: ' + str(e) + '\n')
                break
        if (not RecvError):
            # Time = (time.time() - TimeSent)
            DataDecoded = data.decode(encoding="utf-8")
            print(DataDecoded)
            TelloReady = True


    print ("recvBasic ended")
#-----------------------------------------------------------------------------------
def recvState():
    global Running
    global StateDecoded
    global SockState
    global NumFrames
  
    print ("Tello recvState task started")
    count = 0
    while Running:
        RecvError = False
        try:
            data, server = SockState.recvfrom(1518)
        except Exception as e:
            RecvError = True
            if (str(e) == 'timed out'):
                print (":", end = "") # python2 users, please remove this line
                pass
            else:
                print ('\n------------------- Exception: ' + str(e) + '\n')
                break
        if (not RecvError):
            StateDecoded = data.decode(encoding="utf-8")
            if (NumFrames > 0):
                print(StateDecoded)
                NumFrames = NumFrames - 1


    print ("recvState ended")
#-----------------------------------------------------------------------------------

Running = True
DataDecoded = ""
TelloState = ""
StateDecoded = ""
NumFrames = 0

host = ''
tello_address = ('192.168.10.1', 8889)


# --- basic communication --------------
# Create a UDP socket
portBasic = 9000
locaddrBasic = (host,portBasic)
SockBasic = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
SockBasic.settimeout (1)
SockBasic.bind(locaddrBasic)

#recvThreadBasic create
recvThreadBasic = threading.Thread(target=recvBasic)
recvThreadBasic.start()

# ------- retrieving state --------------------
# Create a UDP socket
portState = 8890
locaddrState = (host,portState)
SockState = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
SockState.settimeout (1)
SockState.bind(('0.0.0.0', portState))

#recvThreadState create
recvThreadState = threading.Thread(target=recvState)
recvThreadState.start()


TimeSend = 0
TelloReady = True



print ('\r\n\r\nTello Python3 Demo.\r\n')

print ('Tello: command takeoff land flip forward back left right \r\n       up down cw ccw speed speed? battery?')
print ('state n ... print status string n times \r\n')

print ('end -- quit demo.\r\n')


while Running:
  
        try:
            msg = input(">");

            if not msg:
                break

            Splitted = msg.split()
            keyword = Splitted[0]
          
            if 'end' == keyword:
                print ('...')
                Running = False
                break
            elif (keyword == 'state'):
                NumFrames = int(Splitted[1])

            else:
                # Send data
                if (TelloReady):
                    TelloReady = False
                    msg = msg.encode(encoding="utf-8")
                    sent = SockBasic.sendto(msg, tello_address)
                    TimeSent = time.time()
                    print (str(sent) + ' bytes sent')
        except KeyboardInterrupt:
            Running = False
            print ('\n ctrl-break \n')
            break

TimeShutdown = 2
print ("Will shut down in " + str(TimeShutdown) + " seconds")
time.sleep (TimeShutdown) # give recv tasks some time to end
SockBasic.close()
SockState.close()
print ("Thank you for using telloStatus")
 
Last edited:
  • Like
Reactions: f41ardu and Terry
Thank you for voting.

The code I used to test the barometer is different from the one shown above, and there is a bug.
What I changed in the meantime: I don't run the recvState loop all the time but use tkinter's task scheduling to start it once every second. And this produced results which looked good on first glance, but were obviously not correct.

I'll keep you informed.
 
  • Like
Reactions: Terry
So, here we go.
Made a less sophisticated program, but one that works - read out the status string "as is", and then extract the baro with a second program.
Again, pasted the result into a spreadsheet and created a diagram.
Here is the result:

baromater001.jpg

The commands were takeoff - up 200 - down 200 - up 200 - down 200 - and so on.
After each altitude change I recorded 3 status frames.
On the x-axis there are simply the recorded frames, no exact time given.
I should have taken a reading after landing.

The values look very good.
I still don't know the units. It is definitely not hPa or bar, although metric units are used throughout the SDK.
Is it psi, or inches of mercury, or what?
 
  • Like
Reactions: Terry
So, I finally made it with my (new) python program!
I gave up on using a tkinter GUI as it obviously produces timing issues.

This python program is called tellTello and is released on github, see cozmobotics/tellTello
It is by far not perfect, and my programming style is almost as oldschool as Terry's barometer test method (I never learned OOP).
I'll start a thread on tellTello.

Interesting that the baro reading goes up when Tello goes up. The air pressure goes down when you go up, so the baro reading is some calculated altitude value derived from the air pressure.

barometer002.jpg

This is the recording of the barometer during a flight. The csv (in this case semicolon-separated values) produced by tellTello is pasted directly into a spreadsheet.
In the spreadsheet (Libre Office Calc, similar to Excel) I marked the "baro" column and inserted a diagram. Apart from selecting the diagram type, I had nothing to do.

The csv looks like this:

Code:
watch;time;baro;LastCommand;
watch;1578742551,4846866;22,97;sdk?;
watch;1578742552,5554144;23,33;takeoff;
watch;1578742553,4669297;23,87;takeoff;
watch;1578742554,496137;24,08;takeoff;
watch;1578742555,4571295;24,08;takeoff;
watch;1578742556,480806;24,02;takeoff;
watch;1578742557,511462;24,04;takeoff;
watch;1578742558,516087;24,03;up 200;
watch;1578742559,540514;24,81;up 200;
watch;1578742560,5050292;25,53;up 200;
watch;1578742561,5293624;25,84;up 200;
watch;1578742562,5473232;25,83;up 200;
watch;1578742563,4721029;25,90;down 200;
watch;1578742564,5419698;25,06;down 200;
watch;1578742565,5600834;24,37;down 200;
watch;1578742566,596162;24,16;down 200;
watch;1578742567,5017655;24,17;down 200;
watch;1578742568,584151;24,20;up 200;
watch;1578742569,4839232;24,95;up 200;
watch;1578742570,5131385;25,68;up 200;
watch;1578742571,5201738;26,03;up 200;
watch;1578742572,5424328;26,03;up 200;
watch;1578742573,543368;26,02;down 200;
watch;1578742574,5325823;25,14;down 200;
watch;1578742575,5504208;24,43;down 200;
watch;1578742576,5702677;24,20;down 200;
watch;1578742577,4955163;24,20;down 200;
watch;1578742578,5654259;24,17;land;
watch;1578742579,5845435;23,91;land;
watch;1578742580,503496;23,29;land;

The columns are:
"watch" so I can filter out the interesting lines
time ... for sorting the lines and to see what happened when
baro ... selected in the script, I can select multiple values
LastCommand ... to see which command hat which effect


I start my program with
Code:
python tellTello.py --script baro.txt

Here is the script baro.txt which is interpreted by tellTello:

Code:
# testing the barometer
# debug 1 # only watch lines and error messages on the screen
key # enables you to interact with tello while script is running
watch baro
watchperiod 1
takeoff
up 200
sleep 5
down 200
sleep 5
up 200
sleep 5
down 200
sleep 5
land
sleep 3
end
 
Last edited:

New Posts

Members online

No members online now.

Forum statistics

Threads
5,690
Messages
39,934
Members
17,023
Latest member
Repiv

New Posts