This post will demonstrate how to add a CAN Bus port to the ESP32-WROOM32 development board, i.e., regarding hardware and software.
As a matter of fact, we already offer a hardware utilizing the ESP32 processor and an onboard CAN Bus transceiver as shown in the image to the left.
The ESP32 WiFi, Bluetooth Classic, BLE, CAN Bus Module comes with an onboard ESP32 WROOM-32 WiFi, Bluetooth Classic, BLE Module, and a CAN Bus port with a transceiver. Also, onboard is an RGB LED, IO pins on a 0.1" pad.
The programming is accomplished through the popular Arduino IDE connected to the USB-to-Serial converter with USB-C connector, automatic bootloader and reset.
However, if you don’t need the supported 12 VDC power connection and extended temperature range (specifically suited for automotive and industrial applications) but are satisfied with the power supplied per USB port, you may prefer the lower-priced application as described here.
For this project we are using:
- ESP32-WROOM-32D Bluetooth, BLE, And WIFI Development Board with PCB Antenna...
- CAN Bus Mini Breakout Board...
The ESP32 is a series of low-cost, low-power system-on-chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth. The ESP32 series employs a Tensilica Xtensa LX6 microprocessor in both dual-core and single-core variations and includes built-in antenna switches, RF balun, power amplifier, low-noise receive amplifier, filters, and power management modules. It is a successor to the ESP8266 SoC.
The ESP32 DevKit Board contains the ESP-WROOM-32 as the main module and some additional hardware to easily program ESP32 and connect with the GPIO Pins.
- Single or Dual-Core 32-bit LX6 Microprocessor with clock frequency up to 240 MHz.
- 520 KB of SRAM, 448 KB of ROM and 16 KB of RTC SRAM.
- Supports 802.11 b/g/n Wi-Fi connectivity with speeds up to 150 Mbps.
- Support for both Classic Bluetooth v4.2 and BLE specifications.
- 34 Programmable GPIOs.
- Up to 18 channels of 12-bit SAR ADC and 2 channels of 8-bit DAC
- Serial Connectivity include 4 x SPI, 2 x I2C, 2 x I2S, 3 x UART.
- Ethernet MAC for physical LAN Communication (requires external PHY).
- 1 Host controller for SD/SDIO/MMC and 1 Slave controller for SDIO/SPI.
- Motor PWM and up to 16-channels of LED PWM.
- Secure Boot and Flash Encryption.
- Cryptographic Hardware Acceleration for AES, Hash (SHA-2), RSA, ECC and RNG.
ESP32 Board Components
- ESP-WROOM-32 Module
- Two rows of IO Pins (with 15 pins on each side)
- CP2012 USB – UART Bridge IC
- Micro–USB Connector (for power and programming)
- AMS1117 3.3V Regulator IC
- Enable Button (for Reset)
- Boot Button (for flashing)
- Power LED (Red)
- Some passive components
CAN Bus Connection
The ESP32 integrates a CAN Bus controller compatible with the NXP SJA1000. Thus, it is CAN 2.0B specification compliant.
As with the SJA1000, the ESP32 CAN Bus controller provides only the data link layer and the physical layer signaling sublayer. Therefore, an external transceiver module is required, which converts the CAN-RX and CAN-TX signals of the ESP32 into CAN_H and CAN_L bus signals. The transceiver, such as the MCP2551 or SN65HVD23X, provides compatibility with ISO 11898-2.
Note:The SJA1000 does not support CAN-FD and is not CAN-FD tolerant.
CAN_TXD = ESP32 – IO25
CAN_RXD = ESP32 – IO26
For better resolution, download the PDF file.
CAN Bus Programming
For the CAN Bus programming we used the resources as shown in the following. We didn’t deem it necessary to repeat information in this post that is already sufficiently provided.
The CAN Bus driver source code plus code samples can be found at:
- sandeepmistry/arduino-CAN: An Arduino library for sending and receiving data using CAN bus. (github.com)
For instructions on how to program the ESP32 using the Arduino IDE, see:
Further Development Resources
- ESP32-DevKitC V4 Getting Started Guide...
- ESP32-WROOM-32D & ESP32-WROOM-32U Data Sheet (PDF)...
- Getting Started with ESP 32 | Introduction to ESP32...
- ESP32 vs ESP8266 - Which One To Choose?
- How to Program ESP32 with Arduino IDE?
- Interfacing I2C LCD with ESP32 | ESP32 I2C LCD Tutorial...
- A Beginner's Tutorial on ESP32 Bluetooth | Learn…
- A Complete Beginner’s Tutorial on How to Create…
- In-depth tutorial on ESP32 Servo Control | Web…
The ESP32, a low-cost MCU with integrated Wi-Fi and BLE capabilities, comes with a variety of modules and development boards for building IoT applications efficiently. Wi-Fi and BLE are standard network stacks for Internet-of-Things applications providing cost-effective solutions for your business and project requirements.
This book is a fundamental guide for developing ESP32 programs and starts by explaining GPIO (General Purpose I/O) programming with sensor devices. The reader gets up to speed with ESP32 development through several IoT projects such as weather stations, sensor loggers, smart homes, Wi-Fi cams, and Wi-Fi wardriving. The reader learns how to use ESP32 boards to facilitate interactions between mobile applications and cloud servers, such as AWS.
By the end of this book, you'll have learned how to control a range of IoT projects using the ESP32 chip.
Bluetooth OBD2 Scanner Turns iPhone, iPad, Android, Kindle Fire or Windows Device Into Diagnostic Scan Tool
This Bluetooth OBD2 scanner gives you more codes and advanced parameters than any other wireless OBD scanner - Unlimited FREE OEM data upgrades for Ford, GM, Mazda, Nissan/Infiniti, Toyota/Lexus/Scion vehicles. The OBDLink MX+ reads and clears codes on all 1996 and newer OBD-II compliant vehicles. The OBDLink App (included) provides advanced diagnostics, trip logging, multi-parameter graphing, customizable gauges, [...]
The OBDLink ScanTool ECUsim 2000 ECU CAN Simulator for OBD-II Development is a small diagnostic tool that is ideal for DIY testing and development of OBD services and software. The CAN Bus (ISO 15765) model supports a range of parameter IDs, diagnostic trouble codes (DTCs), freeze frames, and SAE J1979 modes: 1, 2, 3, 4, 7, 9, and [...]
The OBD-2 Automotive Code Encyclopedia and Cross-Reference Guide By Mandy Concepcion presents information without the sponsoring of any one particular company or organization. No endorsements are made or implied. Any reference to a company or organization is done purely for the sake of information.You gain access to a series of valuable cross-reference automotive sensor values, [...]
In all regularity, I receive inquiries from users attempting to connect their Raspberry Pi with PiCAN CAN Bus interface to their vehicle's OBD-II diagnostics port, and the questions asked prompted me to write down the essentials to consider for such a project.Please, note: The following refers to reading CAN Bus data from a vehicle's OBD-II [...]
The ANCEL AD310 OBD II Scanner Car Engine Fault Code Reader And CAN Bus Diagnostic Scan Tool is an excellent upgrade from the more basic diagnostic Code Reader. The primary function of this scanner is detecting the Engine System, and reading and clearing the error codes. Once plugged into your vehicle's 16pin OBD-II diagnostics port, the unit powers up [...]
The Society of Automotive Engineers (SAE) has published a book that guides readers on how to collect and evaluate data from CAN Bus in-vehicle networks of light-duty (LD) vehicles. Data Acquisition from LD Vehicles Using OBD and CAN by Eric Walter and Richard Walter addresses product engineers, service technicians, fleet managers, and all interested in acquiring data efficiently [...]
The CR-HD unit is the perfect tool for diagnosing and clearing heavy duty diagnostic trouble codes. It covers SAE J1587, SAE J1708 and SAE J1939 protocols for accessing Engine, Transmission, Brakes and more. It features a 2.8” full color LCD display and is ergonomic, highly portable and easy to use. Perfect Scan Tool for Heavy Duty Truck works on [...]
Sierra Wireless has announced their Airlink MP70 router to support analytics and reporting for cloud-based vehicle fleet operations. The Airlink MP70 router enables the communication of SAE J1939 or OBD-II vehicle data to the cloud. The Airlink Management Service – Advanced Reporting and Analytics (Alms Ara) services enable organizations to manage their vehicle fleets using Sierra Wireless’ industry-leading Airlink [...]
This CAN-Bus ECU simulator by SK Pang Electronics uses the popular mbed NXP LPC1768 module. It is useful for testing OBD-II interfaces and writing diagnostic software. ECU PIDs parameters are adjustable via menu options.The mbed NXP LPC1768 is an easy-to-use MCU development board designed for rapid prototyping. At its heart is a powerful 32-bit ARM Cortex-M3 processor running [...]