ESP32-S3
Posted: Wed Feb 07, 2024 12:13 pm
Hi. I’m trying to implement the CAN communication protocol with the ESP32-S3 to read and write the data on the 29-bit extended CAN network. I saw this module called ESP32-S3-CAN from UltraMax on Amazon. Here is the link: https://www.amazon.co.uk/ULTRAMAX-BOAES ... C67&sr=8-3 That has an on-board SN65HVD232 CAN transceiver. For the software, I’m using Sandeep Mistry’s Arduino CAN library in the Arduino IDE. The code is here
But the problem is, it is not compiling for the ESP32-S3, and tonnes of errors just popped up when I tried to compile this code. I checked their datasheet, and there is the installation programme for TWAI installation in C. But that is for the ESP-IDF platform and I have not enough knowledge to use ESP32 with ESP-IDF. So, is there any library available for the CAN bus in the Arduino IDE that is the same as Sandeep Mistry’s Arduino CAN for the ESP32-S3? Thanks.
Code: Select all
#include <CAN.h>
#define TX_GPIO_NUM 36
#define RX_GPIO_NUM 35
void setup() {
Serial.begin(115200);
while (!Serial)
;
delay(1000);
CAN.setPins(RX_GPIO_NUM, TX_GPIO_NUM);
if (!CAN.begin(500E3)) {
Serial.println("CAN failed!");
while (1)
;
} else {
Serial.println("CAN Initialized");
}
}
void loop() {
// Send test data on CAN ID 0xEDDF wih Extended 29 bit
CAN.beginExtendedPacket(0xEDDF);
CAN.write(0x90);
CAN.write(0x87);
CAN.write(0x00);
CAN.write(0x00);
CAN.write(0x00);
CAN.endPacket();
Serial.println("done");
delay(1000); //Sending in every 1 sec
}