donderdag 11 november 2021

Experimenting with Node-Red coding on a Raspberry Pi


Trying some coding  on a raspberry pi with a sense hat using node-red.

The environment variables(temperature, humidity and pressure) are shown on the node red dashboard in the background and streaming on the sense hat display.


















I used these data 4 years ago to build a weather station using MySQL and R; here are the links:

1. https://d3-media.blogspot.com/2017/01/weather-data.html 


2. https://d3-media.blogspot.com/2017/01/the-electronic-barometer-2.html

3. https://d3-media.blogspot.com/2017/01/the-electronic-barometer-3.html


woensdag 3 november 2021

Flying around (4)….Hacking the Tello

Tello creates its own based WiFi network. It uses 2.4 Ghz and UDP as protocol to communicate with a client over ports 8889 at the server and 8890 at the client.

Let’s first look at the WiFi. When you directly connect from your cellphone no security protocol is used; just an open WiFi connection between server 192.168.10.1(tello) and the client 192,168.10.2(phone).

IN-USE SSID MODE CHAN RATE SIGNAL BARS SECURITY

* TELLO-627F4A Infra 4 54 Mbit/s 95 ▂▄▆█ --

If you create a password, an option in the settings of the app, WPA2 is used as the security protocol.

IN-USE SSID MODE CHAN RATE SIGNAL BARS SECURITY

TELLO-TELLO-627F4A Infra 4 54 Mbit/s 100 ▂▄▆█ WPA2

You can remove the password by holding the start button for 10 sec. Tello will completely reset. 

Tello is equipped with SDK: software development kit. The Tello SDK 2.0 user guide gives an overview of programming commands. Download here:https://dl-cdn.ryzerobotics.com/downloads/Tello/Tello%20SDK%202.0%20User%20Guide.pdf


Packet Sender

Is it possible to send SDK commands directly to the Tello?

When a computer is directly connected to the Tello network, you could give commands directly to to the Tello. Install ‘Packet Sender’ and send UDP packages to the Tello on address 8889. Tello will reply with OK.

Here is a screenshot showing battery, takeoff and land.







How about connecting the Tello to you home network with WiFi? Yes that is possible, then Tello is not an access point anymore but a client to the home WiFi network.More on this: https://tello.oneoffcoder.com/swarm.html



Home Network

Adding Tello to the home network:

Run the following python script: python set-ap-mode.py -s [SSID] -p [PASSWORD]

Here is the response:

sending cmd command

from ('192.168.10.1', 8889): b'ok'

sending cmd ap [SSID] [PSW]

from ('192.168.10.1', 8889): b'OK,drone will reboot in 3s'


Now Tello is a client of you home network, and directly connecting to the Tello from the phone app is not possible anymore.

Next: We have to scan the network for the IP number of the Tello

nmap -sP 192.168.178.0/24 or nmap -sT 192.168.178.1/24


Nmap scan report for _gateway (192.168.178.1)

Host is up (0.0080s latency).

Nmap scan report for 192.168.178.24

Host is up (0.015s latency).

Nmap scan report for 192.168.178.52

Host is up (0.081s latency).

Nmap scan report for 192.168.178.80

Host is up (0.034s latency).

Nmap scan report for 192.168.178.101

Host is up (0.035s latency).

The last one was newly added to the home network.


Ping on that address:

peter@Pegasus:~/Desktop/TELLO$ ping 192.168.178.101

PING 192.168.178.101 (192.168.178.101) 56(84) bytes of data.

64 bytes from 192.168.178.101: icmp_seq=1 ttl=255 time=1.33 ms

We could check the connection by sending UDP packages with packet sender.


Or run python scripts to control a flight or a mission of  the Tello. But in the scripts you have to update/change the IP address of the Tello and the ID. Send sn? with packet sender to get the ID.

From the oneoffcoder site – https://tello.oneoffcoder.com/swarm.html – try the following scripts.

demo_single.py and demo_status were working. Don’t forget to update the IP number and ID when connected to local wifi network.

You can also create a complete mission and save taht in a .txt file.

Then run:

python planned-flight.py -f cmds-01.txt

See also my blog posting Flying Around(3).
Java Script

Not only Python but also JavaScript is possibility to control Tello from the command line.

But you have to install the environment to to load a JavaScript for execution. I used the Snapstore and searched for npm to install node.js.

The following GitHub repository has a few scripts to get started:

https://github.com/jsolderitsch/tello-nodejs


You can run for example:

node TelloCommandLine.js

this invites you to send commands to the drone

Tello Command Console

---------------------------------------

Tello> Enter a Tello SDK Command.

Tello> command

Command: command

Data received from server : ok

Tello> takeoff

Command: takeoff

Data received from server : ok

Tello> land

Command: land

Data received from server : ok

Tello> command

Command: command

Data received from server : ok

Tello> takeoff

Command: takeoff

(If the port is already in use; run sudo pkill -9 node)


Node-Red

A special case for controlling Tello with JavaScript is Node-Red. Here is the GitHub repository:

https://github.com/johnwalicki/Node-RED-Tello-Control


What exactly is Node-RED?

Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.

Node-RED allows you to create functionality by wiring together flows of data between nodes using a browser. And it has gained tremendous popularity in the IoT space, by modeling bits of application functionality between IoT devices like sensors, cameras, and wireless routers.

Node Red is developed by IBM and is block based coding in a browser. After deploying the code you can have the results. Here are two pictures that show the basics: left the block coding and right the result after deploying.




A desktop or laptop is not great fun for controlling the Tello. Node_red can also be installed on an android device, like a phone or tablet. A complete install is possible, but a bit complicated because you have to set up Termux on your phone/tablet.

For installing Termux, see also http://d3-media.blogspot.com/2021/04/data-journalism-on-samsung-tablet-with.html

After installing Termux is here the recipe for installing node red: https://nodered.org/docs/getting-started/android


Much easier is to install an app RedMobile Lite – Node -RED on Android.


Node Red is especially interesting for IoT, internet of things, connecting devices and data streams. Connecting Tello with Amazon Alexa is an example. Here is the code: https://www.hackster.io/econnie323/alexa-voice-controlled-tello-drone-760615 . After installing you will be able to control Tello with voice commands.