3-Way Asynchronous Bridge Interface
OpenLCB/LCC CBUS/VLCB
This sketch accepts traffic on any of three interfaces: USB/Serial, CAN, Wifi, and passes it to the other two.
It uses inexpensive products from M5Stack, based on the ESP32. Other ESP32 and CAN transceivers could be used.
The Wifi is designed to automatically connect to a LCC or CBUS hub via mDNS. JMRI has hubs which need to be activated
from its menus. For Wifi, one must supply the local Wifi network name and password (credentials) via a AP started by the sketch.
One can can access this via the Wifi-Network name "USBCANWifi-Setup". A webpage will then open in your browser which allows one to choose a Wifi network and supply a password. If this does not happen, then one can open the page at http://192.168.4.1/ manually.
The sketch can also be updated through this website (this is pending, as the hope is to supply .bin files).
Application:
- USB:CAN: Similar to other sketches and products, ie connects a computer to a CAN-segment.
- CAN:Wifi: Connects a CAN-segment to a Wifi-hub, such as available in JMRI.
- CAN:Wifi+USB: Same as CANWifi, but allows a second computer to link via USB for monitoring purposes.
User Interface:
There is a single button and a RGB LED. (Some modules have a screen instead.) Pushing the button briefly (<3s) will reset the processor. Pushing the buttom for greater than 3s will erase the Wifi credentials, and will cause the the AP to activate again.
Note: The USB and CAN will work independently of the Wifi, and the Wifi AP will shutdown if not accessed in 3 minutes.
HW Support:
- M5AtomS3Lite: recommended: 2 cores, native USB
- M5AtomS3R: more expensive and has a screen that is not used
- M5Atom: dual core, but slow serial-USB via a chip
- M5NanoC6: single core but native USB
- M5StampS3: use with the StampS3-Breakout
- M5StampC3U: single core, native USB, requires soldering to fit the Grove connector
Wiring:
The above can be connected to a computer via their USB connector. To connect to a CAN segment, the most convenient way is to use the following M5Stack products:
- Atomic CAN Base: recommended, used with the AtomLite products, secure and inexpensive. Note it has an isolated CAN connetion.
- MiniCAN, connected with a Grove cable. It is not an isolated CAN connection, but can supply power from the CAN bus to the processor.
- ToUnit Base, used with the AtomLite products, substitutes for the Grove cable.
- M5StampS3 base: this supplies a Grove connector, requires soldering
The above are all products from M5Stack (://m5stack.com), but are also available from Digikey (www.digikey.co.uk) and PiHut (thepihut.com) Other similar products can be used, but are not directly supported.
Alternate ESP32 processor boards and CAN-transceivers could be used if desired, but have not been tested.
Architecture:
When available, it uses true Dual-Core FreeRTOS Decoupled Pipeline
- Core 1: Hard Real-Time 125kbps CAN Bus <-> Serial & Network Broadcasters (Priority 5/4)
- Core 0: Self-Healing Wi-Fi Manager, mDNS Tracker & Inbound Network Parser (Priority 2) When the processor only has a single core, the processes are run on that single core.
Dependences
- WiFiManager by tzapu v2.0.17
- M5GFX by M5Stack v0.2.26
CRITICAL ENVIRONMENT REQUIREMENTS:
- This sketch REQUIRES Espressif ESP32 Board Package version 2.0.17.
- Do NOT use version 3.x.x (e.g., 3.3.11), as the updated ESP-IDF framework contains a known PSRAM mapping bug for the AtomS3R pico-package and deprecated peripheral drivers that conflict with the M5GFX library.
Copyright (c) D.P.Harris 2026