Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Can Bus Support (NMEA2K) #27

Open
oxbown opened this issue May 18, 2023 · 5 comments
Open

[Feature] Can Bus Support (NMEA2K) #27

oxbown opened this issue May 18, 2023 · 5 comments
Labels
good first issue Good for newcomers

Comments

@oxbown
Copy link

oxbown commented May 18, 2023

Hardware support for NMEA2K using a cheap SN65HVD230 TJA1050 Chinese board.
NMEA2K cable can provide 12v to the m5stack and the SN65HVD230 TJA1050 can translate the CAN messages to be readable for the ESP32 boards.
Example project: https://github.com/AK-Homberger/NMEA2000WifiGateway-with-ESP32

Example Hardware:

@mgrouch
Copy link
Contributor

mgrouch commented May 18, 2023

They are isolated so m5stack would still need usb for power

@mgrouch mgrouch added the good first issue Good for newcomers label May 18, 2023
@oxbown
Copy link
Author

oxbown commented May 18, 2023

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.
m5Stack_nmea2K

@oxbown
Copy link
Author

oxbown commented May 18, 2023

UART Ext. port on m5Stack delivers 5V to VCC so TJA1050 could be the best option for this...
TJA1050 Datasheet

@oxbown
Copy link
Author

oxbown commented May 18, 2023

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

@mgrouch
Copy link
Contributor

mgrouch commented Jun 2, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants