Getting data from an arduino to signalk

1,369 views
Skip to first unread message

Paddy Burnside

unread,
Feb 15, 2016, 9:47:00 AM2/15/16
to Signal K
Hi, relative newbie here, I have an arduino feeding data through a serial connection into a Raspberry pi running openplotter/signalk on a sailing boat.
So far the arduino is sending out nmea wind data which works OK, it shows up on the sailgauge/instrument panel pages on a tablet.A test with gps worked fine as well, just echoing the nmea sentences. 
So how to I get engine data to signalk from the arduino -  RPM & 2 x temp measurements. Also, I'd like to have battery voltage as well.
I can't seem to get anything using the NMEA XDR sentence.
Is there a method of tranfering data without using NMEA 0183? 

Any pointers much appreciated.

TIA

Paddy

Emile Cantin

unread,
Feb 15, 2016, 10:54:30 AM2/15/16
to Signal K
Hi Paddy,

I'm currently in the process of doing something similar. My boat doesn't have much in the way of electronics, so I'm building a system from scratch with an Arduino, a Raspberry Pi and SignalK. I skipped the whole NMEA thing, and I have my Arduino send me the readings directly over the serial port. I have written a small program (https://github.com/emilecantin/arduino-signalk) that takes these readings and outputs SignalK data. I get these into the SignalK server with the following configuration:

...
"pipedProviders": [{
"id": "arduino-signalk",
"pipeElements": [{
"type": "providers/execute",
"options": {
"command": "node ../arduino-signalk/index.js"
}
}, {
"type": "providers/liner"
}, {
"type": "providers/from_json"
}]
}],
...

I'm still in the process of building all this, and it's not really documented yet, but I'm planning on doing a nice write-up of all this when I'm done, which should be around spring.

For my sensors, I've just ordered a bunch of cheap ones from AliExpress (voltage and current sensors are around $1, and there are many other as well), I'm still waiting to receive them (free shipping from China, so you have to be patient).

Hope this answers your questions!

Emile


--
You received this message because you are subscribed to the Google Groups "Signal K" group.
To unsubscribe from this group and stop receiving emails from it, send an email to signalk+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Teppo Kurki

unread,
Feb 15, 2016, 2:16:41 PM2/15/16
to signalk
On Mon, Feb 15, 2016 at 5:54 PM, Emile Cantin <emile...@gmail.com> wrote:
I skipped the whole NMEA thing, and I have my Arduino send me the readings directly over the serial port.

This is the advice I would have for Paddy as well. Unless you need NMEA0183 output for something (like streaming to Apps) it is a lot more efficient to just parse line oriented Signal K delta coming from the Arduino. 

There's also SK to NMEA0183 naive proof of concept brewing in a branch in case anybody's interested.


I have written a small program (https://github.com/emilecantin/arduino-signalk) that takes these readings and outputs SignalK data. I get these into the SignalK server with the following configuration:
"pipedProviders": [{

"id": "arduino-signalk",
"pipeElements": [{
"type": "providers/execute",
"options": {
"command": "node ../arduino-signalk/index.js"

On a single core CPU it makes more sense to run JavaScript providers embedded in the server instead of forking a separate process for that purpose. This way you'll have only one Node process & heap.

I just merged Fabian's serialport provider that does pretty much the same thing as your separate process does. I haven't used it myself, but as far as I understand it works. I figured it would be easier to  find & use in the master.

See 

Paddy Burnside

unread,
Feb 15, 2016, 3:48:40 PM2/15/16
to Signal K, t...@iki.fi
Thanks guys, jeez i have a lot to learn :)
So forgive me, I can get round programming the arduino but so much of this is brand new.
So I think right now 2 (3) things I need to learn:
  • find out the exact format of " line oriented Signal K delta" that the arduino needs to send. (from here? - http://signalk.org/specification.html )
  • Make sure signalk gets that data from dev/tty/acm0, I'm not sure openplotter passes on non nmea data.  ( Edit volare-serial-settings.json ?)
  • What else do i need to learn?
Thanks for your help, I need it :)

Paddy

Teppo Kurki

unread,
Feb 16, 2016, 1:15:01 AM2/16/16
to signalk

By "line oriented" I meant that the receiving end needs to know when it has received a complete delta JSON message to start parsing and handling it. The simplest way to do it is to send one message per line. 
 

Adam

unread,
Feb 17, 2016, 4:30:36 PM2/17/16
to Signal K
Emile,

Please keep us posted when you get this working.  I'd like to send rudder reference data directly from an Arduino to iKommunicate using Signal K deltas.  I plan to write a second how to guide, once that is done.  I'm not an Arduino programmer so I'm going to have to rely on people like you for the how to.

My current project to show rudder position: http://www.signalkool.com/p/blog-page_4.html

Cheers, Adam

Teppo Kurki

unread,
Feb 18, 2016, 1:39:40 PM2/18/16
to sig...@googlegroups.com
How about a "how to set up a SK server on a RPi with a wifi hotspot" blog entry? I think that kind of a story would find an audience.

Emile Cantin

unread,
Feb 18, 2016, 2:03:09 PM2/18/16
to sig...@googlegroups.com
That's definitely something I'm planning to do! However, It's gonna have to wait until I receive my sensors, which should be in about a month.

Teppo Kurki

unread,
Feb 18, 2016, 2:06:54 PM2/18/16
to sig...@googlegroups.com
Well, in the meantime write a tutorial on just the server & hotspot?

Emile Cantin

unread,
Feb 18, 2016, 2:08:12 PM2/18/16
to sig...@googlegroups.com
I'll see what I can do :-)

Adam

unread,
Feb 18, 2016, 3:05:47 PM2/18/16
to Signal K, t...@iki.fi
I'd be happy to host that and help organize the info but I'd need to get the tutorial first.
To unsubscribe from this group and stop receiving emails from it, send an email to signalk+unsubscribe@googlegroups.com.

Jeremy Boynes

unread,
Feb 18, 2016, 4:23:33 PM2/18/16
to sig...@googlegroups.com, t...@iki.fi
I'm in the process[1] of doing this with the Java server using a Raymarine NMEA0183 gateway, a RPi, and a hotspot. Happy to share notes. 

Jeremy

[1] in process meaning I went to the boat to do this last weekend and ended up swapping the bilge pump instead. I should get to it this week. 

Emile Cantin

unread,
Feb 19, 2016, 11:35:13 AM2/19/16
to sig...@googlegroups.com, t...@iki.fi
I've decided to make this a multi-part series; it's a lot less daunting that way :-). So, here is part 1, getting the SignalK server running on the Pi: http://blog.emilecantin.com/web/sysadmin/iot/javascript/sailing/2016/02/19/arduino-signalk-part-1.html

Emile

Teppo Kurki

unread,
Feb 19, 2016, 4:58:49 PM2/19/16
to sig...@googlegroups.com
Wow, that was way quicker than I expected! 

I have yet to use nvm on the Pi. With minimal netinst there is probably no previous clashing node that isn't node js to uninstall? I really should redo all my RPi cards and add stuff like udev rules with ansible.

Looking forward to the next installation!!
Message has been deleted

Paddy Burnside

unread,
Feb 20, 2016, 4:40:23 AM2/20/16
to Signal K
Hi Emile,
  i wonder if you could briefly explain just what i do with the below when you have a moment. I'm stumbling around in the dark a bit, and it does sound exactly what I'm looking for.

So story so far...
On a RPI2 running openplotter..https://github.com/sailoog/openplotter

  • pasted the "piped providers...."    below into /home/pi/.config/signalk-server-node/settings/openplotter-settings.json
  • copied index.js & package.json to /home/pi/.config/signalk-server-node/arduino-signalk/index.js - edited /dev/ttyACM0 & baudrate to match arduino
  • cat /dev/ttyACM0 showing analog2:255 analog3:255 etc
  • restarted signalk server
No engine data showing in http://192.168.43.75:3000/examples/consumer-example.html , GPS data is showing.

Any pointers very much appreciated! 

Thanks

Paddy

Teppo Kurki

unread,
Feb 20, 2016, 4:57:57 AM2/20/16
to sig...@googlegroups.com
How about taking more detailed support stuff to Slack #support channel? More convenient in chat format.

Emile Cantin

unread,
Mar 19, 2016, 9:07:24 AM3/19/16
to sig...@googlegroups.com
This took me a bit longer than I thought, but here it is: Part 2, getting the Arduino and the SignalK server talking together: http://blog.emilecantin.com/web/sysadmin/iot/javascript/sailing/2016/03/19/arduino-signalk-part-2.html

Happy reading!

Emile

Adam

unread,
Mar 19, 2016, 4:12:59 PM3/19/16
to Signal K
Emile,

Thanks for writing that up. Sorry if this is a dumb question but I'm assuming you connected the arduino uno? to the Pi via a usb cable?  Are you powering the arduino that way as well?  Could this be adapted somehow for the iKommunicate when it eventually allows bi-directional communication? I'm assuming a different sketch would have to be written for the ethernet shield because the iKommunicate doesn't have a serial port.


Cheers, Adam
To unsubscribe from this group and stop receiving emails from it, send an email to signalk+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Teppo Kurki

unread,
Mar 20, 2016, 4:59:18 AM3/20/16
to signalk
Thanks Emile for a really, really nice post, including the  explanation of how the node server configuration and pipedproviders work!

On Sat, Mar 19, 2016 at 10:12 PM, Adam <ad...@signalkool.com> wrote:
Thanks for writing that up. Sorry if this is a dumb question but I'm assuming you connected the arduino uno? to the Pi via a usb cable?  Are you powering the arduino that way as well?  Could this be adapted somehow for the iKommunicate when it eventually allows bi-directional communication? I'm assuming a different sketch would have to be written for the ethernet shield because the iKommunicate doesn't have a serial port.

Another approach would be to use the SK node server as an intermediary. I have some code in a branch that allows SK node server to discover & connect to iK, to use iK as a provider and restream/aggregate all that data. If one would want to add some functionalities, for example updating squidd.io or eboatcards periodically, that piece of logic could run in the SK node server and iK would act as the gateway  0183/n2k land to the world of SK.

Taking this a step further SK node server could write its local input from Arduino/i2c/spi connected sensors in SK to iK, which eventually would convert that data to the appropriate pgns. 

This area is complex, for example if you get a  only COG update and you have maybe stale SOG how do you populate COGSOG pgn?

What we have specs & working software for is streaming data from 0183/n2k to SK. The other direction is still pretty uncharted territory.

There is also a naive implementation of SK to nmea0183 mapping in a branch of node server. It has the same state management / message construction problem of "when do I fire the sentence when I'm getting data from multiple, independent sources for the sentence" unsolved. Not that it is unsolvable, just more complex than converting to SK, that has a lot less rigid message granularity.
Reply all
Reply to author
Forward
0 new messages