Thursday 2 June 2016

Raspberry Pi RTL-SDR AIS marinetraffic image

Here is a Raspberry Pi SD card image that will decode AIS messages on VHF radio using an RTL-SDR dongle.

It will upload the data to marinetraffic.com (you will need to sign up to marinetraffic.com for this) and also broadcast the AIS sentences on your local area network.

This way, you can use the Raspberry Pi and RTL-SDR as an AIS receiver for OpenCPN

I have shrunk the image to fit on Dropbox.

Image file (.zip) for Raspberry Pi: *8GB SD card*

https://www.dropbox.com/s/pflj3xtczzfb2p2/marinetraffic_rtl_sdr01.zip?dl=0

Edit July 2017 - new link:

https://www.dropbox.com/s/p4wqacko4ru3jpl/marinetraffic_rtl_sdr01.zip?dl=0

~1.6GB download

Instructions for copying an image to SD card are given here:
https://www.raspberrypi.org/documentation/installation/installing-images/windows.md

Setup Instructions:

https://www.dropbox.com/s/nez9zzmkkcxcky4/Raspberry%20Pi%20RTL-SDR%20AIS%20receiver%2001.pdf?dl=0

https://www.dropbox.com/s/1q21f23xkysovd5/Raspberry%20Pi%20RTL-SDR%20AIS%20receiver%2001.pdf?dl=0


[update March 2017 - Fitipower FC0012/13 chips have different gain ranges than the suggested values in the notes. My notes are for RT820x based RTL receivers. To see your receiver's allowable gain values, 1) log into Pi via SSH2) stop the AIS code from auto running:   sudo nano ~/ais.sh 
   change line to GO=0
3) reboot the Pi (sudo reboot)
4) log in again, and run the commands:
    cd /usr/local/bin
    rtl_test
   (exit with CTRL-c)
This will list the allowable gain values for your device. Edit ~/ais.sh to use your new gain value.

I am by no means an expert. This image works for me. YMMV. I welcome feedback and improvements.

You might consider using KPLEX http://www.stripydog.com/kplex/examples/marinetraffic.html to distribute AIS to marinetraffic as well as local network addresses, instead of the 'pipe tee' method used on the image.

16 comments:

  1. Just to keep you advised, your package does run well on a Raspberry Pi 3. I was also able to get the build in WiFi working without too much hassle. One thing I havent been able to get running is a GUI. Only command line so far.

    ReplyDelete
  2. Is it possible to feed multiple sites using your image?

    ReplyDelete
    Replies
    1. Hello Michael, yes it is possible to send the AIS data to multiple sites at once. Edit the file ais.sh: sudo nano ~/ais.sh You should see a line where the output of the AIS decoder is piped to several locations - localhost, marine traffic etc, modify the line to add additional "| tail ..." sections to send the data where you want. I don't have access to my pi at the moment to give a better description sorry

      Delete
  3. Doing this after your recepie. Got a Fitipower FC0012 chip on my sdr. Checked out fine on sdr# on WIN before used on the RP3 with your image. But on MT it says that I'm online but no data - station #746.
    Rebooted and now it looks like this:
    https://snag.gy/dKk9PT.jpg

    Jon

    ReplyDelete
    Replies
    1. Hi Jon, the Fitipower FC0012 has different values for the '--gain' parameter than the RT820x chip in the dongle I used.

      Possible gain values are -9.9, -4.0, 7.1, 17.9, 19.2

      I would use 17.9 (too much gain can be as bad as too little gain if you have a strong broadcast signal nearby)

      Edit the ais.sh script: SSH into your PI and run:

      sudo nano ~/ais.sh

      change the value:

      GAIN=17.6

      Delete
  4. Hi Jon, I am replying on the MarineTraffic help forum as well. I think this is a gain setting issue on the FC0012 compared with the RT820x dongle I am using. I will investigate the proper command for setting the gain on this interface and get back to you.

    ReplyDelete
  5. I can not connect to my pi3 on port 8080 as I can on pi2?
    I do not have any ide.
    Please help

    ReplyDelete
  6. Upppsss. IPV6 o no.... That do not work. Must use ipv4...... Now it works OK.
    Thanks.
    sudo /usr/local/bin/rtail-server --wh 192.168.1.23 --wp 8080 --web-version stable &
    Make it work. If you ar connected to ipv6 do this and it works.
    Have a nice ais traction.

    ReplyDelete
  7. hello
    i have a problem:
    root@raspberrypi:~/src/kalibrate-rtl# ais_rx --gain 44 --error -29 -s osmocom | socat - UDP4-DATAGRAM:1.2.3.4:1234
    gr-osmosdr 0.1.3 (0.1.3) gnuradio 3.7.5
    built-in source types: file osmosdr fcd rtl rtl_tcp uhd miri hackrf bladerf rfspace airspy
    Using device #0 Realtek RTL2838UHIDIR SN: 00000001
    Found Rafael Micro R820T tuner
    [R82XX] PLL not locked!
    Exact sample rate is: 250000.000414 Hz
    [R82XX] PLL not locked!
    can you help me?
    thanks

    ReplyDelete
    Replies
    1. Hello Albert. The message "PLL not locked!" is not a problem. I get it too and I can receive absolutely fine.
      I am led to believe it is because when the receiver software is first started it has no frequency assigned, and the hardware cannot tune the receiver, so give the error message. The frequency is then set to the AIS channels and then works with no error message.


      Delete
    2. Would you like to give me a copy of the drawing of the workshop tutorial?
      please
      I need it to be easier to understand.
      Send to albertsarmedisaragih@gmail.com
      thank you

      Delete
    3. Hello, I have updated the article with new links to the image and configuration instructions.
      Image download: https://www.dropbox.com/s/p4wqacko4ru3jpl/marinetraffic_rtl_sdr01.zip?dl=0

      Instructions: https://www.dropbox.com/s/1q21f23xkysovd5/Raspberry%20Pi%20RTL-SDR%20AIS%20receiver%2001.pdf?dl=0

      Delete
    4. Unfortunately can't get image to work on Rpi 3B. Kernel seems damaged (colored screen and red led, no booting). Standard Raspian image works like a charm on same configuration. Any suggestions to get this fixed?
      Cheers!

      Delete
    5. Same on my new RPi 3B. I put the sd card into a Rpi2 and updated to Raspi stretch. Now - it works!

      Delete
    6. Some problems with starting ais_rx on Raspian "Stretch":

      ais_rx --gain 44 --error -3 -s osmocom | socat - UDP4-DATAGRAM:5.9.207.224:9811
      Traceback (most recent call last):
      File "/usr/local/bin/ais_rx", line 7, in
      import ais
      File "/usr/local/lib/python2.7/dist-packages/ais/__init__.py", line 45, in
      from ais_swig import *
      File "/usr/local/lib/python2.7/dist-packages/ais/ais_swig.py", line 28, in
      _ais_swig = swig_import_helper()
      File "/usr/local/lib/python2.7/dist-packages/ais/ais_swig.py", line 24, in swig_import_helper
      _mod = imp.load_module('_ais_swig', fp, pathname, description)
      ImportError: libgnuradio-runtime.so.3.7.5: cannot open shared object file: No such file or directory

      Delete