NMEA 2000 Shield

FXVT: Bonjour Timo,

I intend to buy the new TEENSY 4.0. Do you think it will work as well as a Teensy 3.2 or 3.6 with your library ?

What kind of transceiver I must add to plug it with my N2K network ? I will prefer a ready-made board instead of something to solder.

Thank you. FX VAN THUAN

Unfortunately I have not had time to write "driver" for Teensy 4. On the other hand even Teensy 3.2 can handle rather big projects and Teensy 3.6 even much bigger.

For Teensy 3.6 there is "Dual CAN-Bus adapter" and for Teensy 3.2 http://skpang.co.uk/catalog/teensy-canbus-breakout-board-include-teensy-32-p-1507.html. Those have problem that they are not isolated from NMEA2000 bus.

What kind of interface you are looking for. I know company, who has different kind of proper boards.

stspanhe: NMEA2000ToWiFiAsSeaSmart:32:17: error: conflicting declaration 'tNMEA2000_esp32 NMEA2000'

tNMEA2000_esp32 NMEA2000;

Something does not match. If you look code on https://github.com/ttlappalainen/NMEA2000/blob/master/Examples/ESP32/NMEA2000ToWiFiAsSeaSmart/NMEA2000ToWiFiAsSeaSmart.ino there is not that definition on line 17.

You are conflicting since you use #include and then you redefine tNMEA2000_esp32 NMEA2000; You should either use common #include or forced method

include // https://github.com/ttlappalainen/NMEA2000_esp32

... tNMEA2000 &NMEA2000=*(new tNMEA2000_esp32(GPIO_NUM_32,GPIO_NUM_34));

Also you get warning about wifi library, since you have it loaded on your libraries and on ESP32 framework. This is drawback of simple Arduino environment that you can not have project depended libraries.

timolappalainen: Unfortunately I have not had time to write "driver" for Teensy 4. On the other hand even Teensy 3.2 can handle rather big projects and Teensy 3.6 even much bigger.

For Teensy 3.6 there is "Dual CAN-Bus adapter" and for Teensy 3.2 http://skpang.co.uk/catalog/teensy-canbus-breakout-board-include-teensy-32-p-1507.html. Those have problem that they are not isolated from NMEA2000 bus.

What kind of interface you are looking for. I know company, who has different kind of proper boards.

Bonjour Timo,

Thank you for your prompt reply. Actually I am tented to buy a Teensy 4.0 because of his power and above all because of the price. It is cheaper than a 3.6 and a 3.2 and much much more powerfull. Today I have 2 arduino Uno devices (Ok..I know... ;-) )with your library. The first one interfaces a BMV700 Victron Battery Monitor to the N2K network and the other catches the engine temperature , RPM and the fridge temperature and send them to the network as well. and I'd like to merge the 2 sketches in one in order to have less connexions. These 2 sketches are "time sensible" and I gess it will work better with a more powerfull microcontroller. May be a Teensy 3.2 will be enough but for the same price, or even cheaper, I can get the new 4.0

Merci. FX VAN THUAN

Thanks Timo, I did chose the "#include " that sorted things out. It seems both sending and receiving is working fine with DUE and ESP32. But for Arduino Mega i can only send messages and unfortunately not receive. :(

timolappalainen: You are conflicting since you use #include and then you redefine tNMEA2000_esp32 NMEA2000; You should either use common #include or forced method

include // https://github.com/ttlappalainen/NMEA2000_esp32

Teensy 4 is indeed interesting, but as I said the driver is not yet ready and I can not give schedule. I have Teensy 4 waiting time for it.

I used Teensy 3.2 for reading NMEA0183, translating it to NMEA2000, reading some inputs and sending them to NMEA2000, converting NMEA2000 to USB as NMEA0183 etc. Also controlling touch display. Lot of things. Then moved to 3.6 due to SD card. I think power will not be the problem in your case.

Couple of questions:

How does one detect if certain message is being sent at bus and it is fresh?

What is the type of heading reference at N2kHeading for arduino? I see that one can send true heading but for receiving more variables are needed like variation, deviation and reference.

I did not understood your questions?

There is now way to see if some unit sends false information. What do you mean with fresh? Due to normal collisions messages may be delayed. Sending one frame (8 bytes) takes about 400 us. So you can expect frame to be time to time delayed that much due to collision.

PGN 127250 is for heading. If true heading has been used deviation and variation should be set to not available. If message has been sent by magnetic compass, it can provide those values. Variation should be fixed on location and deviation should come from compass deviation table.

Possible referencies on NMEA 200 library are simply N2khr_true or N2khr_magnetic.

Is there a way to see if a message is sent by other devices and how long ago it was last sent?

When reading heading what is the variable type for reference? I mean like double, float, boolean, integer and so on. With GPS compass I can send TrueHeading without defining that variable. Reading heading from bus to other device needs to have all variables or it does not compile for me.

The only way is to save in your device internally for each message time stamp, when you last received it.

If you mean my NMEA2000 library SetN2kTrueHeading function that actually calls SetN2kPGN127250 with all parameters by setting deviation and variation to NA and reference to N2khr_true.

If you read heading from bus ParseN2kHeading you can see in header file the types: ParseN2kHeading(const tN2kMsg &N2kMsg, unsigned char &SID, double &Heading, double &Deviation, double &Variation, tN2kHeadingReference &ref) So reference type is enum tN2kHeadingReference. See example DataDisplay2 and function void Heading(const tN2kMsg &N2kMsg) You must handle reference variable so that you know is sent andle true or magnetic.

allen652: I'd be happy to help. PM sent.

Hello @Allen652, can you give me The arduino connection diagram with The motor and nmea?

Hi All,

When using timolappalainen's N2k library with the Teensy 3.6, I assume it defaults to CAN0. Is that correct?

If so, how would I go about setting it to CAN1?

Currently there is no CAN port definition, if you use simple method by including NMEA2000_CAN.h. Instead of having

#include "NMEA2000_CAN.h"

on beginning of your project you include necessary libraries and define NMEA2000 object with can index 1 directly:

#include "N2kMsg.h"
#include "NMEA2000.h"
#include 
#include  
tNMEA2000 &NMEA2000=*(new tNMEA2000_teensy(4,1));

Thank you!

Hi guys, I'm trying to read the information from a Garmin GPS19x NMEA 2000 (I only have it on my network) to my Arduino Mega, I put the DataDisplay2 on my arduino with this sentence in the begging: #define MCP_CAN_CLOCK_SET MCP_8MHz because I'm using this little guy here: https://www.makerfabs.com/can-module-mcp2515.html I already conected two 120 ohms resistor between my can high and can low output All the other conections are already done (Pin 21, 50, 51 , 52 and 53), but I only get this message on my serial monitor "CAN device failed to open" Does anyone know how can fix it, please?

“CAN device failed to open” simply means that library can not communicate with can controller.

You have wrong definition for clock set. See NMEA2000_CAN.h descriptions on the beginning.
The right definition is:
#define USE_MCP_CAN_CLOCK_SET 8

timolappalainen: "CAN device failed to open" simply means that library can not communicate with can controller.

You have wrong definition for clock set. See NMEA2000_CAN.h descriptions on the beginning. The right definition is:

define USE_MCP_CAN_CLOCK_SET 8

Thank you, now I can get some datas, but I only get 129026 information instead 129029. It's strange because I only have a Garmin GPS19x NMEA2000 on my bus.

This is what I got: CAN device ready Running...In Main Handler: 129025 In Main Handler: 129025 In Main Handler: 129026 COG/SOG: 243 reference: true COG (deg): 0.00 SOG (m/s): 0.04

There seem to be default receive frame buffer only 2 for mcp_can. Uncomment line // NMEA2000.SetN2kCANReceiveFrameBufSize(50); To set it 50. You may need to reduce it smaller due to low RAM on Arduino Mega.

timolappalainen: There seem to be default receive frame buffer only 2 for mcp_can. Uncomment line // NMEA2000.SetN2kCANReceiveFrameBufSize(50); To set it 50. You may need to reduce it smaller due to low RAM on Arduino Mega.

Thanks Timo, everything is running good! Sorry to bother you again, but is it possible to get more decimal places on Latitude and Longitude informations?

DataDisplay2 is one example how you can catch messages and parse their data. You should study it and understand the idea and build your own code for handling data. With parse functions you get data in full resolution double (note that on Mega double is actually float), which you can handle as you like. The DataDisplay2 example is not very usable execpt as example of using library functions.

ok, total noob here.

I have been reading about the NMEA-2000 work and saw the fantastic code by Timo. I want to create a data logger for a friend's boat and capture his current location (where in the world is ).

I decided to buy a PI Zero W and a RS-485 Can Hat https://www.amazon.com/gp/product/B07DQPYFYV/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1 Now my first question is: How do I actually use/run Timo's code on the PI? These are arduino libraries but as far as I know, I will have to write standard C code to make my application on the PI (not my first choice of language but it should be fine). Never programmed on a PI before but have been developing software for a long time.

My request here: How do I get the most basic code written/running using Timo's library?

My follow up question will be how I physically connect my PI to my PC and possibly run a garmin emulator there to have something to talk to.