Site Information

 Loading... Please wait...


ESP32: CAN Bus Programming with MCP2515 and MCP2517FD

Posted by Wilfried Voss on

espBerry - ESP32 Development Board with Dual Isolated CAN Bus HAT

For good reasons, the ESP32 processor is a prevalent choice for embedded hardware development. Besides considerable memory resources, it provides various hardware features for many applications, most prominently the Internet of Things (IoT). All that comes with more than reasonable price tags, specifically when you use one of the multiple ESP32 development modules. And since we at Copperhill Technologies are primarily involved with CAN Bus, SAE J1939, and NMEA 2000 development, we welcomed the integration of an internal CAN controller. Consequently, we offer a variety of hardware components based on the ESP32 and using the onboard CAN controller, such as our SAE J1939 ECU Simulator with USB Port. Furthermore, we offer the user-programmable ESP 32 WiFi, Bluetooth Classic, BLE, and Controller Area Network (CAN) Module.

So, the question arises: Why use an external MCP2515 CAN Controller? Well, first of all, the ESP32, combined with its two SPI connections, can control up to six CAN controllers. Add the internal controller, and you get seven, even though it requires a different code. Furthermore, while the internal CAN Bus controller is much appreciated, you should be aware of some functionality limitations. These (not necessarily critical) limitations include a restricted set of baud rate settings and the lack of support for CAN FD.

We have used the available MCP2515 resources to create two products:

  1. ESP32 Development Board with NMEA 2000 & NMEA 0183 HAT...
  2. ESP32 Development Board with Dual Isolated CAN Bus HAT...

Both modules come with extensive documentation and plenty of code samples.

We are currently working on combining our espBerry board with our PICAN FD and PICAN FD Duo HATs. Both HATS use the Microchip MCP2517FD controllers. We will post an application note as soon as it is available. If you need further information, please feel free to contact us. offers a unified library, all-inclusive of code, which implements a CAN Busdriver for the built-in CAN hardware on an ESP32. It also implements a driver for the MCP2517FD SPI-connected CAN module. The built-in CAN port is CAN0, and the MCP2517FD is CAN1. This library works directly with the EVTV ESP32-Due board. However, with minor modifications, either driver found within this library could be used on other boards.

For further information on ESP32 CAN Bus programming, see our posts:

Connecting any CAN Bus, SAE J1939, or NMEA 2000 application to the internet is easily accomplished using the information in this post. To learn more about a connection to Bluetooth, BLE, or WiFi, we recommend the following literature:

Electronics Projects with the ESP8266 and ESP32: Building Web Pages, Applications, and WiFi Enabled DevicesElectronics Projects with the ESP8266 and ESP32: Building Web Pages, Applications, and WiFi Enabled Devices

Copperhill Technologies highly recommends using this book for your wireless application projects. Yes, many good books and free online resources are available these days, but this is the book we are using. It made our approach to Bluetooth, BLE, and WIFI a breeze. Programming wireless applications without hassles was fun, and we will share them on this web page.

Projects throughout the book utilize the wireless functionality and processing power of the ESP microcontrollers. Projects are built in the Arduino IDE, so you don't need to download other programming software. In addition, mobile apps are now ubiquitous, making the app build projects of the book very relevant, as are the web page design projects.

In Electronics Projects with the ESP8266 and ESP32, you'll see how easy and practical it is to access information over the internet, develop web pages, build mobile apps to remotely control devices with speech recognition, or incorporate Google Maps in a GPS route tracking app.

More Information...

Arduino Uno R4 Combines CAN Bus Port with IoT Capabilities

The  Arduino UNO R4 WiFi combines the RA4M1 microprocessor from Renesas with the ESP32-S3 from Espressif, forming an all-in-one tool for engineers with improved processing power and a diverse array of new peripherals. With built-in Wi-Fi and Bluetooth abilities, the UNO R4 WiFi allows makers to launch into unlimited innovative opportunities. Likewise, this universal board boasts a [...]

Read More »

ESP32 Project: USB to Bluetooth Gateway

The ESP32 processor allows the integration of Wi-Fi, Bluetooth, and Bluetooth LE (BLE) for a wide range of IoT (Internet of Things) applications. Using Wi-Fi ensures connectivity within a large radius. At the same time, Bluetooth allows the user to easily detect (with low-energy beacons) a module and connect it to an Android/iOS smartphone or [...]

Read More »

IoT-Enabled Control, Data Logger, and Data Transmission Platform with CAN Bus Interface

The RapidM2M C3 by Microtronics represents a control, data logger, and data transmission platform with IoT capabilities, suitable for remote control, automation, and control tasks in industrial automation. The device includes a PLC (Programmable Logic Controller), router, firewall, and data transmission to a web platform. Process-related requirements are pre-configured, minimizing the solution integration effort. Data from analog sensors [...]

Read More »

Arduino-Compatible Microsoft Azure Certified IoT Development Kit with Visual Studio Code Support

This Microsoft Azure Certified IoT DevKit (IOT-AZ3166) is an all-in-one kit optimized for prototyping and developing Internet of Things (IoT) applications leveraging Microsoft Azure services. It supplies an Arduino-compatible board with multiple peripherals such as an OLED display, sensors, hardware debugging chip (ST-Link), and security chip. The project collection offers creative examples for learning and reference, plus [...]

Read More »

Raspberry Pi Compute Module With CAN FD for Automation and IoT Applications

Kontron announced the release of their Pi-Tron CM4 computer with Linux OS, which utilizes the fourth-generation Raspberry Pi compute module with the 1,5-GHz, 64-bit Broadcom BCM2711 chip and four Arm Cortex-A72 processors. The computer’s steel housing allows for universal use, e.g., for automation and IoT (Internet of Things) applications. Depending on the variant, it provides a 1-GiB, 2-GB, [...]

Read More »

A New Generation of SAE J1939 Gateway, ECU Simulator, and Starter Kit

Like many other businesses, we have to deal with the global shortage of electronic components. For instance, the NXP LPC 17xx processors we used for our SAE J1939 gateways and the starter kit are not available at this time. Even worse, there is no reliable information if/when production resumes. This situation forced us to rethink [...]

Read More »

ESP32 Starter and Development Kits for Building Bluetooth and WiFi Enabled IoT Devices

The integration of Wi-Fi, Bluetooth, and Bluetooth LE allow a wide range of applications with ESP32 modules. Wi-Fi ensures connectivity within a large radius, while Bluetooth allows the user to easily detect (with low-energy beacons) a module and connect it to a smartphone. The chips add priceless functionality and versatility to your applications with in-built [...]

Read More »

Embedded CAN Bus, SAE J1939, NMEA 2000 Development With ESP32

Like many businesses in the CAN Bus marketplace, we have struggled with the global shortage of electronic components. For instance, our SAE J1939 gateways are equipped with NXP processors, mainly the LPC1754 and LPC1768. Unfortunately, both processors are currently unavailable, and they come with remarkably long delivery times that go well into next year. We [...]

Read More »

Industrial Cellular 4G LTE Router For Advanced IoT Applications

Phytools announced adding a new suite of products to their portfolio of industrial networking solutions. The Teltonika Networks product line incorporates dependable, secure, and easy-to-use cellular 4G LTE mobile routers, gateways, and switches for industrial, enterprise, IoT, and M2M applications. The  RUT240 is one of the most popular industrial 4G LTE WiFi routers for professional M2M and [...]

Read More »