NMEA 2000 Shield

Hi Timo and others

Firstly, a huge thank you to Timo for developing this excellent resource and making it available to all. It is great fun being able to develop my own devices and realise there is no limit to what can be done other than my limited but growing knowledge of coding.

I have successfully implemented the temperature monitor and that talks to my N2k bus nicely. However, I am having a little trouble getting a thermocouple to work (using a Max31855). At this stage I am just running trials with a Teensy 3.2 on my PC without a can tranceiver connected. After a few seconds of seeing pgn's appear on the serial monitor in the IDE it then just says 'send failed'. Am I doing something wrong in my code or is this some kind of buffer problem because I don't have a tranceiver connected yet?

CAN device ready
Start address claim for device 0
5600 : Pri:6 PGN:60928 Source:22 Dest:255 Len:8 Data:24,15,C3,FF,0,82,96,C0
5851 : Pri:7 PGN:126993 Source:22 Dest:255 Len:8 Data:60,EA,0,FF,FF,FF,FF,FF
8602 : Pri:5 PGN:130312 Source:22 Dest:255 Len:8 Data:1,1,3,B3,6A,FF,FF,FF
8603 : Pri:5 PGN:130311 Source:22 Dest:255 Len:8 Data:1,C3,B3,6A,FF,7F,FF,FF
11603 : Pri:5 PGN:130312 Source:22 Dest:255 Len:8 Data:1,1,3,B3,6A,FF,FF,FF
11604 : Pri:5 PGN:130311 Source:22 Dest:255 Len:8 Data:1,C3,B3,6A,FF,7F,FF,FF
14604 : Pri:5 PGN:130312 Source:22 Dest:255 Len:8 Data:1,1,3,B3,6A,FF,FF,FF
PGN 130311 send failed
14605 : Pri:5 PGN:130311 Source:22 Dest:255 Len:8 Data:1,C3,B3,6A,FF,7F,FF,FF
PGN 130312 send failed
17605 : Pri:5 PGN:130312 Source:22 Dest:255 Len:8 Data:1,1,3,B3,6A,FF,FF,FF
PGN 130311 send failed
17606 : Pri:5 PGN:130311 Source:22 Dest:255 Len:8 Data:1,C3,B3,6A,FF,7F,FF,FF

Code attached

Keith

N2K_max31855_temp_2018.ino (3.44 KB)

Thanks.

The send fails, if you do not have it connected to the bus. Actually it should be enough to have one terminator resistor on tranceiver, but I have not tested. You do not get error message immediately, since if buffers some messages and when buffer comes full, error starts to appear.

Hi to all, thank you Timo for your work.
I m a beginners, but i wold you like to send some data from my ESP32 to N2k network.
I bought one NGT-1 usb gateway, to verify the data trasmitted from my ESP32.
I follow your guide, and i see temperature reading to NMEA reader via serial.
The next step is connect ESP32 to N2K network and read data from my ngt-1.
I connect GPIO4 and GPIO16 to MCP2562 pin 1 and 4 like this schema:
https://github.com/ttlappalainen/NMEA2000/blob/master/Documents/ArduinoDUE_CAN_with_MCP2562.pdf
But i cant read data in NMEA reder via NGT-1.
Where is the error?

Thank You

Emiliano

With quick look your connections seem to be OK, except I could not see is NGT-1 powered on NMEA 2000 side? You have to feed 12V to NMEA2000 bus, otherwice NGT-1 tranceivers will not get powered and it will not listen/send anything.

On NMEA Reader you can also allow NGT-1 to receive all data. Select Edit-Preferences...-"Transfer: Receive all"

Ouch!!!
Thank You Timo, il try to feed 12v.

:slight_smile:

Edit:
All work fine!!!!
Thank You Timo

An other question....
I have two engine, and i send the flow fuel rate of each engine to NGT-1.

engine0---> 56 l/h
engine1---> 23 l/h

This is my code:

SetN2kEngineDynamicParam(N2kMsg,0,N2kDoubleNA,N2kDoubleNA,N2kDoubleNA,N2kDoubleNA,Engine0Flow(),N2kDoubleNA,N2kDoubleNA,N2kDoubleNA,N2kInt8NA,N2kInt8NA,true);
NMEA2000.SendMsg(N2kMsg);
SetN2kEngineDynamicParam(N2kMsg,0,N2kDoubleNA,N2kDoubleNA,N2kDoubleNA,N2kDoubleNA,Engine1Flow(),N2kDoubleNA,N2kDoubleNA,N2kDoubleNA,N2kInt8NA,N2kInt8NA,true);
NMEA2000.SendMsg(N2kMsg);

Why in NMEA Reader i see

Engine0 ---> Fuel rate 0,0560 Cubic Metres Per Hour

Engine1 ---> Fuel rate 0,0230 Cubic Metres Per Hour

In N2kMessages.h declar:
//*****************************************************************************
// Engine parameters dynamic
// Input:
// - EngineInstance Engine instance.
// - EngineOilPress in Pascal
// - EngineOilTemp in Kelvin
// - EngineCoolantTemp in Kelvin
// - AltenatorVoltage in Voltage
// - FuelRate in litres/hour
// - EngineHours in seconds
// - EngineCoolantPress in Pascal
// - EngineFuelPress in Pascal
// - EngineLoad in %
// - EngineTorque in %
// Output:
// - N2kMsg NMEA2000 message ready to be send.

Thank You

Emiliano

This is the way how Actisence shows it and which actually has been better unit for library interface too, since it is SI. Note that 0,0560 m3/h = 56 l/h.

Note also that you should use SetN2kEngineDynamicParam(N2kMsg,1,... for engine instance 1. Otherwise value for engine instance 0 is just jumping between instance values (56 / 23 ).

But, when i ll connect my esp32 to the nmea network, a garmin or raymarine display what will show?

L/H or m3/h?

And i need to trasform 0,560 in 56?
Example:

lh1 = lh1*1000;

Thank YOU.

On sending by library function you have to use value in l/h. I would expect that on Raymarine or Garmin you can choose the unit.

Hi I have successfully set up a teensy32 with CAN http://skpang.co.uk/catalog/teensy-canbus-breakout-board-include-teensy-32-p-1507.html and am using MessageSender.ino to interface to a Raymarine E70077 MFD (A-Series).

All the code worked perfectly, thank you Timo. A couple of items that caught me out at the start was forgetting that the SeaTalkNG MUST be supplied with 12V as well as the CAN breakout board, and that the 120 Ohm terminating resistor link must be fitted on the breakout board.

I am able to simulate Engine Temp, Oil Pressure, Battery Voltage and engine RPM by hard coding the relevant fields in the Sketch and I see them appear on the MFD. Next step is to write the A/D and frequency measurements and then do the hardware interface to the sensors and the alternator.

I would like the Raymarine MFD to provide over heat and low oil pressure alarms, I can enable the alarms in the MFD but cannot set alarm limits, so will do this within my sketch.

The part I am stuck on is how to send the right alarm messages over N2K/SeaTalkNG, I cannot find any reference to a pgn for alarm handling, does anyone know where I might be able to find this information?

The alarms I would like to send are:

Engine Overheat
Low Oil pressure
Low Battery Voltage

Thanks
Simon

SetN2kEngineDynamicParam function has parameters for: flagOverTemp, flagLowOilPress, flagLowSystemVoltage.

Note that you should have terminal resistor at both end of main bus. SeaTalkNG is also CAN bus so its terminal resistors should be calculated. So totally bus must have two resistors! It is better to have resistors on the main bus and not on board, since if you e.g. remove board, your bus does not work. Each drop cable should not exceed 6 m. See e.g. http://www.yachting-pages.com/content/a-guide-to-nmea-2000-installations-for-yachts.html

Hi Timo,

Many thanks for the guidance, I was looking in the wrong place and had not seen the flags! I will have a play later to test it out

re Termination of the bus, yes understood. In this application I will only have the two devices as it is on a small motor launch and has no multi drop bus, just CAN breakout wired straight to the MFD. I guess that the MFD has no internal termination resistor so perhaps I should reduce the value of the termination resistor on the CAN breakout? It is working ok with the termination 120R on the breakout board, so maybe not an issue. I will later fit the same to our sailing yacht which has a properly terminated multi-drop bus so will not fit the terminator on that installation.

Thanks again
Simon

I have not met any MDF with internal resistor. It would not be good. On test system with short bus, one terminating resistor is normally enough.

Hello Timo,

after a half year now I have found some time again to take a look into NMEA again. This also due to my Princess gets a "new" engine which needs again a digital interface.

We started beside selling diesel based heaters for boat and caravan. I was thinking about if it is possible to control the heaters through the protocol. From the library, I found the "tN2kTempSource" class. Like the name show, it is just a source.

So do you know about devices which can control the cabin temperature through the NMEA2K protocol? I could find yet something about this from my device, the Raymarine Axiom 9. Would be great if I could make an interface which then could control the heaters through some kind of panel or already existing multifunction device.

I am talking about this device https://marine-varmer.no/produkt/planar-2d-12-tm-3995-12v-2kw-pu27/ , please this is not meant as advertisement here. We do not sell outside NO,DK,SE as well. It would be also interesting to control warm water heater which we use the engine water heater for together with a tank.
There is also a SMS module which can turn on and control the heaters. With the right interface it should be able to control whatever device in from the NMEA2K network where it would make sense.

So do you know about devices which are able to controle heating systems, do you have an example like a panel which could be mounted several places on the boat to controle the things?

I do not know any common device for controlling heaters. The problem is that there is no standard messages for that, so every manufacturer would use proprietary messages.

On the other hand there temperature PGN:s 130312 (obsolote) and 130316 could be used for tempretature control. They both has field "Set temperature", which can be changed by standard way with Complex groupg function PGN 126208. So in principle your device can provide Cabin current temperature and set temperature with 130316. Then with other device - e.g. MFD it should be possible to change set temperature field on your device and so your heater would start to heat. Unfortunately I do not know does MFD:s support that functionality or if any does, how complex it would be change set temeperature. I mean that it may be behind several click.

Also you can make your own control panel and use proprietary PGN:s. With that you only win that the cabling could be used and you can provide current cabin temperature to the N2k bus. But there is also marketing question about certification. Even my library is "certification ready" the costs for getting you device certified are some thousand dollars. So how meaningfull it is for customers if you sell your system just NMEA 2000 compatible instead of NMEA 2000 certified, if they should connect it with critical network with navigation systems.

It may be easier to make own control panel with some wireless solution .

My plotter B&G vulcan 9 does not transmit or send the pgn for the binairy bank status pgn 127501.
There is a way to get c-zone enabled i have to put in a config file.

anyone familiar with C-zone and know how to implement this ?
i eventualy want te set an output with my Vulcan 9

hello timo
i have got my teensy3.2 + CAN breakout board working
I can send test data (windmonitor example sketch to nmea) to MFD (Raymarine Axiom LH3 - latest versions 3.5)
data displays on MFD as expected - all good.
I can monitor the nmea2000 messages (using actisense reader) and see all my bus devices and respective PGN messages etc - all good. (inc those generated by the sketch)

However when trying the “battery monitor example” .. using same config etc .. i see the various
PGNs generated by the sketch (PGN 127506, 127508, 127513) however i cant get any data
to display on axiom/LH3.
Raymarine manual lists PGN 127506 as supported (latest 3.5 LH3 version) - however respective data fields on MFD are blank (eg battery SOC - ive tried each of the 5 battery instances it claims to support - and note the sketch is sending battery =1)
The LH3 manual states data items support for
“battery - voltage, current, temperature... data items available for up to 5 batteries”
(which also is the same number of engines supported)
the LH3 manual doesnt provide any details on how the available data items map to the list of supported PGNs .
The “engine” related PGNs have a “alternator voltage” field, but no mention of current or temp.
At presentI dont have any devices sending battery voltage (nor do i have an engine gateway,
so no battery voltage or battery data displayed)

So to the question : do you have any clues on which PGNs might be used for the battery temp, current? (other than PGN 127508 - which is not shown on the supported LH3 PGN list .. and the list doesnt have any obvious PGNs listed for battery ... very strange)

further to above
I added the additional hardware (USB port) to my teensy, and using listenersender
sketch I have now been able to use your simulator s/w .
... as an aside - a BIG thanks for providing these tools, tutorials and great work on N2K library...

I can get data from simulator to display on MFD (axiom LH3) - all good, and have confirmed that
indeed the MFD is supporting (& displaying) PGN 127508... this question solved.

However ... whilst using the simulator and changing various parameters and viewing them using
actisense reader & on MFD Ive discovered some inconsistencies:

  1. engine load % appears incorrect?
  • for example when setting to 30% in simulator, NMEA bus displays 14% on BOTH MFD & actisense reader.
  1. engine fuel rate L/Hr
  • for example when setting 11.5L/Hr in simulator, NMEA bus displays 0.0052cu m/hr (5.2L/Hr) on actisense reader AND MFD displays 5.2L/Hr also.

the other engine parameters all appear to be OK ... the simulator values match MFD and nmea reader values.

also a couple of additional questions about simulator
3) DC status PGN 127506 - i can enable it in simulator, and see values on nmea bus reader
however it shows 246% for SOC ... and there doesnt appear any way to change this in simulator?
I assume its hard coded?
(MFD doesnt display... but this may be because it expects a value of 100% or less?)
4) Alternator voltage (engine PGN) - these are displayed on MFD and nmea reader - but i cant find anywhere to change these on simulator , once again Im assuming these are hard coded?

Hi!

Interesting thread!

I've been thinking about something like this myself, to input data to my MFD at the Garmin 721XS.
I've found a Datalink to NMEA2000 converter for all the engine data, but it does not include all the data I wish to see.

I would like to send to N2k network:
Oil Pressure (from an analog 0-5v sensor)
Raw water temp (from analog sensor)
Raw water pressure (from analog 0-5v sensor), but I don't know if the MFD has a display field for it though.

I see there is a lot of people using N2k and arduino, so please, can you guide me to a place to start learning about protocol and hardware, because can-bus systems is new to me.

sunnycoastgreg:

  1. engine load % appears incorrect?
  • for example when setting to 30% in simulator, NMEA bus displays 14% on BOTH MFD & actisense reader.
  1. engine fuel rate L/Hr
  • for example when setting 11.5L/Hr in simulator, NMEA bus displays 0.0052cu m/hr (5.2L/Hr) on actisense reader AND MFD displays 5.2L/Hr also.

the other engine parameters all appear to be OK ... the simulator values match MFD and nmea reader values.

also a couple of additional questions about simulator
3) DC status PGN 127506 - i can enable it in simulator, and see values on nmea bus reader
however it shows 246% for SOC ... and there doesnt appear any way to change this in simulator?
I assume its hard coded?
(MFD doesnt display... but this may be because it expects a value of 100% or less?)
4) Alternator voltage (engine PGN) - these are displayed on MFD and nmea reader - but i cant find anywhere to change these on simulator , once again Im assuming these are hard coded?

I'll try to check the errors above. Some values are just hard coded quicly to get some information to the bus.