Go Down

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


Looks like you would have two copies of NMEA2000 libraries with different names under your libraries. Search e.g. NMEA2000.h from your libraries and check that it founds only one.


Bonjour Timo,

Well... the NMEA2000 was actually unique.
But the problem was around the libraries directories indeed.
I have erased the previous NMEA2000 directory, then re-downloaded and added the library into the Adruino IDE and the error disappeard.

Merci beaucoup. :)


Bonjour Timo,

I use a MultiDevice Sketch (2 devices: Engine and Battery)  and the problem is that the ProductInformation is not always reliable on the B&G Triton (Menu Parameters/Sources/Engine or Battery).
Most of the time, it does'nt recognise the devices.

I meet different cases:

- No product found: The Triton does not recognise any "Arduino Device", but it is ok for the other regular devices (pilot, VHF, MFD...) (Picture N°1). Off course, it does'nt display anything from the Arduino

- The Device Name is strange, like "???00?????????????POX!..." : In this case, despite a strange name, it is Ok, the Triton displays correct datas coming from the Arduino  (Pictures 2, 3, 5)

- The Device Name is OK: The device name displayed by the Triton is faithful to the name set in the NMEA2000.SetProductInformation. Of course, in this last case, the Triton can display the datas (Pictures 4, 5). Nevertheless I have never had the correct name for 2 devices at the same time.
The best result I have is when the 2 devices have been both recognized with strange names.

I don't change anything in my sketch, and I have to switch on/off several times the whole network and the instuments to get sometime a correct display.

Anyway, the datas (RPM, Voltage, T°) are always correctely send on the network, because the Raymarine devices (A78 MFD and i70) always recieve and display these datas, even if they don't recognise the device's names send by the Arduino.
The trouble is only with the B&G Triton who need to get a device name to be able to display its datas.

I use an Arduino Mega with Canbus Shield who work well when using single-device sketches.



- Do you use interrupt with NMEA2000 library? With interrupts library is more reliable, since it buffers frames on both send and receive side.

- Take care you have big enough buffers. As default with mcp you should have 50 frame buffer, which should be big enough on small systems. You can set buffer sizes on setup() with commands
Call those before calling anything else for library.

- Have you tested without using multidevice system? It is still open for me is it even possible to do NMEA certification with my multidevice support. There is no requirement that device sending different types should act as multi device - specially, if device is just for your own.

Other data will be sent to bus right, since you do it. NMEA 2000 logic and communication requires that you do not loose input frames, which means that it is best to use interrupting and never ever have a delay() in your code. If you use other libraries for sensors, you should also check that they do not have delay or spent do long for reading data. E.g. normal DallasTemperature library in synchronous mode may cause long delays, so that e.g. product information requests will be lost.

Again I prefer to check e.g. Teensy 3.2 or higher - less power consuming, more flash/RAM, faster, smaller layout, better CAN.


Bonjour Timo,

I have clearly understood concerning the Teensy vs Mega. And if I have too much troubles, I will change for a Teensy, who is moreover faster.

As far as I know, I don't use interrupts  neither delay in my sketch.
But it is possible that the libraries I use contain such instruction. I use Freqcount.h.

I also use DallasTemperature.h with the lowest temperature resolution (9 bits, 0,5°C) to get the fastest response (93.75 ms)

I will edit my sketch with the buffer adjustements and try that as soon as I return to the boat.



You have to use DallasTemperature in async. I use it with full 12 bit resolution and max. off time is 10 ms, which is still much - you may get 24 frames on that time. With 93 ms off time othere systems may give up with fast packets.

I have one old one wire code, which I can send you, if you send me personal message. I still use a lot 1-wire, but not with direct pin. Instead I use "DS2482-100 Single-Channel 1-Wire Master" chip to take of most 1-wire communication and i2c_t3c library with Teensy, so that I have 1-wire communication totally interrupt handled.

Freqcount does not cause delays.


 I am  looking for the motor temperature sensor to connect to my axiom 7 via NMEA 2000   i can use external sensor I just need the simple programming script is anyone have it ?


There is example TemperatureMonitor on NMEA2000 library, which sends data to the bus. You just need to add code for temperature sensor you use. If you are going to use 1-wire sensor and Teensy, send me your email by personal message, so I can send you sketch, which sends several different 1-wire sensor values to the bus.


I have an Arduino UNO with a Seeed CANBUS shield (SPI) that does som brute nmea2k transmissions for testing.
Seven nmea2000 messages separated with a 5ms delay. After the seven messages it starts over again after a 100ms delay….
I have checked with an Actisense and it is OK and nmea2000 messages are decoded OK.

Receiver1 is an Adafruit Metro M0 with a Seeed CANBUS shield (SPI). CAN Library from CoryJFowler.

Receiver2 is an Adafruit Huzzah ESP with built in CAN and with an CANBUS transceiver. ESP32 CAN Library from MIWAGNER.

Almost identical code in the receivers except for the Library differens. Both receivers decode OK (checked with Actisense).
BUT... Receiver1 is faster with about 7-9ms between messages and the ESP32 is slower with more than 25ms.

Should't the ESP32 be much faster ??



In my previous message here, when I wrote faster or slower i meant the time as seen on the PCmonitor after "Serial.print".

I have used many "Serial.print" in the code. The same for receiver1 and receiver2.
It turns out that on the ESP32 it is the number of "Serial.print" that slows down the ESP32.

Is there a way to speed up this ?

(Does not seem to be a nmea2000 question…)


(Does not seem to be a nmea2000 question…)
Not really.

Note that NMEA2000 is not that simple. Some MFD:s are happy, if they just get some PGN without knowing anything about the device. So it is possible to just fool and send PGNs with some source e.g. 100 to the bus, and some MFD:s can show it. Some refuses to show data, if they does not get right response for requests to that source. That is what my NMEA 2000 library is for. It handles required communication and you just need to send or handle other PGNs.


Thanks for the reply.
I am not a programmer by profession but enjoy "playing"  with microcontrollers.
So my code is probably "clumsy"...
And I am also a  sailor since 30 years. So the combo nmea/microcontrollers is interesting.
At home, during winter, I have a nmea2000 network running with:
Garmin Echomap GPS Plotter, 12V power, Garmin GND10 bridge between nmea2000 and Nexus bus network, Garmin AIS receiver, Actisense nmea2000 and... my microcontroller with Arduino Ide. The Nexus bus has an Nexus NX server and also Multicontrol instrument.
So it is very close to my sailing boat.
The microcontroller can read the nmea2k data (as far as I have written the code for the usual PGNs).
I can send data and the Garmin GPS Plotter will show the data. Also the GND10 bridge will translate to the Multicontrol instrument, and the NX server translates to nmea0183 OK as well.

If the nmea2000 network only consists of the GPS plotter and an Arduino just listening, the GPSplotter does not send anything.

My initial idea was to have a homebuilt "Race Computer" that has my boats VPP-performance and then displays target boatspeed, actual boatspeed and wind data.

Your nmea2000 library is very professional !!!    It is just that I would like to try learn basics myself.


Hi Timo and thanks for your huge work!

I'm having problem with arduino mega and 2515 can bus shield. I got data shown on NMEA reader correctly but as soon as I commented //NMEA2000.SetDebugMode(tNMEA2000::dm_Actisense); , my code stopped working. The problem is with can shield. Serial monitor informs about problem where "CAN device failed to open".

I found two comments about this problem from this thread but no answer. My shield is on top of arduino mega. Is there some definitions that I should make before Can shield would work?


For Mega that means that there is failure on communicating with CAN controller - the MCP2515 chip on the shield. It may be because of wrong CS pin definition. If it has not been defined, the default CS pin is 53. Check from your shield documentation what CS pin it has and add to your code before including NMEA2000_CAN.h
Code: [Select]
#define N2k_SPI_CS_PIN XX  // Pin for SPI Can Select
where XX is the right CS pin

What shield did you use?


Dec 28, 2018, 07:44 pm Last Edit: Dec 28, 2018, 11:37 pm by hirppa10

I bought one from ebay. (https://www.ebay.com/itm/SPI-MCP2515-EF02037-CAN-BUS-Shield-Controller-communication-speed-high-Arduino/401090806613?epid=863282652&hash=item5d62e00355:g:kSgAAOSwm-Fb~SH-)

I found datasheet from (https://www.elecfreaks.com/estore/can-bus-shield.html) and tried to add code with pin 10 defined as CS but was not able to get communcation with CAN shield.


Did some googling and problem is with mega's pins with this shield. CAN-Shield's TX ja RX strated glowing when I wired shield as following:

However now i'm not able to see any data on NMEA Reader, is this normal?

Commented NMEA2000.SetForwardType(tNMEA2000::fwdt_Text) -> starts to work again. Everything good for now :)

Go Up