Step 1 of 7 · about 5 minutes
Choose your hardware
Pick the board and CAN hardware you have on hand. The wiring, pins and firmware follow your choice, so you can switch any time.
Parts list
No hardware yet? Press Simulate device above and the dashboard runs on made-up data from your CAN messages.
Step 2 of 7 · about 10 minutes
Wire the two boards together
Run one jumper wire per row, pin to pin. Work with the USB cable unplugged.
| ESP32 pin | CAN board pin |
|---|
Change pins
Have the blue 5 V MCP2515 module (TJA1050)?
Its chip runs at 5 V, but the ESP32's pins take 3.3 V only. Power it from the board's 5V pin and put a 4-channel logic level shifter on CS, SCK, SI and SO. A 3.3 V module is simpler.
Step 3 of 7 · 5 to 20 minutes
Set up the CAN messages and IDs
List the messages the gateway should read, or send. Each message is one CAN ID. Its signals say where each value sits in the 8 data bytes and how to turn the raw number into real units.
| Name | Start bit | Bits | Byte order | Signed | Scale | Offset | Unit | Min | Max | Send value |
|---|
value = raw × scale + offset. Start bit and byte order follow the DBC convention: Intel counts from the signal's lowest bit, Motorola from its highest.
No messages yet. Choose a preset, import a DBC file, or add a message.
Step 5 of 7 · about 15 minutes the first time
Put the program on the ESP32
- Install the free Arduino IDE. In Boards Manager add
esp32by Espressif (version 3.0 or newer). - In Library Manager install
PubSubClient. - Put the download in a folder named
o2m8_can_gatewayand open it. - In the Tools menu set USB CDC On Boot to Enabled, or the Serial Monitor stays empty.
- Press Upload, then open the Serial Monitor at
115200. After a few seconds it showsMQTT: ... ok.
See the code (passwords hidden)
Step 6 of 7 · about 5 minutes
Connect to the machine
Three wires go to the machine's diagnostic connector. The pin letters are moulded on its face.
- Pin C to the CAN board's
CANH. - Pin D to the CAN board's
CANL. - Pin A to
GND, so both share a ground. - Power the ESP32 from USB, from a laptop or a power bank.
Testing on the bench instead?
Connect two CAN devices CANH to CANH and CANL to CANL, and fit a 120 Ω resistor at each end of the pair. Set Bus mode to Normal (step 4), because a listen-only node never acknowledges frames.
Step 7 of 7 · 1 minute
Watch it go live
- Press
- Within a few seconds the Gateway lamp turns green.
- Your signals fill in as the machine sends them. The raw log lists every CAN ID it hears.
- Try the Board LED switch and the Ping button: the gateway answers.
This demo uses a public test broker, so anyone can see these topics. For a customer installation, use a private broker with logins and TLS (step 4, More settings).
Topics the gateway uses
| Topic | What it carries |
|---|
This dashboard is empty.
Add a widget from the left, or start from a template.
