The TWAI (Two-Wire Automotive Interface) was developed/applied by Espressif for the ESP32 microcontroller family, effectively implementing CAN Classic.
TWAI is a highly reliable, multi-master, real-time, serial asynchronous communication protocol designed for automotive and industrial applications.
The TWAI controller is not compatible with ISO11898-1 FD Format frames and will interpret them as errors. TWAI is effectively “CAN Classic,” not CAN-FD, which is what the automotive industry & promoters such as STMicroelectronics, Infineon, NXP, Texas Instruments, Kvaser, Bosch, Daimler, and GM wouldn't appreciate Espressif referring to their transceiver as “CAN,” which could confuse.
The TWAI standard supports both 11-bit and 29-bit identifiers. The protocol supports message prioritization with lossless arbitration, automatic retransmission, and fault confinement mechanisms. The ESP32 microcontroller includes TWAI controllers, allowing for the creation of one driver instance, as follows:
| Platform | TWAI busses |
|---|---|
| ESP8266 | 0 |
| ESP32 | 1 |
| ESP32-S2 | 1 |
| ESP32-S3 | 1 |
| ESP32-C2(ESP8684) | 0 |
| ESP32-C3(ESP8685) | 1 |
| ESP32-C5 | 2 |
| ESP32-C6 | 2 |
| ESP32-C61 | 2 |
| ESP32-H2 | 1 |
| ESP32-P4 | 3 |
TWAI messages come in different types, each defined by its header. A typical data frame mainly includes a header and a data payload, with a structure similar to the following:
| Page | Date | Tags |
|---|---|---|
| 2025/11/19 16:18 | esp8266, esp32, esp32-c2, esp32-c3, esp32-c5, esp32-c6, esp32-c61, esp32-h2, esp32-s2, esp32-s3, esp32-p4, espressif systems, communication, ethernet, ip, wi-fi, thread, zigbee, matter, homekit, bluetooth, mqtt, adc, spi, uart, i2c, i2s, rmt, pwm, usb, usb otg, twai | |
| 2025/11/20 21:20 | bus, communication, as-i, basic, can, twai, espressif, esp32 |
This page has been accessed for: Today: 3, Until now: 10