A PlatformIO project for testing CAN bus communication between microcontrollers using MCP2515 CAN controllers.
- Arduino Uno R4 WiFi (Receiver with LED Matrix)
- Arduino Nano ESP32 (Alternative platform)
- MCP2515 CAN Controller modules
- LED Matrix (for message display on Uno R4 WiFi)
├── CANReceive/ # Generic CAN receiver
├── CANReceiveUno/ # Arduino Uno R4 WiFi CAN receiver with LED matrix
├── CANTransmit/ # CAN transmitter
├── main.py # Python script for monitoring CAN bus via serial
└── platformio.ini # PlatformIO configuration
- Receives CAN messages split across two frames (ID: 0x123, 0x124)
- Assembles 16-character messages from 8-byte frames
- Displays message reception status on LED matrix
- Serial debugging output
- Timeout protection for incomplete messages
- Memory-safe buffer handling
- Sends 16-character messages split into two 8-byte CAN frames
- Generates messages with format: "ALEX " + 8 random letters + " " + sequence number
- Configurable transmission interval
- Monitors CAN bus traffic via Waveshare USB-CAN adapter
- Parses and displays CAN frames in real-time
- Supports variable-length frame format
-
Hardware Setup
- Connect MCP2515 modules to your microcontrollers
- Wire CS pin to GPIO 5
- Connect CAN_H and CAN_L between modules
- Add 120Ω termination resistors at both ends
-
Software Setup
# Install PlatformIO pip install platformio # Build for Arduino Uno R4 WiFi pio run -e uno_r4_wifi # Build for Arduino Nano ESP32 pio run -e arduino_nano_esp32 # Upload to device pio run -e uno_r4_wifi -t upload
-
Python Monitoring
# Update PORT in main.py to match your USB-CAN adapter python main.py
- Bitrate: 500 KBPS
- Crystal: 8 MHz
- Frame IDs: 0x123 (first frame), 0x124 (second frame)
- Total Length: 16 characters
- Frame 1 (0x123): Bytes 0-7
- Frame 2 (0x124): Bytes 8-15
- Timeout: 1 second for complete message assembly
autowp/autowp-mcp2515@^1.2.1- MCP2515 CAN controller libraryArduino_LED_Matrix- LED matrix support (Uno R4 WiFi)pyserial- Python serial communication (for monitoring)
-
No CAN communication
- Check wiring connections
- Verify termination resistors (120Ω)
- Ensure matching bitrates and crystal frequencies
-
Incomplete messages
- Check for electrical noise
- Verify frame timing
- Monitor timeout messages in serial output
-
LED Matrix not working
- Ensure using Arduino Uno R4 WiFi
- Check LED_Matrix library installation
MIT License - Feel free to use and modify for your projects.