Thursday, April 14, 2016

Building your own NMEA 2000 Device

The hard work has already been done, first by the pioneering efforts of Kees Verruijt at canboat , and now by the development of a NMEA2000 Arduino library by Timo Lappalainen.

I am using the NMEA2000 library with an Arduino Due board. The Due has a built-in CAN controller (in fact 2 of them), missing only an external CAN transceiver to get attached to a N2K backbone. With the arrangement described below, I first ran the library example ‘TemperatureMonitor’, sending 2 fixed temperature values to the N2K network. The result can be seen in the following screen capture of the B&G Touch 7 display, showing the sea and cabin temperature values sent by this example.

I then proceeded to develop a replacement for the Actisense NGW-1, which translates fast NMEA 0183 heading sentences to their equivalent N2K PGN. For this, I also made use of the TinyGPS++ library, which takes care of parsing the NMEA 0183 sentences. 

All this is done with a deceptively short Arduino sketch (‘Heading Converter’), which I reproduce in its entirety here.

// Convert fast heading data from NMEA 0183 to NMEA 2000

#include <Arduino.h>
#include <NMEA2000_CAN.h>
#include <N2kMessages.h>
#include <TinyGPS++.h>

TinyGPSPlus gps;
TinyGPSCustom heading(gps, "HCHDG", 1); // $HCHDG sentence, 1st element

void setup() {
  NMEA2000.SetProductInformation("00000001", 100,"Heading converter", " (2016-04-13)", " (2016-04-13)");
  NMEA2000.SetDeviceInformation(1, 140, 60, 2046);

void loop() 
  tN2kMsg N2kMsg;
  if (heading.isUpdated())
    SetN2kMagneticHeading(N2kMsg, 1, DegToRad(atof(heading.value())));
  while (Serial2.available() > 0)


  1. Where did you get the can tranciver?

  2. Look for 3.3V SN65HVD230 CAN transceiver on eBay.

  3. This comment has been removed by the author.

  4. This comment has been removed by the author.

  5. Hi, how connect the CAN transceiver to the nmea2000 cable? (pinout) thanks so much

  6. Hello,
    Can you please tell me the pinout how to connect NMEA2000 cable to cjmcu-230 transciever? I built autopilot for my boat and I would like to connect it with my chartplotter over NMEA2000. I am using esp32 microcontroller.
    Thanks in advance and have a pleasant day.


  7. Thanks for sharing your valuable blog. Very Informative. If you want to buy Marine hardware accessories, electronics products so you visit our reputed Point Supplies online stores. Our premium quality products are available at affordable prices.

    NMEA 2000 Cable
    Best Marine Solar Panels
    Marine Circuit Breakers

  8. I have three telegrams HCHDT, HEROT, AND HCHDT. I want to remove HCHDT telegram, so how can I do this.

  9. hello
    what is the can id of Lorrance point-1 and how is the angle expressed?

  10. Integration of the latest ENT Instruments in UK has brought about significant improvements in patient care. The precise diagnosis made by these instruments allows for customized treatment plans that result in better outcomes for patients. Additionally, minimally invasive methods that are made possible by the latest instruments have resulted in lesser scarring and shorter hospital stays and faster recovery time - improving the comfort and satisfaction for patients.