Open oxbown opened 1 year ago
They are isolated so m5stack would still need usb for power
The idea is to connect the SN65HVD230 TJA1050 to the UART port (PORT-C) on M5Stack TOUGH.EXT board and the PWR port (RS485 PORT) to use de 12V from NMEA2K bus to power the board.
UART Ext. port on m5Stack delivers 5V to VCC so TJA1050 could be the best option for this... TJA1050 Datasheet
Some CAN bus info in ESP32 boards https://www.circuitstate.com/wp-content/cache/all/tutorials/what-is-can-bus-how-to-use-can-interface-with-esp32-and-arduino/index.html
To use the PORT-C as a CAN port:
#define ESP32_CAN_TX_PIN GPIO_NUM_14 // Set CAN TX port to 14 for M5 Stack Tough PORT-C(Blue)
#define ESP32_CAN_RX_PIN GPIO_NUM_13 // Set CAN RX port to 13 for M5 Stack Tough PORT-C(Blue)
#include <NMEA2000_esp32.h> // https://github.com/ttlappalainen/NMEA2000_esp32
I got N2K working on m5atom. Here: https://github.com/bareboat-necessities/bbn-nmea200-m5atom/tree/main/bbn-nmea2000-usb-gw-m5atom. With https://shop.m5stack.com/products/atom-canbus-kit-ca-is3050g
It should be trivial to port that part on m5tough with this unit instead https://shop.m5stack.com/products/canbus-unitca-is3050g
N2K Parsing code example is here: https://github.com/ttlappalainen/NMEA2000/blob/master/Examples/DataDisplay/DataDisplay.ino
It would need to be enhanced for other PGNs (which are already coded in https://github.com/ttlappalainen/NMEA2000) and instead of doing Serial.println(valueFromPGN)
store data in shipDataModel structure with data age as millis()
That will turn bbn_m5tough_active_boat into N2K display (Plug and play. No Wi-Fi required, nothing to set up, just plug into CanBus).
Hardware support for NMEA2K using a cheap
SN65HVD230TJA1050 Chinese board. NMEA2K cable can provide 12v to the m5stack and theSN65HVD230TJA1050 can translate the CAN messages to be readable for the ESP32 boards. Example project: https://github.com/AK-Homberger/NMEA2000WifiGateway-with-ESP32Example Hardware: