NMEA 2000 Shield

  • Download NMEA2000 and NMEA2000_esp32 libraries.
  • Connect e.g. MCP2562 tranceiver TX (pin 1) to Esp32 GPIO 16 and RX (pin 4) to GPIO 4.
  • Try example NMEA2000ToWiFiAsSeaSmart.
  • If you use other pins, you have to add to NMEA2000ToWiFiAsSeaSmart.ino above line
    #include <NMEA2000_CAN.h>
#define ESP32_CAN_TX_PIN GPIO_NUM_xx
#define ESP32_CAN_RX_PIN GPIO_NUM_yy

timolappalainen: I bought two FCH-Mini sensors http://www.tedcomp.se/produkter/flodesmatare/flodesmatare-fch-mini/ with 9000 p/l resolution.

Hi Timo thank you for help, it looks like a nice sensor.

There is a version with built-in PT100, do you think is useful to compensate for density variations? Temperature before and after the engine can be quite different. And yes, i fear that pulsation dampers are indispensable me too... :-(

timolappalainen: - Connect e.g. MCP2562 tranceiver TX (pin 1) to Esp32 GPIO 16 and RX (pin 4) to GPIO 4.

Thx. Can I use module sach https://ru.aliexpress.com/item/MCP2515-CAN-Bus-TJA1050-SPI-Arduino-V2/32858503783.html?af=208&aff_platform=default&cpt=1555009938551&afref=&cn=42ppt9cipxogprc6d5je2o5p0z2f9xiv&dp=v5_42ppt9cipxogprc6d5je2o5p0z2f9xiv&onelink_item_from=32858503783&onelink_thrd=0.0&onelink_page_from=ITEM_DETAIL&cv=0&onelink_item_to=32858503783&pvid=e372b7fb-d175-448f-b2e9-a3f07e0b3f8b&onelink_duration=0.822145&sk=ccfBY4yg&aff_trace_key=eae1b09afa824914960414239fcae9ba-1555009938551-03155-ccfBY4yg&onelink_status=noneresult&scm=1007.22893.125779.0&terminal_id=ffc9f15ca425414b973194b92768577c&onelink_page_to=ITEM_DETAIL

popeye_70: There is a version with built-in PT100, do you think is useful to compensate for density variations? Temperature before and after the engine can be quite different.

I prefer to do it somehow. I did not notice that version, so I have planned to use 1-wire sensors.

maxik: Can I use module sach https://ru.aliexpress.com/item/MCP2515-CAN-Bus-TJA1050-SPI...

Yes, but then you need to force code to use mcp_can instead of internal can controllor. Also that seem to be with 8MHz clock, so you have to set that too.

And why you would like to use external controller, while there is build in CAN?

timolappalainen: And why you would like to use external controller, while there is build in CAN?

Only becose I have this board now but dont have MCP2562 :-)

I prefer to use internal can and just tranceiver. Anyway there is some instructions on post 694 to force mcp_can and clock.

I found you was use https://ru.aliexpress.com/item/SN65HVD230-CAN-bus-transceiver-communication-module-for-arduino/32693908062.html?af=208&aff_platform=default&cpt=1555258161604&afref=&cn=43ppykvl8luepb2vp9uwk354ui4tgwwr&dp=v5_43ppykvl8luepb2vp9uwk354ui4tgwwr&onelink_item_from=32693908062&onelink_thrd=0.0&onelink_page_from=ITEM_DETAIL&cv=0&onelink_item_to=32693908062&pvid=8dfcafcb-a429-4441-abe1-7d530eefad0e&onelink_duration=1.569596&sk=ccfBY4yg&aff_trace_key=3b2571d572c04e168a620c0fb6589eed-1555258161604-01832-ccfBY4yg&onelink_status=noneresult&scm=1007.22893.125779.0&terminal_id=ffc9f15ca425414b973194b92768577c&onelink_page_to=ITEM_DETAIL

can i use this board instead mcp2562? I found it in my home %-)

It should work.

In picture it has termination resistor on the board. Take care that you have exactly 2 termination resistor on whole N2k bus. Resistors has to be on end of the bus and any drop cable must not exceed 6 m.

Thank you! But why you are prefare MCP?

Simply because I have not had any problem with MCP2562. If you check posts others have had some problems with SN65HVD230 and then switched to MCP2562. Maybe they have connected it wrong and burned it or what ever. MCP2562 works with both 5V and 3.3V as far one connects Vio to used IO level. Now I have started to use ISO1050 to isolate device from bus.

In our shops I found ISO1050. But how I can connect it with MCP? Do I need any more details? I like the idea of isolation.

Isolation is naturally more complex and requires more parts. Note also that if you make device just for your own and you anyway feed N2k bus from same 12V source as you feed your device, isolation does not make sense. For isolation you should think it then more widely. Certified devices are required to be isolated on bus side. So if you feed N2k power with isolated PSU, then you could think having isolation on your tranceiver.

Just Google ISO1050 and download datasheets. There is good example. In the example there is isolated DC-DC converter from device side feeding tranceiver. Other way is to have DC-DC converter taking power from N2k bus and feed ISO1050 with that. Then you feed your device from battery with other DC-DC.

I have a DST800 sensor (depth sensor, speed and temperature).
This sensor works with the NMEA2000 standard.
I am using a seeed CAN shield (v1-2) (http://wiki.seeedstudio.com/CAN-BUS_Shield_V1.2/)
And i use an arduino MEGA 2560 and a 12V continuous stable power supply.
I think i need to use the “ttlappalainen” library (https://github.com/ttlappalainen).

Someone would have managed to acquire the data from this sensor?
If yes, how did you do it?

thank you in advance

DST800 sends standard depth PGN 128267 and speed PGN 128259. To read these with Mega 2560 you need to install NMEA 2000 library, NMEA2000_mcp and CAN_BUS_Shield libraries from my git https://github.com/ttlappalainen?tab=repositories.

Under NMEA2000 library examples there is DataDisplay2, which shows various bus data in clear text format. The example should give you way to handle received data. That e.g. handles speed on Speed(const tN2kMsg &N2kMsg) and depth on WaterDepth(const tN2kMsg &N2kMsg) callbacks.

If your electronics and connections are ok, the example works.


May be anyone have list of Raymarine proprietary n2k sequences. I need it to calibrate ITC5.


Thanks timolappalainen to help me. But this doesn't work.

This is what i did in the first time: - I downloaded NMEA2000_mcp-master; NMEA2000-master; CAN_BUS_Shield-master-2 - I test "DataDisplay2" but i don't work. They are "CAN device failed to open Running...CAN device failed to open all the time"

After: - I test "receive_check.ino" in CAN_BUS_Shield-master-2. I change "Slave select" of SPI (const int SPI_CS_PIN = 9;) because in my seeed CAN shield (v1-2) the CS (SS) is in 10. After I changed (const int SPI_CS_PIN =10) he tell me "CAN BUS Shield init ok!" but nothing else.

After: - I return in "DataDisplay2.ino" i connect the pin10 in pin9 (I twisted the pin and i connected a wire between pin 10 to 9 because i don't know where i can change the instruction in your software) but he tells me all time the same message (CAN device failed to open Running...CAN device failed) In the same time i changed #define N2k_CAN_INT_PIN 21 to 2 (because I tested electronically "INT" of my MCP2515 is connected to the pin 2 of arduino MEGA2560)

You know why my system doesn't work.

See on file NMEA2000_CAN.h:

  There are also library specific defines:
    #define N2k_SPI_CS_PIN 53  // Pin for SPI Can Select
    #define N2k_CAN_INT_PIN 21 // Use interrupt  and it is connected to pin 21
    #define USE_MCP_CAN_CLOCK_SET 8  // possible values 8 for 8Mhz and 16 for 16 Mhz clock

Thanks again timolappalainen,

Now i changed:

// #define N2k_CAN_INT_PIN 0xff   // No interrupt.
#define N2k_CAN_INT_PIN 2 // shield seeed v1.2 INT is 2
#include <NMEA2000_mcp.h>
#if !defined(N2k_SPI_CS_PIN)
#define N2k_SPI_CS_PIN 10   // shield seeed v1.2 CS/SS is 10
//#define N2k_SPI_CS_PIN 53  // Pin for SPI Can Select 

in a NMEA2000.h

And after i comment #define N2k_CAN_INT_PIN because he is in NMEA2000.h

Now i have in a serial terminal:
“CAN device ready

but nothing else and i can see RX led blink in CAN shield seeed v1.2

Did you mean NMEA2000_CAN.h?

You should not touch any library code at all. If test example, you can take copy of it and modify that. If you need to change definition, you do it in your code before including NMEA2000_CAN.h - not modifying itself. Like this:

#define N2k_SPI_CS_PIN 10
#define N2k_CAN_INT_PIN 2
#include <NMEA2000_CAN.h>

Have you modified shield? As default shield has CS on D9! Also take care that you have exactly two termination resistor on the whole N2k bus.