NMEA 2000 Shield

I don’t have switch box, I would like to operate the buttons from chart plotter and receive the status change on teensy

I do not know which method Garmin uses. There is PGN 127502 for setting binary control switches. But that is deprecated and on new designs it should be done with 126208, which is a bit more complex.

I'm trying to use an ESP32S2 for the NMEA2000 project. I get the error PERIPH_CAN_MODULE was not declared. some errors:
NMEA2000_esp32.cpp:119:23: error: PERIPH_CAN_MODULE was not declared in this scope
NMEA2000_esp32.cpp:123:51: error: DPORT_CAN_CLK_EN was not declared in this scope

My code has the following include:

#include <stdio.h>
#include <time.h>
#include <math.h>
#include <Arduino.h>

#define ESP32_CAN_TX_PIN GPIO_NUM_16
#define ESP32_CAN_RX_PIN GPIO_NUM_4
#include <N2kMessages.h>
#include <NMEA2000_esp32.h> 
#include <NMEA2000_CAN.h>
#include <N2kMessages.h>
#include <N2kMessagesEnumToStr.h>
#include <ActisenseReader.h>

All problem seam related to the CAN driver instead of the TWAI driver. The answer I got from Espressif is: TWAI is a near direct drop-in replacement for the old IDF CAN driver
if NMEA2000_esp32 is using a different CAN driver (not ESP-IDF) then they will likely not support anything but ESP32.
from a very quick read of GitHub - ttlappalainen/NMEA2000_esp32: Inherited object for use NMEA2000 with ESP32 boards it looks likely they implemented their own driver based on the ESP32 register set and that will not map to ESP32-S2

Is there a way to have the NMEA2000_esp32 to support TWAI?

It was easy to fix in NMEA2000_esp32.cpp as I had to change a few names with _CAN by _TWAI. SignalK is now receiving data from the ESP32S2
Timo, next time you make an update of your code, you could use TWAI instead of CAN.

@timolappalainen , I found the modifications to the NMEA2000_esp32 library to make it work for the ESP32S2. Let me know if you want to know those modifications for an update of the NMEA2000_esp32.

Great. Please make PR to NMEA2000_esp32 then we can continue discussing there.

my configuration is RapsberryPi running SignalK <--> USB <--> ESP32S2 <--> NMEA2000 bus <--> Raymarine Axiom. The ESP32S2 use the librairies NMEA2000.h, NMEA2000_esp32.h and ActisenseReader.h

At the begining of test, the data flow correctly between the RaspberryPI, ESP32S2 and Axiom.
After a few minutes, the USB and NMEA stop working but my web interface is still running ok so the ESP32S2 is not dead. When doing the same test with a Teensy4.1, it works for hours without problem. In both cases, I have the same read and forward stream. If I disable the forward stream (ESP32S2 to RaspberryPi), the software doesn't stop and the Axiom receive data from the SignalK.

Do you have any idea of what could cause the data to stop flowing ? I saw in one of your ino example that you use two different stream (Serial & Serial1); I tried that but the Signal1 doesn't work.

I wanted to do the PR to the NMEA_esp32 but I want to make sure it works fine.

Dear Timo and all,

I have the Arduino Mega and the Seeed CAN-BUS Shield V2.0; using the Timo's library and documentation I was able to do the first little sketchs.

Now, can I use this shield to make an engine gateway (i.e. reading analog data from the engine to write to NMEA2000 and showing on the MFD) in a safe and correct way (i.e.: isoleted transceivers) without running the risk of ground loops?
Do I need to do some special settings?
Or is it mandatory to change shield?

Thank you in advance,
Raimondo

Hello all,

I'm having product sending n2k data from bus to wifi. I'm currently in the testing phase but I'm missing a solution for simulating AIS data to the bus. I have used the NMEA simulator to simulate all other data successfully but have not found a way to simulate AIS data.

Does anyone have a working solution to simulate AIS data or could someone share the NMEA2000 AIS message in hex format (PGN 129039 or 129038)?

hirppa10;

The newest simulator has playback feature. If you can record with simulator AIS data, you can playback it (all or filtered) to the bus. Free Simulator does not allow long recording.

raisepe;

Unfortunately you will create ground loop with CAN-BUS Shield V2.0. Only question is how long. If your NMEA2000 bus power, your device and engine ground are nearly same point (<50 cm), there is no problem. If you feed your bus on e.g. chart table and have your device 6 m (in wire length) away on engine, then you ground your bus again near engine. In that point situation is bit better if your device is near bus power point, but then you will have long measuring cables from engine and may get noise to them.

Making CAN shield by own is not rocket science. I made my first shield according to https://github.com/ttlappalainen/NMEA2000/blob/master/Documents/ArduinoMega_CAN_with_MCP2515_MCP2551.pdf . Change MCP2551 to ISO1015 as on document https://github.com/ttlappalainen/NMEA2000/blob/master/Documents/Connecting_hardware_to_NMEA2000.pdf and you will have safe isolated shield.

And think to go to Teensy 3.2 - smaller board, more power more memory, internal CAN controller. You need only transceiver,

Dear TImo,

Thank you so much for your answer, which is very clear.
I really appreciate that you find the time to answer my question.

Thanks,
Raimondo

No problem. For some reason I still do not get email of new messages on forum so response takes some times long.

hi timo, do you have some example for windlass rode counter?
i try to set my teensy only with 128777 pgn but in my garmin chartplotter i dont see anything.
can you helpm me?
thank you :pray: :pray: :pray:

Unfortunately I can not. If PGN 128777 is not in supported list of plotter, you can not do anything. I use it on my own boat with Vitals Vessel Monitor and it works fine.

Note that this PGN is pretty new - document date is July 2019. So if your plotter has been launched before that, there is unlikely support for it.

I have a Garmin 8612 and I know that it supports rode deployed. One of my next projects is to design the system - I know that my windlass already has a magnet sensor installed so the connections will not be that difficult. I have done some preliminary coding with the variable in Timo’s library and haven’t quite figured that part out yet. Pretty sure I just need to look at it closer and learn more about how to tie the different pgns together.

Hi all,
I have a question.
With PGN130074 I can set a waypoint. Is there a PGN to delete or to move a waypoint?
Thanks a lot,
Manfred

Hi Timo and all

I have been successful in implementing a number of useful things over the past couple of months. Now I have moved on to the thing that I originally wanted to get done which is a windlass counter that will display the rode deployed on my Garmin 8612 MFD.

I have struggled with the basics of just outputting pgn 128777. I know that this pgn can be integrated with two other pgns, but all that I am interested in is seeing the rode deployment. I recognize that this should be the easy part and what I have done is in line with several other pgns that I am successfully outputting. Can someone help me understand what I am doing wrong or what is different about this pgn?

Thanks in advance for the help.


You should call in loop (or maybe you do I do not see full code):
void loop() {
...
NMEA2000.ParseMessages();
SendN2kPGN128777();
...
}

Is your device visible on MFD device list?

Hi @timolappalainen,

Thank you for your incredible work on this.

Quick question...The MCP2562 chip seems to be sold out worldwide with lead times mid 2023. Is ther an alternative transeiver that would work instead?

Many thanks,

Andrew