Saturday, 17 April 2021

MTU issue with Zerotier

Just for the record, I had some issues using Zerotier between UK and US. For some reason, I could ping through with default packet size but ssh did not work. Once I changed MTU on UK side as follows it was working stable.

pi@pi0w:~ $ sudo nano /etc/dhcpcd.conf
interface wlan0
static interface_mtu=1200

Thursday, 1 April 2021

Exploring software defined radios

When last season Premier League restarted behind closed gates some games were broadcasted on Pick (a free to air Sky channel) paralell to paid streaming so I built a DVB-T hat on a Raspberry Pi Zero W. This was great fun running a small TV headend able to stream BBC One, BBC Two, iTV, Channel 4 and Channel 5 simultaneously, all in HD quality to Kodi installed on any device. But with the cease of free to air games I realised that watching TV on the corresponding apps (BBC iPlayer, iTV Hub, etc.) is actually even more convenient and does not disturb my daugther as reception was only adequate from her window upstairs.
Already back then I read about software defined radios (SDR) but unfortunately the DVB-T hat I got has a Sony CXD2880 tuner that only supports DVB-T/T2.
One of my friends told me he had a lot of fun with SDR during lockdown so I decided to buy a Realtek RTL2832U based USB dongle and plugged it to an unused Raspberry Pi 4B from the drawer.

pi@pi4b2:~ $ lsusb
Bus 001 Device 035: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T

While DVB-T/T2 driver is loaded as default, there are plenty of other bands that can be demodulated as the underlying chip supports a test mode giving direct access to IQ stream output from the tuner. To get access to the other bands, first we need to blacklist the DVB driver:

pi@pi4b2:~ $ sudo nano /etc/modprobe.d/blacklist-dvb.conf
blacklist dvb_usb_rtl28xxu

After reboot we can install rtl-sdr package that is supported in Raspberry Pi OS:

pi@pi4b2:~ $ sudo apt install rtl-sdr
pi@pi4b2:~ $ rtl_test -t
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 
[R82XX] PLL not locked!
Sampling at 2048000 S/s.
No E4000 tuner found, aborting.

Now I was ready to join to an ADS-B community and start sharing. I picked flightradar24 and installed their service with:

pi@pi4b2:~ $ sudo bash -c "$(wget -O - https://repo-feed.flightradar24.com/install_fr24_rpi.sh)"
pi@pi4b2:~ $ fr24feed-status 
[ ok ] FR24 Feeder/Decoder Process: running.
[ ok ] FR24 Stats Timestamp: 2021-04-01 10:46:26.
[ ok ] FR24 Link: connected [UDP].
[ ok ] FR24 Radar: T-EGMD67.
[ ok ] FR24 Tracked AC: 19.
[ ok ] Receiver: connected (16814 MSGS/0 SYNC).
[ ok ] FR24 MLAT: ok [UDP].
[ ok ] FR24 MLAT AC seen: 19.

It runs quite nicely now with 500-900 aircrafts seen in a day. This gives me access to the business plan of flightradar24.com (for all its worth) and my contribution can be viewed online on flightradar24.com as some nice aggregated statistics graphs or more details on actual aircrafts seen locally on port 8754.

UPDATE

I kept having disconnected USB dongle issues. Some error messages in /etc/dmesg suggested powering issues although I was using the official Raspberry Pi power supply. I gave this USB-C hub with power charging input a try:
https://smile.amazon.co.uk/gp/product/B08KW2MCK2/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

In order to use the USB power input of the Raspberry Pi in OTG mode I had to add this line to the boot config file:
pi@pi4b2:~ $ sudo nano /boot/config.txt
otg_mode=1