NMEA2000 icon indicating copy to clipboard operation
NMEA2000 copied to clipboard

Use 2 CAN controllers to filter data from NMEA2000 device.

Open mjsneijders opened this issue 2 years ago • 1 comments

i have a question, not really an issue:

I have an airmar Weatherstation 150WX on the NMEA2000 bus., which among other features also has a compass. unfortunately, this is a uncompensated 2 axis compass... needless to say, whenever my boat starts to heel, both the Compass heading as the Theoretical wind readings become faulty.

There is another fine compass on the bus ( precision 9), and Theoretical wind is calculated so i dont depend on this value from the weatherstation wx. I am also not able to disable the output of these values coming from this unit ( i dont have the airmar pc connection hardware). On my Simrad TP22 autopilot, i have no way to select which compass to use.

I would like to create some ESP32 board that i can add between the bus and this unit, and filter out any unwanted PGN's. Is there a way to have two instances of the NMEA2000 object on a single cpu, each using another can controller ( eg by adding an MCP2515)? Any ideas anyone?

mjsneijders avatar Mar 02 '22 10:03 mjsneijders

Yes it is. The simplest hw is Teensy 3.5, which has 2 good CAN controllers. It is also possible to do with ESP32. E.g., on ESP32

#include <NMEA2000_CAN.h> // This creates default NMEA2000 with ESP controller
// Manually add other controller
#include <NMEA2000_mcp.h>

#define N2k_SPI_CS_PIN 16 // Pin for SPI Can Select
#define N2k_CAN_INT_PIN 21 // Use interrupt  and it is connected to pin 21
#define MCP_CAN_RX_BUFFER_SIZE 50

tNMEA2000 &NMEA2000_2=*(new tNMEA2000_mcp(N2k_SPI_CS_PIN,MCP_16MHz,N2k_CAN_INT_PIN,MCP_CAN_RX_BUFFER_SIZE));

or for Teernsy 3.5

#include <NMEA2000_CAN.h> // This creates default NMEA2000 with first Teensy controller
// Manually add other for second port
tNMEA2000 &NMEA2000_2=*(new tNMEA2000_teensy(4,1)); // 4 is old definition. 1, means to use second port

ttlappalainen avatar Mar 02 '22 11:03 ttlappalainen