Go Down

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



I built the Teensy with an MPC2562 CAN BUS today, I get it to communicate with the NMEA Reader using the static temp values. I hooked up a DS18B20 and get a different readout but not accurate.  I can't tell what pin you intended the data to go to.  I used what I believe is A0 or pin 14 it is 2 from the end.   I  loaded a different sketch and the output was -127 which usually means the wrong pin is being used for the data or the probe isn't working.

Thoughts on that? 


You do not need second USB. That was for debug/analyze device I made for someone who wanted to send simulated data from my NMEA Simulator on one port and listen with NMEA Reader on other port.

Which code you are using for DS18B20? The sketches I have found are not usable with NMEA2000, since they does not make things asyncronously. Without async. your system may just delay 700-800 ms on which time NMEA2000 library woult be polled and you will loose possible device queries. This leads to situation that you MFD will show up your device and then not. With async. one can get delays to 10ms, which is acceptable, if your device does not do anything else. The best solution would be to use 1-wire with DS2482-100 and improved i2c library.

A0 is pin 14 as you can see on Teensy Pinout. DS18B20 is rather accurate and reliable.


Yes you can. Take care that you provide "Not available" data to all fields you do not send on each PGN.
Thank you, Timo.

To test putting the "not available" data in one field i tried with a simpler PGN (the 130313 one) chosing field#5, and i think i found a mistake in the N2kMessages.h file...

I think

SetN2kPGN130313(N2kMsg, SID, HumidityInstance, HumiditySource, Humidity);

should be:

SetN2kPGN130313(N2kMsg, SID, HumidityInstance, HumiditySource, ActualHumidity, SetHumidity);

or maybe i'm looking at wrong/old Nmea 2000 pgn description list?


You were right - it is fixed now. SetHumidity is optional parameter, since it is rarely needed.

... should allways tripple check others commits.


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




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:
But i cant read data in NMEA reder via NGT-1.
Where is the error?

Thank You



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"


May 22, 2018, 08:25 am Last Edit: May 22, 2018, 09:57 am by tmsio
Thank You Timo, il try to feed 12v.


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:
Code: [Select]


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



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?

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



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

Go Up