I'm trying to set up a CAN Bus communication system using two ESP32 WROOM modules, each connected to its own MCP2515 . I'm using the mcp2515.h Library by autowp to manage communication, with one ESP32 acting as a sender and the other as a receiver.
Despite successful initialization on both sides, the receiver ESP32 does not receive any data, even though the sender prints messages indicating that frames are being sent.
Setup:
ESP32 #1 (Sender)
MCP2515 CS on GPIO 5
SPI pins: default (SCK=18, MISO=19, MOSI=23)
Sending frame every second with ID 0x123
ESP32 #2 (Receiver)
Identical wiring, using checkMessage() and readMessage() in the loop
Bitrate: CAN_500KBPS
Oscillator setting: MCP_8MHZ
Both MCP2515 modules are physically connected with:
CAN_H to CAN_H
CAN_L to CAN_L
Common GND
120Ω resistor across CAN_H and CAN_L at each end
In place of the word salad an annotated schematic will make it much easier to follow. The reason I ask it appears there are parts missing. With what you are putting together either end can be both a sender and receiver. Slow the buss down so you can get it working. Also have at least a meter of wire between nodes. With it turned off what is the bus resistance.
// ESP32 connections
// MCP2515 INT to ESP32 GPIO22
// MCP2515 SCK to ESP32 GPIO18 CLK
// MCP2515 SI to ESP32 GPIO23 MOSI
// MCP2515 SO to ESP32 GPIO19 MISO
// MCP2515 CS to ESP32 GPIO5 CS
// MCP2515 GND to ESP32 GND
// MCP2515 VCC to ESP32 3.3V
and run the File>Examples>mcp_can>CAN_loopback test program to check SPI connection is OK