November 04, 2023

AIS for Raspberry with Map, Dispatcher

Updated 2023-11-04, OK with Bookworm 32 bit !
Not Bookworm 64 Bit !

This is a setup, on a Raspberry Pi(RPi), with a software package, AIS Dispatcher, from http://www.aishub.net which includes
  • receiving and processing of all standard AIS messages
  • streaming raw AIS feeds to multiple destinations
  • advanced monitoring of device status, coverage and message statistics
  • embedded electronic map with all received vessels
The best AIS application ? is found here !

Introduction
An alternative application, OK with Bookworm 32/64 bit, could be the SW package AIS receiver with OpenSeaMap where you also can see AtoN:s, buoys and beacons. There are also plugins available for AIS forwarding.

On the same RPi I have installed;
  • AIS dispatcher application
  • RTL-SDR dongle, approx 30 €, or the even better NooElec NESDR Nano 3as the AIS receiver
  • An application with 2 channel support which is interfacing the dongle, decoding the information, and sending NMEA 0183(N1) data to AIS dispatcher
Starting fresh ?
The applications needs a computer running Linux and if you want to start from scratch, with a RPi, here is a how to.

Installation of 
AIS Dispatcher
Follow the instructions where the installation is ending with 

........

........

Install complete

By default web interface is accessible at http://IPADDRESS:8080/

To change default listening host/port check "/home/ais/etc/aiscontrol.cfg"

To disable auto start execute "loginctl disable-linger ais"


:: Available IP Addresses

eth0             DOWN           

wlan0            UP             192.168.68.110/24 



Application for the RTL-SDR
Alternative 1
A software package, recommended, which is used by OpenPlotter is found here.

Alternative 2(Note !! this app is not available anymore) 
An older package, which is working well is aisdeco2.

Install some dependences for the aisdeco2 software, with


$ sudo apt-get install librtlsdr-dev


In this download You will get a readme file with info about the package

Copy the "aisdeco2" file to the RPi, with the hostname "rpiais". On a Mac with following command which will put the file in pi home folder

$ scp aisdeco2 pi@rpiais:

In a ssh session on the RPi issue the command

$ sudo mv aisdeco2 /usr/local/bin

which will move the program to the right place. 

Plugin the RTL-SDR dongle, with a connected antenna, to the RPi and then the command 

$ sudo aisdeco2 --udp 127.0.0.1:10110

which will show something like 

2019-01-26 19:15:38.303  INFO     AiSDeco2 v.20180430
Found Rafael Micro R820T tuner
[R82XX] PLL not locked!
Supported Gains (dB):.. 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
Freq: 162.000 MHz
Freq Correction: 0 ppm
Gain: Auto
2019-01-26 19:16:16.383  INFO     !AIVDM,1,1,,A,13o1h>00280qdj:P61hdBqpR0D2?,0*60

The "--udp 127.0.0.1:10110" in the command line means that the N1 output should be sent  as UDP from local host, IP  127.0.0.1, on port 10110.

The last line is an AIS N1 output "!AIVDM,1,1,,A,13o1......."

Let the program run

AIS Dispatcher configuration
Open the GUI and complete the configuration with "Input" according to the picture and the rest according to Your setup.

If the aisdeco2 program is listing any N1 messages the vessels should appear in the GUI map. See above picture.


Dispatcher
One purpose with the AIS dispatcher software is to dispatch, send, AIS information to Vessel tracking sites like
If You do this You probably will get an "Premium" account and can retrieve information from the sites. Sign up and You will get a web address and a port number which will be used in the AIS Dispatcher "Configuration => Output"

Another way using this software could be installing it on a Raspberry Pi Zero W and use it as a standalone AIS receiver/dispatcher on Your boat or at home. As a source for maybe
Adding an output in AIS Dispatcher with UDP output, port 10001, and host IP/name to Your iPhone/iPad, with iSailor installed, the setup will be as enclosed picture.

Remarks
Monitor failure
In this post I built an application that sends an alert if no AIS message haven't appeared within a certain time.

Improve receiving range?

UDP as input
Using UDP as input gave me problem specifying the specific IP adress, but using IP "0.0.0.0" made it work ?

Old rPiAIS
This post was initially written for the older software rPiAIS, which didn't work with RPi 4, but updated for the mentioned AIS dispatcher. (The GUI is almost the same)

32 comments:

  1. Hello there...

    I follow the instruction but can't make it...

    pi@rPiAIS:~ $ sudo mv aisdeco2 /usr/local/bin
    pi@rPiAIS:~ $ ls
    pi@rPiAIS:~ $ sudo aisdeco2 --gain 49.6 --udp 127.0.0.1:10110
    sudo: aisdeco2: command not found
    pi@rPiAIS:~ $ cd /usr/local/bin
    pi@rPiAIS:/usr/local/bin $ ls
    aisdeco2
    pi@rPiAIS:/usr/local/bin $cd
    pi@rPiAIS:~ $ sudo aisdeco2 --gain 49.6 --udp 127.0.0.1:10110
    sudo: aisdeco2: command not found

    I have no idea on how to run the aisdeco2. Please advise.

    Regards.

    ReplyDelete
    Replies

    1. Hi ! Seems that the RPi don't think it is a program? If You fetch the aisdeco2 again and try to execute it in the pi home catalog ? Just aisdeco2, nothing else.
      Another way is to use the receiver program in this post https://pysselilivet.blogspot.com/2018/06/ais-reciever-for-raspberry.html Here You compile the program on the RPi, so it cant go wrong.

      Delete
    2. Hi Pyssel i livet,
      I did use the rtl-ais and it can work when run the command, checked with rpiais status page, there are lots of invalid messages and no boats / ships / vessels shown in the map. What should I do next?
      Thanks.

      Delete


    3. pi@rPiAIS:~ $ sudo systemctl status ais
      ● ais.service - AIS
      Loaded: loaded (/etc/systemd/system/ais.service; enabled; vendor preset: enabled)
      Active: active (running) since Tue 2019-02-26 22:17:38 UTC; 3min 4s ago
      Main PID: 8803 (rtl_ais)
      CGroup: /system.slice/ais.service
      └─8803 /home/pi/rtl-ais/rtl_ais -p 0 -R on -n

      Feb 26 22:19:42 rPiAIS rtl_ais[8803]: !AIVDM,1,1,,A,4055od1v<eFCb8Cv=d3LtVA000S:,0*41
      Feb 26 22:19:49 rPiAIS rtl_ais[8803]: !AIVDM,1,1,,B,D055od0nPNfqMhN01E8f01KHf00,0*18
      Feb 26 22:19:54 rPiAIS rtl_ais[8803]: !AIVDM,1,1,,A,D055od0D<NfpfpN0178f01=Hf00,0*6B
      Feb 26 22:20:03 rPiAIS rtl_ais[8803]: !AIVDM,1,1,,A,4055od1v<eFD28Cv=h3LtV1000S:,0*6A
      Feb 26 22:20:09 rPiAIS rtl_ais[8803]: !AIVDM,1,1,,B,D055od0v`f014pf000,0*09
      Feb 26 22:20:14 rPiAIS rtl_ais[8803]: !AIVDM,1,1,,A,D055od0h`f00npf000,0*4F
      Feb 26 22:20:29 rPiAIS rtl_ais[8803]: !AIVDM,1,1,,B,D055od1UHNfp00N0240f02:@f00,0*1E
      Feb 26 22:20:33 rPiAIS rtl_ais[8803]: !AIVDM,1,1,,B,4055od1v<eFDP8Cv=j3LtUQ00HCC,0*7B
      Feb 26 22:20:34 rPiAIS rtl_ais[8803]: !AIVDM,1,1,,A,D055od134NfqMhN01n0f01t@f00,0*37
      Feb 26 22:20:43 rPiAIS rtl_ais[8803]: !AIVDM,1,1,,A,4055od1v<eFDb8Cv=l3LtUQ00<2R,0*58

      Delete
    4. Nice the receiver part is working ! Just a very small portion, less than 1 %, should be invalid. Are there any message Type 1 ?

      Delete
    5. Hi,
      This is the screenshot
      https://ibb.co/r72z6nW

      Delete
    6. OK. But during 12 minutes You have received 12 MSG1 which should show in the Map ?

      Delete
    7. Hi,

      It works but not much ships / vessels /boats shown in the map. Thanks for the help.

      Delete
    8. The error about command not found is fixed changing to 755 permision on file.

      Delete
    9. Thanks for Your remark, but wouldn't "sudo" solve any authority problem ?

      Delete
    10. Regarding 'sudo: aisdeco2: command not found' you need to make aisdeco2 executable, run: 'sudo chmod +x aisdeco2'

      Delete
    11. Thx ! What OS are You running ?

      Delete
    12. Hi, thanks for this detailed post about AIS and Rpi!
      I'm using windows running PuTTY to access the pi. I transfered the file with ftp.
      However it didn't work for me on an old Rpi1 that I had around, giving me the output "illegal operation" when running aisdeco2.
      I've sourced a previous version, aisdeco from github which would run but not work correctly.. I ended up compiling rtl-ais me too...

      I wasn't able to receive any signals though, although the system seems to run fine, not many big ships around my area..
      I'll check with a newer pi model to see if I can get better results...

      Delete
    13. Thx. Please check antenna and calibrate. https://pysselilivet.blogspot.com/2019/08/sdr-calibrate-with-kalibrate-rtl.html

      If You really want to download, aisdeco2, direct to Your RPi use

      wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1B1O2cseigoGNRFzP9Ii3a2QZq_uBSJmP' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1B1O2cseigoGNRFzP9Ii3a2QZq_uBSJmP" -O aisdeco2_rpi2-3_deb9_20180430.tgz && rm -rf /tmp/cookies.txt

      and then

      tar zxvf aisdeco2_rpi2-3_deb9_20180430.tgz

      but it seems that rtl-ais is a little better program

      Delete
  2. Did a Google ;-) Check with: $ file aisdeco2
    aisdeco2: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=bc5e257d36fae892d47d5e547b8f72932b118791, stripped

    ReplyDelete
  3. Do you have any idea how to fix the rPiAIS network issue?

    It will failed in network routing almost after 24 hours of operation...

    Is it possible to disable / remove the auto route to 172.16.32.254 on eth0, which I need only my own router 192.168.1.x and I suspect the network configuration has bugs on it...

    Every time when the rPiAIS runs more than 24 hours, the pi eth0 / wlan0 will disconnected from the network and cannot access it anyway...

    Unplugged and then re-plugged also useless... Have to keep it off for certain time then can connected to the network.

    Thanks again.

    IDX LINK TYPE OPERATIONAL SETUP
    1 lo loopback carrier unmanaged
    2 eth0 ether routable configured
    3 wlan0 wlan off unmanaged

    ● State: routable
    Address: 172.16.32.254 on eth0
    192.168.1.159 on eth0

    ReplyDelete
    Replies
    1. I’m just using the WiFi and don’t have any problems. Since it is not open source I don’t know how the setup is done. Please contact the AISHub guys.

      Delete
    2. Have you configured the aisdispatcher for automatic updates ? Current version as today 27 October 2019 is 1.3 - you can see the version of aisdispacther at the bottom ledt side of the window when using the web interface. -When installing from the downloaded image file , it will be version 1.1 witc had the same buggy behavior for me. After automtoc updates to 1.2 and now 1.3 is seems to be stable.

      Delete
    3. you should choose IP addresses which are not in use; ideally outside the range used by your DHCP server, within the same sub-network.

      dhcpcd method

      Leave /etc/network/interfaces at its default (as above).

      Edit /etc/dhcpcd.conf as follows:-

      Here is an example which configures a static address, routes and dns.
      interface eth0
      static ip_address=10.1.1.30/24
      static routers=10.1.1.1
      static domain_name_servers=10.1.1.1

      interface wlan0
      static ip_address=10.1.1.31/24
      static routers=10.1.1.1
      static domain_name_servers=10.1.1.1

      ip_address is the address and size from the command above (or another unused address on the same network), routers is the address of your router (or gateway). domain_name_servers is the DNS address(es) from /etc/resolv.conf. (see man dhcpcd.conf)

      Delete
    4. A new post, OpenSource app, with the better OpenSeaMap is available https://pysselilivet.blogspot.com/2019/10/ais-receiver-with-openseamap.html Then You can setup the network interfaces as You want.

      Delete
  4. Hi, works great!! sending my output to aishub.net, i am station 3159.
    i would like to do a check on my rtl-sdr-stick, but do i need to load additional software for this? ( to do rtl_sdr test)
    thanks in advance

    ReplyDelete
    Replies
    1. Thanks. With this software package the statistics page with counting received messages seems good enough for having control ?

      Delete
    2. Is it possible to stream to multiple udp-addresses? adding an extra addresses in aisdeco2.service is failing, or can I run ais dispatcher on the same RPI??

      Delete
    3. Absolutely! Assuming you are using rPiAIS you just add another output. "Configuration => Output"

      Delete
    4. Made it so, thanks! found dispatcher already running.

      Delete
  5. Pyssel, is it neccessary to put the frequency in detail? trying to do that was failing on starting my service, I thought it might be needed to see different classes of AIS A- or B-class, thanks in advance.

    ReplyDelete
    Replies
    1. The only time I use something concerning frequency is after a calibration when you fine-tune the RTL-SDR. Check post https://pysselilivet.blogspot.com/2019/08/sdr-calibrate-with-kalibrate-rtl.html Both class A and B are using the same frequency.

      Delete
  6. Hi ! can you please help me to identify this problem:
    when I type "" sudo aisdeco2 --udp 127.0.01:10110 "" , in the Raspberry Pi terminal, I receive this :
    """"""""""""
    2021-04-14 12:57:20.611 INFO AiSDeco2 v.20180430
    Detached kernel driver
    Found Rafael Micro R820T tuner
    [R82XX] PLL not locked!
    Supported Gains (dB): 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
    Freq: 162.000 MHz
    Freq Correction: 0 ppm
    Gain: Auto
    Allocating 16 zero-copy buffers
    """"""""""
    so ?

    ReplyDelete
    Replies
    1. Seems OK compared to my documentation? Would anyhow recommend my other post with 2 channel AIS receiver.

      Delete
    2. thank you for your repliy, actually, it works now, it was just because of the place of my antenna.
      anyway you are recommending your other post, I'm so curious to try it, is it ""AIS receiver with OpenSeaMap"" you are talking about ?

      thank you again for your posts, they are so interesting!

      Delete
    3. Nice it worked! Yes I like the OpenSeaMap chart with buoys and the receiver https://pysselilivet.blogspot.com/2020/05/ais-reciever-for-raspberry-pi-2-channel.html

      Delete

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !