AirSpy - RPi - RTL-SDR - ADS-B / AIS

well, that was acronym overload for you.. let me break it down:

Airspy - https://airspy.com/ USB dongle to "listen to all the things"

RPi = Raspberry Pi 4 - yes, they are back in stock & I just received a 4GB version.  Couldn't remember why I had it on back order, so I thought I would use it for this project anyway.

RTL-SDR = Software Defined Radio - basically a USB stick that acts as a scanner of radio waves - but not just audio / digital too.

https://www.rtl-sdr.com/about-rtl-sdr/


So what can you do with this?

Well, you can run software that allows you to see what Plane transponders are broadcasting ADS-B around the 100+mile radius of where you are (if your antenna is good enough) - basically flightaware.com



You can see what Ships are broadcasting AIS messages, albeit usually within a 25m radius - basically marinetraffic.com


Basically, devices transmit encoded messages and we can pick them up from the SDR and decode them and work out the details that they contain and then use software to present them either as text in a table or visually on a map - that's how most people look at the data.

The data can also be audio - so you can actually pick up audio/sound and convert that sound - like DAB radio.  yep, you can have a DAB radio via USB too.  Might show how to set that up too - always handy to be able to listen to Planet Rock wherever you happen to be.

You can also pick up the data that satellites are transmitting too... yep, so weather satellites are transmitted data via sound and you can receive this, decode it and get a visual representation of that data and basically see a nice map of that section of the Earth with the weather shown on it... and then there are "other" satellites that you can pick up too - even the ISS (International Space Station) broadcasts data, so when it's flying over you can pick up what it is transmitting.

https://www.rtl-sdr.com/rtl-sdr-tutorial-receiving-noaa-weather-satellite-images/

ADS-B is listening on frequency 1090

AIS is listening on either 161.975 or 162.025 - there are 2 frequencies as a back up.

I have an antenna specifically for AIS, whereas the other antenna can be used for a wider range of frequencies but it will not pick up AIS.


Setting up

We're going to cheat a bit here an use a pre-built image.  Why? well, it contains pretty much EVERY piece of software that you will ever want/need to use and saves having to download everything and configure it yourself.  You can opt to do this if you really want to, but for speed, we'll do it this way:

Go visit this github repo: https://github.com/luigifcruz/pisdr-image

Download the latest image from here:

https://github.com/luigifcruz/pisdr-image/releases/tag/v6.1

Select the img.xz file and use the right tool to burn to a micro-SD card, either Etcher or similar.

Now, take the Micro-SD card and plug it into your RPi4 device.

I'm going to tweak a few things so I can access it via SSH (follow tutorials on the inter-webs) and VNC so I don't have to have it connected to a monitor all the time.

Apparently when it boots up you need to run (in Terminal):

$volk_profile

as this will setup some math optimisation that is used by some of the software.

As the github repo states, a lot of the software is executable only from CMD line.

Once I get it up & running and plugged in - I'll grab some screenshots of the different applications to give an example of usage.

I also aim to install NODE-RED onto the RPi, so that I can gather the data directly, as several of the applications either expose the data onto a UDP or TCP port that you can listen to in Node-Red and get the data, decode it, parse it and "do something" with it.... or you can get the tooling to output/stream the data to a file that you can then read from Node-Red also.  many options.

Will update shortly.

UPDATE:

So, it turns out using the airspy USB device is okay....for specific software.  For instance,as a quick & simple test I thought I'd download, make and use dump1090 - however this isn't compiled to be able to use the airspy - you have to jump through some hoops to get it recognised and to work properly.  It "is" do-able, but I'll do it later.



So, for now, I have a specific FlightAware USB dongle that IS supported, so plugging that in and running ./dump1090 --net and there we go, loads of data flying up the screen!

I do also have a "I will only work on 1090 frequency" antenna too.


As I am travelling in my motorhome, this is attached to the arm of the passenger seat inside the motorhome, rather than externally - although it still gets great signal.

..and YES, that is the cockpit of my motorhome and not a private jet - although it does feel like it sometimes :-)


As mentioned, I've set up an RPi 4 with the flightaware USB plugged in and I have dump1090 running.  so, how do you go about "seeing" what data is being captured?

Well, that's actually pretty simple.  The dump1090 software actually shares the decoded data on port 30003, so you can see in the screenshots below (top-right), I'm just running telnet with port 30003 - this shows me the decoded data.  I can re-direct that output to a csv file - so I can then use that data later.

Then, in steps node-red.  If you don't know what node-red is, go google it, go download it, go install it, go and use it!  it's great.  it's low-code. in fact we can get that dump1090 data received, parsed and output onto a visual map with very little code.  very little.  (and absolutely ZER0 python code! yay!)

As you can see in the following screenshots, I was up & running receiving live plane data and was able to also have an overlay of weather on the map too - yes, one of the ONLY places in the UK that was having a rain-storm, was where I was... it was interesting to see all the planes avoiding the rain!





Of course - that data that we're streaming directly to node-red via port 30003 can be stored into a database - we can build up "tracks", ie. where the individual planes have travelled (there are also some extra features within dump1090 to help with that, it can output that data to .json files).

Then once we have all of that data available to us - we can do all sorts, we can "replay" a specific day  & time, we can monitor specific planes and yep, we can even get a bit of ML (AI, but it's not AI) in the equation to - to detect anomalies, ie. that plane usually follows route X to Y, why did it deviate? was it weather related or other reason?

Now to set the same sort of thing up with the AIS device for ships :-)


UPDATE 2:

okay, so I decided to take a drive early on a Saturday morning down to the coast to see what ship data I could catch.... I had planned to be there for midday, however, I woke up early and got there for about 08:00! so, spent about an hour capturing data... and boy did I get a lot of data over an hour.

Again, I opted to NOT use the airspy (however, this DOES work with the asi-catcher software), I chose to use a specific USB device and specific antenna too.  Both obtainable from Amazon:



As you will notice, I actually chose to run the software and devices on an UBuntu linux laptop instead of the Raspberry Pi, it works EXACTLY the same, I just chose the laptop for ease of use.

The weather forecast was for rain - however, I got there before the rain, so it wasn't too bad a drive.


capturing data live:


Yes, Mrs.TonyisaGeek was roped into coming along for the ride too:


Apparently out there, there are vessels:



All I had to do was run the AIS-catcher software with the most simple of commands:

$./Ais-catcher -v 10 -o 1

This will output to the screen the data every 10 seconds and the output will be just the RAW NMEA data values, such as:

!AIVDM,1,1,,B,33P;=j@01>wq6U6M1t1=b:Tt00mQ,0*75

!AIVDM,1,1,,A,B3IS3?00BOv<g@W@0OPHkwh1l4pl,0*50

!AIVDM,1,1,,A,B3P=?FP0;Wv90RW@Ao2kCwh1h@C?,0*3B

!AIVDM,1,1,,A,H3P=1eQLtu`4000000000000000,2*1E


Then it was time to copy the data into a file, clean it up a bit (I then realised I should have used the telnet style setup like I did for dump1090 and I could have just streamed all the data to a file there and then.... d'oh!, anyway... wasn't that bad)

Then after a quick setup using the ais-decoder node (there is another ais node, that seems to output not quite the same data into different object attributes), bit of fiddling around and voila, I can read in the file containing all of the data from this morning, parse it, and output the values to a world map - just like the planes, this time with ships

As you can see, I have individual data about each vessel, MMSI Id number, lat/lon, speed, direction, heading, whether under power or sail or even if moored up.


If I zoom in a bit, I get a bit more detail:


and if I zoom in a bit more - wow! I can see more details about who is moored up in the harbour.


I can switch view a bit and even pin-point which vessel is where in the harbour:



If I pick a vessel at random:


MarineTraffic.com informs me that the MMSI Id belongs to this vessel:


and more info is available to view HERE.  I can then use the info. on that website to verify / validate that what I've picked up in real life is actually what is being reported:


Okay, I was fetching the data at 08:00-09:10(ish) and am now creating this information and looking at the data at around 15:30-1630, so the above does actually tally up.


There you have it - using simple USB devices, simple software and a little bit of know-how, we can capture data about ships & planes.  woo!hoo!  why do we want/need to do this?  Well, as they say, "AI is nothing without data"..... OH! it's for doing smart "AI stuff" with ;-)

A future post will potentially explain how to use some python libraries, like Pycaret to detect anomalies in time series data... until then, enjoy!


Check out the other cool stuff the library can do HERE.


Comments