Function Description

Use ESP32 internal CAN controller resources to realize CAN bus data transmission and reception. Note: You need to connect to the device before using CAN UNIT .

Init bus n extframe True/False mode x baudrate TX RX

  • Initialize the CAN bus, configure whether to expand the frame mode, work mode (normal mode, loopback mode, etc.) and baud rate settings

Get state of the controller

  • Get CAN controller status

If any message wating on the FIFO

  • Check if there is unread data in the FIFO

Send Message with id x

  • Send a piece of data and specify the ID of the data frame, the ID length is 1 byte, the incoming data type is required to be list or tuple, and the data length of the data frame is required to be 8 bytes.

Receive message

  • Receive data

Set filter bank x mode x message

  • Set filter group

Clear filter

  • Clear filter group

Clear TX queue

  • Clear the sending queue

Clear RX queue

  • Clear the receive queue


  • Restart the CAN bus


  • Stop CAN bus


Test case: Use two M5Core devices, respectively connect CAN UNIT to PORT C (if you need to use a different port, please change the pin configuration in the initialization program), run the following programs respectively, and press button A to send the data frame.

On This Page