poghosyanstepan / esp-idf-CANBus-Monitor

Monitor Canbus traffic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

esp-idf-CANBus-Monitor

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 |
+-------------+           +-------------+           +-------------+            +-------------|

Software requirement

esp-idf v4.4 or later.
This is because this version supports ESP32-C3.

Hardware requirements

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

  2. USB-TTL Converter
    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.

Converter ESP32
RXD -- GPIO4 (*1)
TXD -- GPIO5 (*1)
GND -- GND

(*1) You can change using menuconfig. But it may not work with other GPIOs.

  1. SN65HVD23x CAN-BUS Transceiver
SN65HVD23x ESP32 ESP32-S2 ESP32-C3
D(CTX) -- GPIO21 GPIO17 GPIO9 (*1)
GND -- GND GND GND
Vcc -- 3.3V 3.3V 3.3V
R(CRX) -- GPIO22 GPIO18 GPIO10 (*1)
Vref -- N/C N/C N/C
CANL -- To CAN Bus
CANH -- To CAN Bus
RS -- GND GND GND (*2)

(*1) You can change using menuconfig. But it may not work with other GPIOs.

(*2) N/C for SN65HVD232

  1. Termination resistance
    I used 150 ohms.

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 for ESP32

git clone https://github.com/nopnop2002/esp-idf-CANBus-Monitor
cd esp-idf-CANBus-Monitor
idf.py set-target esp32
idf.py menuconfig
idf.py flash

Installation for ESP32-S2

git clone https://github.com/nopnop2002/esp-idf-CANBus-Monitor
cd esp-idf-CANBus-Monitor
idf.py set-target esp32s2
idf.py menuconfig
idf.py flash

Installation for ESP32-C3

git clone https://github.com/nopnop2002/esp-idf-CANBus-Monitor
cd esp-idf-CANBus-Monitor
idf.py set-target esp32c3
idf.py menuconfig
idf.py flash

Configuration

config-main config-app

CAN Setting

config-can

WiFi Setting

config-wifi-1

CAN received messages can be broadcast using UDP.
config-wifi-2

You can use recv.py as the receiver.
USBCAN-501

UART Setting

config-uart

How to use

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

Windows application User manual

See here.

About

Monitor Canbus traffic

License:MIT License


Languages

Language:C 97.0%Language:CMake 1.2%Language:Makefile 1.0%Language:Python 0.8%