Skip to content

signalk connections

marcobergman edited this page Jul 7, 2023 · 5 revisions

WORK IN PROGRESS JUL-2023

Signalk zeroconf

The modern way of interfacing pypilot to signalk, is to have pypilot connect to signalk instead . This was introduced in March 2020 (v0.21) and it does require a recent version of pypilot; the tests here were done with v0.24. From a technical point of view, this method is exquisite: there is no senseless up-and-down sending of nmea messages to the whole world - no - there is one operational data store of nautical data, and as a client, you subscribe to updates of only the data you need.

This signalk connection works with a zero configuration mechanism: pypilot will find the signalk server all by itself by issuing a 'service discovery request' onto the network. Some agent (more on that later) answers pypilot with the address of signalk, and then pypilot connects to signalk on that address. Pypilot will then issue an Access Request into signalk, and when you approve that request manually in signalk, a permanent connection is established.

This requires some things to be set up, which are not there by default.

On openplotter, you need to install a few packages:

sudo pip3 install zeroconf
sudo apt install python3-zeroconf python3-websocket

How would you know that? If you run pypilot at the prompt and read the output line by line, it's there. This is the only way to troubleshoot this type of issues.

When you start pypilot, you will then see that pypilot is able to put out a service request for signalk:

signalk zeroconf service add myrouter._http._tcp.local. _http._tcp.local.

If there is no-one to answer that service request, nothing happens. The agent that should answer, is an mdns server: 'multicast dns service discovery'. This service is normally not available on your network, but it is provided by signalk, if you have Server->Settings->mdns checked. Remember you need to restart the SignalK server for this.

With mdns on, your pypilot server will find signalk:

signalk server found 10.10.10.1:3000

When pypilot connects to signalk (through the web service at 3000/signalk) it finds itself unauthorized, and therefor posts an access request (requestId).

signalk probe... 10.10.10.1:3000
signalk found ws://10.10.10.1:3000/signalk/v1/stream?subscribe=none
signak failed to connect Handshake status 401 Unauthorized
signalk post {'state': 'PENDING', 'requestId': '384b3471-9e76-401c-a663-c84f2fc30cad', 'statusCode': 202, 'href': '/signalk/v1/requests/384b3471-9e76-401c-a663-c84f2fc30cad', 'ip': '::ffff:10.10.10.1'}
signalk request access url http://10.10.10.1:3000/signalk/v1/requests/384b3471-9e76-401c-a663-c84f2fc30cad
signalk see if token is ready http://10.10.10.1:3000/signalk/v1/requests/384b3471-9e76-401c-a663-c84f2fc30cad {'state': 'PENDING', 'requestId': '384b3471-9e76-401c-a663-c84f2fc30cad', 'statusCode': 202, 'href': '/signalk/v1/requests/384b3471-9e76-401c-a663-c84f2fc30cad', 'ip': '::ffff:10.10.10.1'}

In signalK, you will see this access request showing up under the Security menu. When approving, you should set the permissions to Read/Write, otherwise pypilot still cannot write its measurements into signalk. Upon periodically polling ('see if token is ready'), pypilot will receive a security token and is able to make the connection:

signalk received token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXZpY2UiOiJweXBpbG90LTg4NzQ2NDg3OTQ4IiwiaWF0IjoxNjE2MTQ2NTMzLCJleHAiOjE2NDc3MDQxMzN9.KSADIUWyEYKB9Go4_kltxidwb8fIj_u9EwI6mlyh_RI
signalk connected to ws://10.10.10.1:3000/signalk/v1/stream?subscribe=none

From that point on, you will also find navigation.attitude in your signalk data browser.


This pypilot initiated signalk connection should be able to replace all nautical data interchange with pypilot: you should not need to send NMEA wind, track, gps data to pypilot anymore. When this connection works, port 20220 is obsolete.

So in short, to get signalk zeroconf working:

  • install packages
  • switch on mdns
  • approve access request, read-write

With regard to heel and pitch, these readings are affected by the compass heading offset that is set in the compass calibration screen. See https://forum.openmarine.net/showthread.php?tid=2946&pid=17922#pid17922. This effect makes the usability of pitch and heel somewhat non-universal.


Step 14: The Pypilot Motor Controller >>>

Clone this wiki locally