Go Down

Topic: NMEA 2000 Shield (Read 380821 times) previous topic - next topic


RPi works fine. There is even commercial product based on RPi and my library.

I have not either done much with RPi, but there is example NMEA2000ToNMEA0183, which I tested on RPi with OpenCPN. I used Code::Blocks GUI environment for which there is project file N2kToNMEA0183.cbp. Unfortunately I have not published full instructions for building up full test environment.

On PRi on important thing to to add loop to some sleeps to allow other threads to run. Otherwise loop will eat lots of resources on core you are running you program.


Thank you for your reply!

I was hoping to test it with the rpi connected to my PC through a USB rs-485 dongle using a Garmin emulator on the PC. Th second option is to buy a new starter set but I still wouldn't have a second device. Suggestions here are welcome. I don't have access to my friends boat (different continent)

I will read the starter doc and see how far I get writing some code and see if I can get stuff to compile

Any examples of your make file would be helpful too if you are willing to share


I do not see any the point of testing it with Garmin Emulator. If you develop NMEA2000 system you have to build to your home test system. Normally it is enough to have my NMEA Simulator and hw for it. With simulator you can simulate devices on bus and also listen bus data. other option is to have some MFD on the bus.

The board I tested had 16MHz chrystal, but your board has only 8MHz chrystal. I have not checked how socketCAN will be setup for RPi and is there any setting for chrystal like in mcp_can driver for Arduinos. If it is not right, it will not work.


Is it possible to run something on my PC and my, to be written, code on the RPI and let them talk to each other without an actual NMEA Bus with devices on it? I looked at NMEA Starter kits but although they would have the wiring and power, they of course still wouldn't have devices on it.

I can see how I can get the code written and running but I am still unsure about the testing.

I didn't see your NMEA Emulator. Can you give me some info on this please?


Yes you can, but then you have to bypass NMEA2000 communication totally.

Check www.kave.fi/Apps


OK, the emulator is running against COM7 which is my RS-485 USB Adapter (CH340 chip)

I see the light blinking on the adapter when the emulator runs.

It looks like I can wire the A & B + Gnd wires to the corresponding A & B + Gnd wires on the RPI Shield. I don't know yet if there is a way to cheat a little and have the RPI + NMEA library talk across the 485 port to the USB adapter + NMEA Emulator on the PC. If this works, I should be able to write the code I want and then at some point, I will have to switch ports to the CAN0 once I connect it to an actual boat.


This does not work. You need NMEA Simulator hw with NMEA Simulator. You can e.g. make own or buy one. Read "How to use.html" file carefully!

Note that protocol send to port from simulator is different (Actisense) than on RPi shield (NMEA2000). NMEA Simulator hw converts Actisense protocol to NMEA2000. Please do not mix things.


Thank you for all your information. It is clear that I need to do a lot more reading before I ask more crazy questions.

I had made the assumption that Actisense was simply a brand implementation of NMEA2000.
I also figured that since the RPI will communicate with the canbus shield through a SPI, that I could use this in between the PC and the RPI. Alas, no go.

The Across Ocean system is a little to rich for my blood as this was just meant to be a little hobby project


As document says you can as alternative make your own Simulator hw - with Teensy 3.2 and tranceiver chip it cost about <30 $


Aug 13, 2020, 01:48 am Last Edit: Aug 13, 2020, 01:49 am by gjunky
I guess to start, I could use the hardware I have as a simulator and run the ActisenseListenerSender on it. This way I could at least get some data from the simulator to show up on my hardware. Once I have that working (I figure it will take some learnings) I can build the Teensy and actually have two devices I can connect. I prefer little steps at a time. I will go try this Friday (traveling tomorrow) and see how far i get


Aug 13, 2020, 10:54 am Last Edit: Aug 13, 2020, 11:05 am by kenobiben
Hi Timo,

can I use the shield to program the actisense EMU instead of the NGT-1 ?

How can I send in the field 127489 enginedynamicparam the discret status 1&2 bit 11 & 12 to send the alarm status of high temp and low oil pressure ?

Have a nice day


Couple updates. Still trying to get my environment to work. I am using netbeans so I can program the RPI remotely. A simple Hello World worked so all communication is working. I can also putty into the RPI

BTW: The can hat I am using seems to have the newer higher rate crystal:
so hopefully this will be ok.

if I run candump can0 - I am getting a "network is down" message. Since it is not hooked up to anything yet, this seems ok and it looks like it at least sees the interface (I hope)

I am now trying to get the ActisenseListenerSender sample to compile

I am getting the following error in my code:
./../NMEA2000-master/src/N2kGroupFunction.h:86:15: error: 'strcmp' was not declared in this scope
I have an #include <cstring> but this doesn't seem to fix it

@pkrekelberg : Do you have any information about the physical wiring between your devices?

My apologies for the NOOB questions. I am hoping once I get past the basics, I can start writing something useful :)


kenobiben: Something happened for my first reply?

Do you mean library? Yes you can program EMU with library, but you should first write program for that. Also you should understand how to use Group Function PGN 126208. What you should program?

Function SetN2kEngineDynamicParam has all parameters and can be used to build message for sending engine dynamic parameters. Check example MessageSender.



I've used a small electronics prototyping breadboard for my bus bar and then stripped back some cat5e cable to connect between devices.  Evently I'll get some M12 micro connectors and joiners. 

Also note you need 120ohm terminators on each end.  Some devices have them builtin, switchable in or require external terminators. your RS485 hat has it installed.  for initial setup there not super important but when you start pushing more data they become very important.

I had the same problem as you with the "N2kGroupFunction.h:86:15: error: 'strcmp' " in the latest copy of the library..  I just added "#include <cstring>" into the N2kGroupFunction.h file after "#define _N2kGroupFunction_H_"

In regards to "candump can0 - I am getting a "network is down" you should get that. the port should just open regardless and site and wait for traffic.  Did you initialise the interface with  "sudo /sbin/ip link set can0 up type can bitrate 250000" ?



Thank you. That got me past the strcmp error and the "network is down" I had forgotten to initialize the can0 port and now the candump patiently waits for traffic :)

I am still having an issue with the stream definition

main.cpp:63:1: error: 'Stream' does not name a type; did you mean 'pread'?
 Stream *ReadStream=&READ_STREAM;

but that looks like I am missing a reference somewhere.

I am still hoping to make this talk to the emulator or maybe I just create a second device

thank you again. I am learning a lot about working with the tools and the RPI

Go Up