In my case, I'm watching POCSAG on 148 MHz, ADS-B on 1090 MHz and a weather station on 433 MHz. Different frequencies need different antennas, so it's important I select the right one; I've found that the device index follows no pattern (it's been reported it's based on the order it's plugged in, but I've got devices that will take on index 0 even if another device already has it).
Image courtesy of rtl-sdr.com: Using Multiple RTL-SDRs to Capture a Trunking System
To achieve this, we need to be able to do three key things:
- Uniquely identify each device in software
- List all RTL-SDRs in a system by index and unique identifier
- Retrieve the index that can be supplied in-line to existing tools
rtl_eeprom -d 0 -s 00000666
Just plug one device in at a time to ensure you've got the right one! Everything going to plan, you'll see the message Configuration successfully written once the serial is updated.
Next, we need to enumerate all devices in the system - but we have to cheat a little bit here. Like many of the tools in the rtl-sdr library, most will list all devices as part of their output. We use the rtl_sdr tool for this, but the cheat is that we need to specify an invalid device index to get it to enumerate all devices in a way we can scrape the output:
pi@pitwo:~ $ rtl_sdr -d 9999
Found 3 device(s): 0: Realtek, RTL2838UHIDIR, SN: 00000001 1: Realtek, RTL2838UHIDIR, SN: 00000002 2: Realtek, RTL2838UHIDIR, SN: 00000666
No matching devices found. rtl_sdr, an I/Q recorder for RTL2832 based DVB-T receivers Usage: -f frequency_to_tune_to [Hz] [-s samplerate (default: 2048000 Hz)] [-d device_index (default: 0)] [-g gain (default: 0 for auto)] [-p ppm_error (default: 0)] [-b output_block_size (default: 16 * 16384)] [-n number of samples to read (default: 0, infinite)] [-S force sync output (default: async)] filename (a '-' dumps samples to stdout)
rtl_sdr -d 9999 |& grep -P -o "\d(?=:\s*.+SN: 00000666)"
Which returns only the device index (2 in this instance). If you're playing along at home, the above regex comprises the following:
- \d: Any single digit
- (? ): Lookahead query
- .+ : Match any number of any characters
- : and SN: 00000666: Strings to match
From here, you can slip it inline with an existing command using $():
$(rtl_sdr -d 9999 |& grep -P -o "\d(?=:\s*.+SN: 00000666)")
rtl_fm -A lut -s 22050 -f 148.9125M -d $(rtl_sdr -d 9999 |& grep -P -o "\d(?=:\s*.+SN: 00000666)") -g 17.9 | multimon-ng -t raw -a POCSAG512 -a POCSAG1200 -a POCSAG2400 -f alpha /dev/stdin
It's worth noting that certain tools, such as dump1090, allow you to specify a serial number instead of device index - always use the device serial as the identifier wherever available!
Hi Chris great job! Anyway to set squelch on this and pipe to Java?
ReplyDelete