This implementation provides a CAN Bus to USB adapter using the ESP32 microcontroller (commonly available in devkits such as the ESP-WROOM-32 we will use as example). The adapter uses the slcan protocol (CAN over Serial), making it compatible with popular software tools such as SocketCAN, Python-can, and other slcan-compatible applications. Since these boards include a UART bridge connected to the UART0 peripheral, SLCAN will be available through UART0 and USB using the default configuration.
The ESP32 implementation supports the following configuration:
-
USB, UART0 and MCP2515 (SPI to CAN)
- The USB port and the UART0 port of the ESP32 can be used for communication with the host system.
- The MCP2515 (SPI to CAN) module is used for CAN Bus communication.
- This configuration allows the device to interface with a CAN network while communicating with the host via USB.
Connections:
Function ESP32 MCP2515 Vcc VIN/5v 5v GND GND GND MOSI D13 SI MISO D12 SO Clock D14 SCK CS D15 CS
- Install
espflash
cargo install espflash cargo install cargo-espflash
- Download the release
doggie_esp32
. - Run
espflash flash --monitor -L defmt doggie_esp32
-
Install Rust and cargo with support for ARM architecture.
Follow the installation instructions from the official Rust website. -
Install
ldproxy
,espup
and the ESP32 toolchain:cargo install ldproxy cargo install espup espup install . $HOME/export-esp.sh # Or add to .zshrc/.bashrc
-
Install
espflash
cargo install espflash cargo install cargo-espflash # Optional espflash cargo command
-
Connect ESP32 to the PC via USB
-
Build and flash:
DEFMT_LOG=off cargo run --release