Skip to content

Running RTL AIS on Raspberry Pi

mike w edited this page Jan 24, 2021 · 1 revision

Here's some quick notes on how to build and run RTL-AIS on a Raspberry Pi.

Prerequisites

You'll need:

  • An RTL-SDR compatible tuner. I'm using this bundle.
  • A working Raspberry Pi.

Step 1: Install dependencies

You'll need a handful of packages locally to build/run:

$ sudo apt-get install git librtlsdr-dev librtlsdr build-essential

Step 2: Fetch code

$ git clone https://github.com/dgiardini/rtl-ais

Step 3: Compile the code

Step into the source code and build it.

$ cd rtl-ais
$ make

If it succeeds, you'll have an rtl_ais binary locally:

$ ./rtl_ais --help
./rtl_ais: invalid option -- '-'
rtl_ais, a simple AIS tuner
	 and generic dual-frequency FM demodulator

[...]

Running rtl_ais for Airdash

Airdash expects rtl_ais to be started as a TCP server. Here is a minimal command:

$ ./rtl_ais -p 0.5 -T

Note that -p 0.5 will vary based on your radio. See the usage note in the rtl-ais README.

You can then point Airdash to this server with:

DATA_SOURCES=ais-tcp://localhost:10110

Troubleshooting: undefined reference to ... error

Due to a bug in some distributions of librtlsdr, you might see the following error:

pi@discopi:~/rtl-ais $ make
cc main.o rtl_ais.o convenience.o ./aisdecoder/aisdecoder.o ./aisdecoder/sounddecoder.o ./aisdecoder/lib/receiver.o ./aisdecoder/lib/protodec.o ./aisdecoder/lib/hmalloc.o ./aisdecoder/lib/filter.o ./tcp_listener/tcp_listener.o -o rtl_ais -lpthread -lm -L -lrtlsdr
/usr/bin/ld: rtl_ais.o: in function `rtlsdr_thread_fn':
/home/pi/rtl-ais/rtl_ais.c:368: undefined reference to `rtlsdr_read_async'
/usr/bin/ld: rtl_ais.o: in function `rtl_ais_start':
/home/pi/rtl-ais/rtl_ais.c:570: undefined reference to `rtlsdr_open'
/usr/bin/ld: /home/pi/rtl-ais/rtl_ais.c:610: undefined reference to `rtlsdr_set_agc_mode'
/usr/bin/ld: /home/pi/rtl-ais/rtl_ais.c:595: undefined reference to `rtlsdr_cancel_async'
/usr/bin/ld: /home/pi/rtl-ais/rtl_ais.c:596: undefined reference to `rtlsdr_close'

This error occurs because the file at /usr/lib/arm-linux-gnueabihf/pkgconfig/librtlsdr.pc is misconfigured. Edit the file so that the first four lines match these:

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include