NMEA 2000 Shield

You were right, I loaded flexcan when I added Teensyduino. I'm on a Mac so it took me a while to find but I got rid of the flexcan library in that install and it compiles just fine! Now to try to get the simulator running!

Thanks again!

Hi all, I just added ESP32 support to NMEA2000 library.

Hi Timo,
i have a question about Nmea2000 rules: can i have two devices sending the 127489 PGN (but different fields) at same time?
For example, a device that sends field #11 discrete status 1 data, while another device is sending oil press and water temp?

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

Also take care that you set different unique number for your devices. If you use my library, you define it during setup with NMEA2000.SetDeviceInformation(...). It is also best to set ProductInformation right, so you can separate the devices on MFD devicelist.

Is there a place to get the N2K connectors? I thought I saw it in this thread but I went trhough all 30 pages and did not find it!

Thanks

Scott

I do not know, what happened my previous reply.

For boards and hubs I have used 5 pos terminal blocks. Below are example Farnell codes:

  • 1717013 CTB9208/5 TERMINAL BLOCK, PLUGGABLE, 5POS
  • 1717025 CTB9308/5 TERMINAL BLOCK, HEADER, 5POS

Standard 5 pos Micro-C M12 connectors can be found e.g. from tme.eu. Look on
Connectors-Industrial Connectors-Industrial circular connectors-M12 connectors Filter "Number of Pins" to 5 and "Polarization" to "A code - DeviceNet" to get a list of possible NMEA2000 connectors. I used e.g.

  • ELWIKA5012PG9 Connector:M12;female;PIN:5;angled 90°
  • 12P-05PFFS-SF8001 Connector:M12;female;PIN:5
  • 12P-05BMMA-SL8001 Connector:M12;male;PIN:5
  • 12P-05BFFA-SL8001 Connector:M12;female;PIN:5

Thanks Timo,

I'm sure I saw that post but I could not find it again! BTW I got the NMEA Simulator working on my Mac last night and can't wait to try it on the boat. Should get a teensy board and 2562 delivered today!

Thanks!

So Timo,

Got the teensy running and communicating with the computer, had some challenges as I have a VM running on my mac which is my windows machine. If anyone has trouble I can share what I needed to do.

I have the TemperatureMonitor.ino running and it is visible to the Actisence NMEA Reader software. I do not get the 4 PGNs that you reference in your documents though.

"Now you should see "ISO address claim" (PGN 60928), "Environmental parameters" (PGN 130310) ), "Environmental parameters" (PGN 130311) and "Temperature" (PGN 130312) messages on “NMEA Reader”."

I get all but the 60928 pgn. I do however get 126993 which is the "heartbeat" I guess.

Any thoughts?

Also, I am thinking the first stage of this will be as a listener, I just want to make sure I have this right. I will connect the N2K bus L&H via the CAN BUS that I'm going to build. If I later want the device to broadcast to the N2K bus do I really need the serial to USB converter you show? I don't want to then create another physical conversion back to the N2K bus. But can I connect the TX and RX to the same L&H wires?

Thanks!!!

Ypu probably won't see 60928, since that will be send on the very beginning and the USB is not ready for communication, so NMEA Reader will miss it. If you would have it connected to real bus, some device would probably reaquest it and you would see it and some others then.

What do you mean with "...serial to USB converter you show"?

timolappalainen:
What do you mean with "...serial to USB converter you show"?

I mean in the schematic and jpg that you have on teensy listener sender it shows 2 USB plugs.

I'm not sure where you were plugging those into. Unless one is for power or computer. But my goal is for this box to send the data to another location without a pc in the middle.

Does that make sense?

Thanks you are a great person to help people like this!

Scott

Timo,

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.

timolappalainen:
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

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