Linux Format

LEDs and landing strips

Discover how you can use your Raspberry Pi to scan the skies for flying craft, and light up your workspace with bright lights.

-

Look to the skies above and you might see any number of craft overhead. Aeroplanes, helicopter­s, drones, UFOs… there’s all sorts. And if you have a clear line of sight (LoS) to a patch of sky, then with some not very expensive kit you can find out a little about your local air traffic, making those UFOs a little more identifiab­le.

Most air jurisdicti­ons require aircraft using them to send periodic ADS-B (Automatic Dependent Surveillan­ce-Broadcast) data. In the US the FAA is moving away from ground navigation­al aids (such as radar) in favour of ADS-B, because it’s safer, cheaper and provides more informatio­n. It’s also much more feasible for smaller aircraft, so you might spot a few of those. This data is sent unencrypte­d through the ether. So let’s start sniffing.

You’ll need an ADS-B receiver and an antenna. If you’re in an urban area, you may want a 1,090MHz filter to get rid of urban electromag­netic noise (the Flight Aware stick we used has this filter built-in). We used a 5dB antenna to get started, which is a small step up from the entry-level models that tend to come bundled with the receiver. ADS-B signals are blocked out by walls, so you’ll see more craft if the antenna is positioned close to a window. If you want to get serious, you can set everything up outside on the top of a hill with a very large antenna. Just watch out for lightning strikes.

We’ll start by installing the required tooling, we’ll need to compile the dump1090 utility in a moment so we need some header files for various chipsets. The build tools were installed already on our clean install of the desktop OS, but they probably aren’t in the Lite version:

$ sudo apt install build-essential debhelper librtlsdrd­ev pkg-config libncurses­5-dev libbladerf-dev libhackrf-dev liblimesui­te-dev libsdl2-ttf-2.0-0 The next step is to clone the dump1090 repository and begin the build: $ git clone https://github.com/flightawar­e/dump1090. git

$ cd dump1090

$ make

This is quite a small program so the build won’t take too long. You can speed this up, marginally, on quad core Pis by running make -j3 instead. Or you could take a break and make a cup of tea anyway. Now plug in your receiver and antenna, if you haven’t already, and run

dump1090 in interactiv­e mode:

$ ./dump1090 --interactiv­e

You should see a table appear in your console with various rows filled with data for nearby aircraft, including their altitude and flight number. If you don’t see any data, consider moving closer to the outside. It’s quite straightfo­rward to plot this data on a map. In fact

dump1090 has a web applicatio­n that does just this, we just need to activate it, and then use the simple Python webserver to serve the directory. This time run

dump1090 again, this time activating JSON output:

$ mkdir public_html/data

$ ./dump1090 --write-json public_html/data

Now open another terminal (this also all works remotely/headlessly, so start another SSH session in that case) and start the HTTP server:

$ cd ~/dump1090/public_html

$ python -m http.server

Now open up a browser (anywhere on your local network) and navigate to http://192.168.x.y:8000

replacing the IP address as appropriat­e. You should see a map, and if you zoom in to your location you should see the aircraft within your antenna’s earshot.

Pretty lights

The Raspberry Pi may be a great platform for learning, but one major thing it can’t do out of the box is use analog electronic components. That leaves everything from analog joysticks to potentiome­ters off-limits by default, but fortunatel­y adding an expensive chip solves the problem. The MCP3008 ADC (Analog to Digital Converter) is used to connect analog electronic­s to the Raspberry Pi’s 40 GPIO pins, enabling you to use all kinds of additional components.

To show you how to take advantage of analog-todigital conversion and how to make a fun light show, we’ve created a project that will read three potentiome­ters and use these dials to control the colour of an Adafruit NeoPixel. Here’s how to create a colourful Raspberry Pi light show using analog input. We used a 12-pixel LED ring from Adafruit, but the idea applies anywhere. You’ll also need a breadboard, three 10k potentiome­ters and a selection of jumper wires. You may

need to solder jumper wires to your LEDs or otherwise extend the connection to the breadboard.

We borrowed this project from Tom’s Hardware. See www.tomshardwa­re.com/uk/how-to/raspberry-pi-lightshow-analog-inputs for the original.

Insert the MCP3008 into the breadboard so that the pins straddle the central cut out. The notch on the chip should face the short end of the breadboard. The 16 pins of the MCP3008 start with 1 in the bottom left corner, then we count along to 8 in the bottom right. Pin 9 is in the top right corner and finally pin 16 in the top left.

Connect the MCP3008 to the Raspberry Pi GPIO using the female-to-male jumper wires. First use the female-to-male wires to connect the 3.3V and GND pins to the + and - rails of the breadboard. Then use male-tomale wires to connect the rails to the MCP3008 pins for power and GND.

Jump around

Connect the MCP3008 to the Raspberry Pi using female-to-male jumper wires. Pin 10 on the MCP should connect to GPIO 08 on the Pi. Pin 11 goes to GPIO10. Pin 12 goes to GPIO 9 and Pin 13 to GPIO11. Insert the potentiome­ters and connect them to the MCP3008 using male-to-male jumper wires. They connect on pins 1, 2, and 3 which is easy. Solder three wires, or otherwise connect them, to the Adafruit NeoPixels. PWR, GND and In. PWR connects to the + rail on the breadboard, GND to the - rail. “IN” is connected to GPIO 18 on the Raspberry Pi.

We need to install the Python modules for NeoPixels: $ sudo pip3 install rpi_ws281x adafruit-circuitpyt­honneopixe­l And here’s the code to get it going: import board import neopixel from time import sleep from gpiozero import MCP3008

r = MCP3008(channel=0) g = MCP3008(channel=1) b = MCP3008(channel=2) pixels = neopixel.NeoPixel(board.D18, 16)

while True: red = round(r.value * 255) green= round(g.value * 255)

START SCANNING THE SKIES “ADS-B signals are blocked out by walls, so you’ll see more craft if the antenna is positioned close to a window.”

blue = round(b.value * 255) print(red,green,blue) for i in range(16): pixels[i] = (red, green, blue) sleep(0.1)

See the final pages for a glimpse at how this might be different on the Arduino.

 ?? ?? Skies over Bath were quiet this evening, but perhaps if we had a bigger antenna we would see more activity.
Skies over Bath were quiet this evening, but perhaps if we had a bigger antenna we would see more activity.
 ?? ?? The circuit diagram looks nice and tidy, but in real life things will be much messier.
The circuit diagram looks nice and tidy, but in real life things will be much messier.
 ?? ?? There, we have overcome the Pi’s aversion to analogue electronic­s.
There, we have overcome the Pi’s aversion to analogue electronic­s.
 ?? ??

Newspapers in English

Newspapers from Australia