A simple setup to feed AIS data to Marine Traffic with a Raspberry Pi and USB SDr

Comments

49 comments

  • Official comment
    Avatar
    Dimitris Vitoris

    @Jon Aronsen

    Can you please tell me your station ID?

    Regards

     

    Comment actions Permalink
  • Avatar
    Dimitris Vitoris

    Hi Scott,

    That's actually a pretty good idea. We tried a few SDR solutions on the Pi a while back but it wasn't working reliably and

    it was put on hold. We'll revisit this soon.

    Best Regards

     

    1
    Comment actions Permalink
  • Avatar
    Dimitris Vitoris

    Hi Scott,

    You can download the ARM compatible version of AISDispatcher here:

    http://www.aishub.net/aisdispatcher-linux.html

    Do you plan to use a USB-to-Serial adapter and connect your receiver to the RPi?

    If so check if something like /dev/ttyUSB0 is present on your /dev directory after you connect everything

    up. Assuming you see it there, try the following:

    sudo aisdispatcher -r -d /dev/ttyUSB0 -s 38400 -H 5.9.207.224:xxxx (your unique port number you got during

    registration of your station ID)

    If /dev/ttyUSB0 is not there, check with dmesg (sudo dmesg) immediately after plugging the adapter in to see how the

    device is mounted.

    Best Regards

     

    -1
    Comment actions Permalink
  • Avatar
    Dimitris Vitoris

    Hi Scott,

    You can install tcpdump:

    sudo apt-get install tcpdump

    and in a second terminal (let aisdispatcher run on the other) type:

    sudo tcpdump -i eth0 port 7601

    and check if there are any outgoing TCP packets. For UDP type:

    sudo tcpdump -i eth0 udp port 7601

    Regards

     

    0
    Comment actions Permalink
  • Avatar
    Dimitris Vitoris

    Great !!! You're sending as station ID 2173 at the moment?

    Regards

     

    0
    Comment actions Permalink
  • Avatar
    Dimitris Vitoris

    Good job !!!

    Cheers

     

    0
    Comment actions Permalink
  • Avatar
    Tarquin Roode

    Hi

    I have a similar question, I had some problem to first het AISdispacther to work from my current RS232 based AIS receiver. I think I mnaged to sort that out today, similar to ansers further below so wont repeat that.

    My next step is to get a RTL USB dongle up and running on the PI and using AISdecoder to feed AISdispatcher similar to this http://www.satsignal.eu/raspberry-pi/AIS-receiver.html but so far I do not receive AIS signals on my RTL stick when I use the same antenna as my current AIS receiver.

    Has anybody have any success yet using the RTL dongle on raspberry PI as this would make a low cost AIS receiver and data dispatcher ??

    I also tried kplex http://www.stripydog.com/kplex/examples/marinetraffic.html but still have some issues with decoding my AIS stream. I will still try and sort that outbut it looks like fairly usefull application.

    I also need to still need to try this
    http://www.oz9aec.net/index.php/gnu-radio-blog/482-a-2-channel-ais-receiver-using-rtl-sdr-and-gnuais

    Any help or suggestions to get RTL SDR dongle to receive AIS on Raspberry pi would be very helpfull!

    Thanks

    Tarquin

    0
    Comment actions Permalink
  • Avatar
    Dimitris Vitoris

    @Tarquin

    It's very difficult to make the RPi decode AIS traffic using a RTL-SDR dongle. In order to do that, gnuradio + gr-ais are required.
    In all our tests here both failed to complile without errors.

    However there is another method of using rtl_fm to tune to one AIS channel and pipe the data to aisdecoder (and then to MT). This
    is rather complicated and untried.

    Let me know if you want me to elaborate.

    0
    Comment actions Permalink
  • Avatar
    Scott C

    Is there a way to edit or delete this support ticket? Issue solved. Thanks.

    0
    Comment actions Permalink
  • Avatar
    Stephen Wilson

    I have a raspberry Pi 2 running with RTL-SDR USB stick successfully feeding AIS to marinetraffic and to my local network. The rough steps (and links to guides are below
    Install RTL SDR on Raspberry Pi and add to blacklist of USB devices http://goo.gl/tXnW13
    Install gnuradio(dev) http://goo.gl/TVogHw
    install gr-ais https://goo.gl/QXXzhO.
    Install and run "kal" " to calibrate the RTL dongle to work out the error value to use in ais_rx http://goo.gl/wbqOts. MY RTL dongle had an error of around minus 33 ppm, and this is the value passed to ais_rx below. replace with your error value. As the dongle warms up this value may change so check again after some time.
    You can then pipe AIS messages to MarineTraffic using "socat" (sudo apt-get install socat) using the command below (where 1.2.3.4:1234 should be changed for your marinetraffic upload IP and port and --error -33 should be changed for your error value obtained from kal
    ais_rx --gain 44 --error -33 -s osmocom | socat - UDP4-DATAGRAM:1.2.3.4:1234
    if you run OpenCPN on a computer on your LAN, you can send the traffic to that at the same time as marinetraffic (assuming your OpenCPN computer is running on LAN 12.168.1.101:9999
    ais_rx --gain 44 --error -33 -s osmocom | tee socat - UDP4-DATAGRAM:1.2.3.4:1234 | socat - UDP4-DATAGRAM:192.168.1.101:9999

    It is fairly processor-intensive on the Pi - 100% of two cores and 75% of the remaining cores.
    I am no raspberry pi expert so optimisations could be made for sure. I'm happy to make my SD card image available to anyone who wants a copy, but I don't have sufficient hosting for the image file

    2
    Comment actions Permalink
  • Avatar
    Alexander Nyberg

    I am also interested of building AIS receiver out of RaspberryPi & RTL-SDR DVB stick.
    I am currently running Flightradar24 in RPi B+ & RTL2832U stick with great success. If it works for ADS-B and MLAT than it should work for AIS.
    @Stephen, can you provide the RPi image? Maybe via dropbox?

    1
    Comment actions Permalink
  • Avatar
    Alejandro

    Hi, if someone make it work please contact me, i have spare space on my servers to save any image of this working.

    contact me chandromqz@gmail.com

    thanks!

    0
    Comment actions Permalink
  • Avatar
    Stephen Wilson

    Alejandro and Alexander Nyburg:
    the SD card image is too large for Dropbox, but I will email Alejandro about his kind offer of hosting the image.
    The image needs a little work to tidy it up for public release (IP addresses and some other software installed are hard coded and specific to my LAN), so please bear with me whilst I make the changes, then I will email Alejandro a link for him to host.
    Steve

    0
    Comment actions Permalink
  • Avatar
    Alejandro

    thanks Steve, if someone wants also space to share image, contact me.

    skype: dedicados
    email: chandromqz@gmail.com

    0
    Comment actions Permalink
  • Avatar
    Stephen Wilson

    I have a working image now for Raspberry Pi 2 and RTL2832/RT820T RTL-SDR USB stick. I will pass it to Alejandro for hosting and he will hopefully post a link here soon when it is available. Instructions have been sent too. Steve

    0
    Comment actions Permalink
  • Avatar
    Harri Kapanen

    I am running a Raspberry Pi 2+ in my sailboat with GPS, dAISY AIS receiver and a 4G cell connection to internet, among other things. I'm muxing different NMEA messages together with kplex and also use it to forward AIS messages (!AIVDM*) to Marine Traffic. However, I'd like to report my own position at the same go (using !AIVDO messages) but my AIS receiver is not aware of its own position and does not generate its own position messages. I'd like to generate them on the RasPi based on the GPS feed but cannot find any existing SW for the task. Essentially mAIS for Raspberry Pi. Anyone stumbled on something like this?

    Thanks,

    Harri

    0
    Comment actions Permalink
  • Avatar
    Grant La Delle

    Hi all, I would like to feed the serial output from my AIS RX to a Pi 2 with a serial to USB converter, for forwarding to MT.

    Could someone please advise the command lines required to achieve this in Raspbian?

    Thanks, Grant.

    0
    Comment actions Permalink
  • Avatar
    Alexander Nyberg

    @ Alejandro Any news on hosting Stephen Wilsons image?

    0
    Comment actions Permalink
  • Avatar
    Stephen Wilson

    I have shrunk the image to fit onto Dropbox. SD card image and instructions now here:
    http://electron-tinker.blogspot.co.uk/2016/06/raspberry-pi-rtl-sdr-ais-marinetraffic.html
    I welcome feedback. Usual disclaimer: I am no expert; this image works for me.

    1
    Comment actions Permalink
  • Avatar
    Alejandro

    hi, here is the image from Stephen Wilson

    http://rasperry.net/download/

    sorry for delay

    0
    Comment actions Permalink
  • Avatar
    Grant La Delle

    Thanks Stephen. What is the cpu usage on your image, and does it scan both channels?

    Have you considered using two dongles, one for each channel? May need to increase USB port current with max_usb_current=1

    Regards, Grant.

    0
    Comment actions Permalink
  • Avatar
    Stephen Wilson

    Hello Grant,
    the image I created receives on both AIS channels simultaneously with just one dongle using 'gr-ais'.
    self._rx_paths = (ais_rx(161.975e6 - 162.0e6, options.rate, "A"),ais_rx(162.025e6 - 162.0e6, options.rate, "B"))
    The two AIS channels fit easily within the receive bandwidth of the RTL-SDR. You could set it to single channel if you wish.

    CPU use on a Raspberry Pi 2 is 100% of two cores, plus around 50% of the other two cores. There is plenty of headroom to run other scripts. The image is meant to run 'headless' without a display, so whether it has enough CPU headroom to run a graphical desktop as well I do not know.

    More info on the image and links to the underlying software used is available on my blog:

    http://electron-tinker.blogspot.co.uk/2016/07/raspberry-pi-sdr-ais-receiver-to.html

    Steve

    1
    Comment actions Permalink
  • Avatar
    Tor Jakobsen

    Thank you all of you.
    I do now have Raspberry Pi 3 up and running with downloaded image. Use dvb-t 820t2. And connect with built in wifi in rp3 to the net.
    Folowed instructions and only thing i had to do extra was to set up wifi.

    Cheers,
    Tor

    0
    Comment actions Permalink
  • Avatar
    Jon Aronsen

    Downloaded the image to my RP3 with a dvb-t FP0012 chip. Calibrated and ran the volk_profile and rebooted. It is sometimes.. registered online but no data is registered on MT (746). Help?

    0
    Comment actions Permalink
  • Avatar
    Jon Aronsen

    746

    0
    Comment actions Permalink
  • Avatar
    Dimitris Vitoris

    @ Jon

    Is the software setup to send the data at 5.9.207.224 port 6066?

    Regards

     

    0
    Comment actions Permalink
  • Avatar
    Jon Aronsen

    5.9.207.224 port 6066 is correct for 746 yes.

    Software set up accordingly.

    0
    Comment actions Permalink
  • Avatar
    Stephen Wilson

    @Jon Aronsen

    I am not familiar with your FP0012 chip and whether this will cause any problems or not. 
    I see MarineTraffic now supply a Raspberry Pi 3 based receiver hardware; perhaps they can share their software and setup?

    Can you try the ais_rx program on its own to see that it receives AIS packets :

    1. log in to your pi via SSH

    2. edit the config file to disable automatic startup:

    sudo nano ~/ais.sh

    change the line to GO=0 to prevent automatic startup

    3. reboot your pi

    sudo reboot

    4. log back in to your pi via SSH

    5. run the command:

    sudo ais_rx --gain 44 --error -43 -s osmocom

    (n.b. replace the error value (-43) with the error for your dongle you got from using the KAL utility as per the instructions https://www.dropbox.com/s/nez9zzmkkcxcky4/Raspberry%20Pi%20RTL-SDR%20AIS%20receiver%2001.pdf?dl=0

    you should hopefully see some information regarding your RTL dongle and then AIS sentences as they are received, e.g.: 

    https://snag.gy/F6wRH3.jpg

    Please try this and let us know if you are receiving AIS sentences or not. If not, then please take a screenshot (Try snag.gy) and post a reply.

    This forum doesn't structure conversations very well. Feel free to discuss further  on my original blog post about the Raspberry Pi image if you prefer:

    http://electron-tinker.blogspot.co.uk/2016/06/raspberry-pi-rtl-sdr-ais-marinetraffic.html

     

     

    0
    Comment actions Permalink
  • Avatar
    Jon Aronsen

    @Stephen Wilson and @Dimitris Vitoris
    Seems that it's producing but not much ais-data...
    https://snag.gy/WdyubT.jpg
    The Fitipower FC0012 is well within fq-range..
    Got it to function under sdr# (airspy) sw on windows without a problem before.
    Antenna ok.

    0
    Comment actions Permalink
  • Avatar
    Stephen Wilson

    @Jon Aronsen,

    Even though you specify Gain 44 in your command line, the dongle is reporting Gain 19. I specify gain 44 on an RT820T2 and get Gain 43 reported by rtl_sdr

    https://snag.gy/F6wRH3.jpg

    I do not know your chip to know whether this is high or low. Can you experiment with gain values to see if this improves your reception? Perhaps leave out the --gain parameter and it will default to auto (mine defaults to 33, but does not receive as many packets), or try

    --gain=192

    The next thing to test is whether the UDP packets are making it off your raspberry pi.

    This will port all the output onto your LAN as a broadcast UDP packet.

    1) see if the packets are available on the pi:

    with the auto-start still disabled, please try the command
    sudo ais_rx --gain 44 --error 33 -s osmocom | tee >(socat - UDP4-DATAGRAM:192.168.1.255:5002,broadcast)

    Open another SSH connection (right-click the top-left icon of the PuTTY window and select "Duplicate Session"), log in then run

    sudo apt-get install ngrep

    sudo ngrep . udp port 5002

    you should see AIS packets being displayed in your second putty window as well as your first, once the first AIS message has been received.

    2) check that traffic is making it off your pi onto your LAN:

    I assume you are running Windows?
    Are you able to install Wireshark and monitor the UDP traffic?

    2a) - using wireshark:
    https://www.wireshark.org/download.html
    You will see UDP packets from your pi on the port 5002. hint: use this filter line:
    udp && ip.addr==192.168.1.188
    (if your pi picks up the same IP address as before)

    2b) - using Packet Sender (Free)

    If you can't run wireshark, then alternatively you can download a utility like
    https://packetsender.com/download
    run this program on your windows computer. Note down the UDP port displayed at the bottom right hand of the Packet Sender window (e.g. 56794) and your Windows computer LAN IP address (e.g. 192.168.1.18)
    then pipe your AIS packets using this command on your pi (replacing your windows PC IP address and the PacketSender port):

    sudo ais_rx --gain 44 --error 33 -s osmocom | tee >(socat - UDP4-DATAGRAM:192.168.1.18:56794)

    where you replace the ip address .18 with your windows PC ip address, and port of that of your Packet Sender UDP box
    you should then see AIS messages coming through on both the Pi and the Packet Sender app
    https://snag.gy/j9PZCq.jpg

    If you see packets on the Pi but not wireshark/ Packet Sender app, then there is probably some filtering on your LAN from your router.

     

     

     

    0
    Comment actions Permalink

Please sign in to leave a comment.