esp-idf-CANBus-Monitor

April 26, 2026 ยท View on GitHub

Monitor Canbus traffic.

USBCAN-V800

Background

Windows application for monitoring CANBus is published here.
This tool is designed to be used with this hardware.
bazaar487719_1

So, I made the hardware side with ESP32.

Application structure

+-------------+           +-------------+           +-------------+            +-------------+
| Windows     |           |   USB-TTL   |           |             |            | SN65HVD23x  |
| Application |<--(USB)-->|  Converter  |<--(TTL)-->|    ESP32    |<--(TWAI)-->|   CAN-BUS   |<--(CAN BUS)-->CAN Network
|             |           |             |           |             |            | Transceiver |
+-------------+           +-------------+           +-------------+            +-------------|

On the ESP32S2/S3, you can use USB instead of UART.

+-------------+                                     +-------------+            +-------------+
| Windows     |                                     |             |            | SN65HVD23x  |
| Application |<--------------(USB)---------------->| ESP32S2/S3  |<--(TWAI)-->|   CAN-BUS   |<--(CAN BUS)-->CAN Network
|             |                                     |             |            | Transceiver |
+-------------+                                     +-------------+            +-------------|

Software requirement

ESP-IDF V5.0 or later.
ESP-IDF V4.4 release branch reached EOL in July 2024.

Note for ESP-IDF V6
This option is required for ESP-IDF V6 because this project uses legacy drivers.
Image

ESP-IDF V6 gives this warning, but it still works.

#warning "The legacy TWAI driver is deprecated, please use esp_twai.h"

Hardware requirements

  1. Windows PC
    Windows applications can be downloaded from here.

  2. USB-TTL Converter or USB Mini Femail connector
    ESP32 development board has USB.
    This USB connects to Linux and is used for writing the firmware and displaying the LOG.
    Need converter to connect with Windows PC.

    ConverterESP32ESP32-S2/S3ESP32-C3/C6
    RXD--GPIO4GPIO4GPIO4(*1)
    TXD--GPIO5GPIO5GPIO5(*1)
    GND--GNDGNDGND

    (*1) You can change using menuconfig.

    ESP32-S2/S3 has a full-speed USB OTG peripheral with integrated transceivers and is compliant with the USB 1.1 specification.
    GPIO19 and GPIO20 can be used as D- and D + of USB respectively.
    On the ESP32S2/S3, you can use USB instead of UART.
    I used this USB Mini femail Connector.
    usb-connector

    ESP32-S2/S3 BOARD          USB CONNECTOR
                               +--+
                               | || VCC
        [GPIO 19]    --------> | || D-
        [GPIO 20]    --------> | || D+
        [  GND  ]    --------> | || GND
                               +--+
    
  3. SN65HVD23x CAN-BUS Transceiver
    SN65HVD23x series has 230/231/232.
    They differ in standby/sleep mode functionality.
    Other features are the same.

  4. Termination resistance
    I used 150 ohms.

Wireing

SN65HVD23xESP32ESP32-S2/S3ESP32-C3/C6
D(CTX)--GPIO21GPIO0GPIO0(*1)
GND--GNDGNDGND
Vcc--3.3V3.3V3.3V
R(CRX)--GPIO22GPIO1GPIO1(*1)
Vref--N/CN/CN/C
CANL--To CAN Bus
CANH--To CAN Bus
RS--GNDGNDGND(*2)

(*1) You can change using menuconfig.

(*2) N/C for SN65HVD232

Test Circuit

   +-----------+   +-----------+   +-----------+ 
   | Atmega328 |   | Atmega328 |   |   ESP32   | 
   |           |   |           |   |           | 
   | Transmit  |   | Receive   |   | 21    22  | 
   +-----------+   +-----------+   +-----------+ 
     |       |       |       |       |       |   
   +-----------+   +-----------+     |       |   
   |           |   |           |     |       |   
   |  MCP2515  |   |  MCP2515  |     |       |   
   |           |   |           |     |       |   
   +-----------+   +-----------+     |       |   
     |       |       |       |       |       |   
   +-----------+   +-----------+   +-----------+ 
   |           |   |           |   | D       R | 
   |  MCP2551  |   |  MCP2551  |   |   VP230   | 
   | H      L  |   | H      L  |   | H       L | 
   +-----------+   +-----------+   +-----------+ 
     |       |       |       |       |       |   
     +--^^^--+       |       |       +--^^^--+
     |   R1  |       |       |       |   R2  |   
 |---+-------|-------+-------|-------+-------|---| BackBorn H
             |               |               |
             |               |               |
             |               |               |
 |-----------+---------------+---------------+---| BackBorn L

      +--^^^--+:Terminaror register
      R1:120 ohms
      R2:150 ohms(Not working at 120 ohms)

Installation

git clone https://github.com/nopnop2002/esp-idf-CANBus-Monitor
cd esp-idf-CANBus-Monitor
idf.py set-target {esp32/esp32s2/esp32s3/esp32c3/esp32c6}
idf.py menuconfig
idf.py flash

Configuration

config-main config-app

CAN Setting

config-can

UART Setting

  • Using UART
    Image
  • Using USB
    Image

How to use

  • Add ESP32 to CanBus.
  • Write firmware to ESP32.
  • Connect ESP32 and Windows PC using USB-TTL Converter or USB.
  • Start a Windows application.

Windows application User manual

See here.

Official document is here.

Reference

https://github.com/nopnop2002/esp-idf-candump

https://github.com/nopnop2002/esp-idf-can2http

https://github.com/nopnop2002/esp-idf-can2mqtt

https://github.com/nopnop2002/esp-idf-can2usb

https://github.com/nopnop2002/esp-idf-can2websocket

https://github.com/nopnop2002/esp-idf-can2socket