Skip to the content
2 layers29 × 26.5 mmCAN Shield, the printed circuit board in 3D

Can Shield for the ESP32-S3

Size
29 × 26.5 mm
Copper layers
2
Thickness
1.6 mm
Parts
15
Nets
34
Pads
58
Tracks, vias
58, 2
Pours
1
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
1 Dec 2023
Updated
3 May 2024

Overview

CAN Shield is an open-source printed circuit board by X1L3F, from the X1L3F/ESP32-CAN-Shield repository on GitHub. It is a 2-layer board of 29 × 26.5 mm with 15 parts on 34 nets, routed with 58 tracks and 2 vias.

It is built around the PESD2CAN. Its parts include 4 connectors, 3 resistors, 2 ICs and 1 capacitor.

Main components

1

README

README.md

ESP32-CAN-Shield

Overview

This ESP32-CAN-Shield is a custom-designed shield for the ESP32-S3, primarily used as a CAN (Controller Area Network) to WiFi bridge. It enables seamless integration and communication between CAN network systems and WiFi networks, making it ideal for automotive and industrial applications where remote monitoring and control are necessary. The developed ESP32-CAN Shieled can be deployed in two different use cases:

1. Single Device CAN-WiFi Interface

One ESP32-CAN Shield is linked to a CAN device, such as an OBD2 unit in an automotive vehicle. The ESP32 generates its own WiFi network, to which the Connector is subsequently tethered. plot

2. Multi-Device CAN-WiFi Network

Multiple ESP32-CAN Shields are each linked to their respective CAN devices, while all ESP32 devices are connected to an established WiFi network. The Connector actively monitors all CANeth messages transmitted over the WiFi network and directed towards it. This use case is also used for development and testing. plot

Compatibility

Note: ESP32 development boards come in various widths. Ensure to adjust the header width of this shield to match your specific ESP32 board model.

Hardware

The shield features a robust CAN transceiver schematic, including an optional termination resistor for network integrity.

Key Components:

  • CAN Transceiver: The TCAN332DCNT, a high-performance CAN transceiver from Texas Instruments.
  • Power Connection: The shield connects directly to the ESP32 board via two header columns, supplying 3.3V power and ground.
  • Signal Pins: Dedicated GPIOs for CAN high (CAN-H) and low (CAN-L) signals for RX and TX operations.
  • Termination Resistor: A bridge connector enables an end-termination resistor, essential for reducing signal reflections on the CAN bus.
  • CAN Interface: Utilizes a 2x5 IDC for CAN bus interfacing, with an IDC to D-SUB cable for standard D-SUB connections, compatible with devices like the Vector VN1610 and tools like CANoe.
  • Protection: Incorporates a PESD2CAN diode in a small SOT23 SMD package, designed to protect the CAN lines from ESD and other transient damages. This ensures reliability and longevity in automotive environments.
  • Manufacturing Compatibility: Designed in accordance with JLC Design Rules for easy custom manufacturing.

Software

The software is structured into two components:

  • The Gateway runs on the ESP and serves as the translater of CAN to caneth/caneth to CAN messages. It also serves a Website where different settings like CAN-speed and remote IP can be changed or a CAN-ID filter can be used.
  • The Connector which runs on a PC and sends/receives/loggs CANeth Messages to the Gateway. It basically connects like Wireshark or any other tool.

Installation

Gateway

The Gateway is developed with PlatformIO it can be installed as VScode extension. When the Gateway folder is opened in VScode, PlatformIO is automatically initalized and the project can be compiled and uploaded to the ESP. Make sure to add a Gateway/include/Secrets.h file with the desired WIFI configuration.

text
#ifndef SECRETS_H
#define SECRETS_H

//Put in the SSID and Password of the WIFI
#define WIFI_SSID "own-WIFI-SSID"
#define WIFI_PASSWORD "own-WIFI-Password"

//Define the SSID and Password for the hotspot of the ESP32
#define Hotspot_SSID "own-ESP32-SSID"
#define Hotspot_PASSWORD "own-ESP32-Password"

#endif

In the main.cpp of the gateway, the network setting can be modified via the mode variable.

  • Mode = 1: The ESP32 connects to a predefined network.
  • Mode = 2: The ESP32 acts as a Wi-Fi Access Point, which one still needs to connect to with a computer.
text
...
// WiFi and Hotspot settings
//Make sure you adjust the ssid and password in your Secrets.h to your WIFI
//mode = 1: connection with a predefined WIFI
//mode = 2: ESP32 as a WLAN-Access-Point
int mode = 1;
...
Webserver

On the Webserver there are several options to configure the communications and apply filter.

CAN Configuration:

  • Remote IP: Enter the IP, where the messages should be send to. (Look up the IPv4-Adresse of your computer.)
  • CAN Bit Rate: Adjust the Bit Rate according to your settings

Filter Option:

  • Allow all Messages: All messages are forwarded. You can add CAN-IDs to to the Blacklist to block messages from certain CAN-Devices.
  • Block all Messages: Blocks all messages. You can add CAN-IDs to to the Whitelist to forward messages from certain CAN-Devices.

Restart: Restarts the ESP32. It can take a moment to reconnet to the WIFI or you have to connect to the Hotspot from the ESP32 again.

plot

Connector

The backend of the Connector application Connector/qt_application_backend.py is a Python script with no external dependencies, besides the default Python 3.9 libraries. The programmed functions, classes, and their methods provide a comprehensive toolset to send, receive, and log CANeth messages. By default, the Connector is listening on all UDP IP channels for CANeth messages. Filters can be applied to restrict IPv4 addresses via a blacklist and whitelist. In addition to that, the CANeth messages can also be filtered by CAN ID via a blacklist and whitelist. The IPv4 address filter and the CAN ID filter are initially set to an empty blacklist, allowing all CANeth messages to be received. For ease of use, a graphical user interface (GUI) was implemented for the frontend of the Connector application Connector/qt_application_frontend.py using PyQt5.

plot

As depicted in the screenshot of the Connector application, the aforementioned features can be accessed through the GUI. In the popup of the advanced settings window, the UDP IP and the UDP port of the socket can be adjusted.

plot

For independent usage of the Connector application outside of a Python interpreter, it was compiled with PyInstaller into a ConnectorApp.exe for Windows 23H2. The .exe file is designed to support 1080p and 2k screen resolutions. A detailed guide for compiling an .exe-file with PyInstaller from a .py-PyQt5 file and .ui-PyQt5 file is provide under dist/PyInstallerGuide.

Simulation

To simulate a device that sends/receives CAN-messages to the Bus either CANoe or a python script found in Tools/canDevice.py is used with a Vector VN1610. To use it follow this steps:

  • install the pip install python-can package
  • install the latest drivers for the Vector hardware Interface
  • install the XL Driver Library and copy the vxlapi64.dll into the working directory (If the driver doesn't show up, you have to manually add the vxlapi64.dll file path to XL Driver Library)

Usage

  1. Attach CAN-Shield to ESP32 connect it to PC with the right USB-port and flash the Gateway-software. Before flashing, ensure you have included the Secret.h file in your project. Select your desired network mode in the Gateway/main.cpp.
  2. Plug in IDC and connect to VN1610. Connect VN1610 to PC.
  3. Access the web server using the IPv4-address of the ESP32. The method to retrieve this address depends on your network connection mode:
    • Hotspot on ESP32: Connect your computer to the ESP32's hotspot. Use the ipconfig command in your computer's command prompt to find the IPv4 address of the ESP32. Type this address into your web browser to access the web server.
    • Conncetion to predefined WIFI: The IPv4 address will be displayed in the Arduino IDE's Serial Monitor. Enter this IPv4 address into your web browser to navigate to the web server.
  4. Configure the CAN Configurations on the WebServer
  5. Start Connector/qt_application_frontend.py or the dist/ConnectorApp.exe, the UDP traffic can also be analyzed with Wireshark by filtering for CANeth
  6. Start CANoe or Tools/canDevice.py

In the linked YouTube video a quick, visual introduction for the Multi-Device CAN-WiFi Network use case and how to use the Connector application is provided. The video summarizes the aforementioned steps for practical work with the code.

Additional resources for understanding CAN and programming CANeth

Parts

15
QtyValueFootprintReferences
3FiducialMisc:FiducialFID1, FID2, FID3
2390Resistor_SMD:R_0603_1608MetricR1, R2
2Conn_01x10_SocketConnector_PinSocket_2.54mm:PinSocket_1x10_P2.54mm_VerticalJ1, J2
1100nFCapacitor_SMD:C_0603_1608MetricC1
1120Resistor_SMD:R_0603_1608MetricR3
1Conn_01x02_PinConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ3
1Conn_02x05_Odd_EvenConnector_IDC:IDC-Header_2x05_P2.54mm_HorizontalJ6
1PESD2CANSemiconductor:PESD2CANU2
1TCAN332GDCNTIC:TCAN332GDCNTU1
1blueLED_SMD:LED_0603_1608MetricTXCAN1
1orangeLED_SMD:LED_0603_1608MetricRXCAN1

Similar boards

  • 4 layers50 × 50 mmHSCanT, the printed circuit board in 3D

    HSCanT

    cherry-embedded/HSCanT-hardware

    HSCanT is a USB to 4-channel CAN FD tool designed based on the HPM5321 chip.

    130 parts52Apache-2.0
  • 2 layers26 × 13.6 mmCFDC embedded, the printed circuit board in 3D

    CFDC embedded

    ucandevices/CFDC_embedded

    Embedded code and PCB for CAN FD to USB converter

    36 parts15LGPL-3.0
  • 4 layers55 × 35 mmCarrier, the printed circuit board in 3D

    Carrier

    jonsole/toyotune

    Daughter-board for reprogramming 1990's Toyota ECUs

    30 parts8GPL-3.0
  • 2 layers52 × 109 mmGlasgow can, the printed circuit board in 3D

    Glasgow can

    attie/glasgow-can

    CAN Interface addon for Glasgow

    46 parts6BSD-3-Clause
  • 4 layers50 × 50 mmBusted umbrella, the printed circuit board in 3D

    Busted umbrella

    useless-branch/busted-umbrella

    USB to CAN FD

    45 parts2Apache-2.0
  • 2 layers80 × 60 mmKNX2HovalGateway, the printed circuit board in 3D

    KNX2HovalGateway

    Blizzard26/OAM-KNX2HovalGateway

    OpenKNX Application to connect KNX Bus to Hoval TopTronic Bus

    41 parts1
  • 6 layers56.7 × 54.7 mmBetter md80, the printed circuit board in 3D

    Better md80

    darshp848/bldc-controller-60v

    60 V, 20 A / 80 A peak BLDC motor controller that fits the MD80 v3.0 mounting. KiCad 10, 6 layers.

    144 parts1

Questions

How big is the CAN Shield PCB?

It measures 29 × 26.5 mm and has 2 copper layers, 1.6 mm thick.

What parts does the CAN Shield use?

15 parts, built around the PESD2CAN. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the CAN Shield KiCad files?

From the X1L3F/ESP32-CAN-Shield repository on GitHub, at the commit this page was made from: the board is CAN-Shield/CAN-Shield.kicad_pcb and its schematic CAN-Shield/CAN-Shield.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the CAN Shield design in my own project?

Its repository states no licence, so its author keeps all rights: ask X1L3F before reusing the design.