Skip to content

CAN bus testing project with Arduino Uno R4 WiFi LED matrix support

agonsep/can-testing

Repository files navigation

CAN Bus Testing Project

A PlatformIO project for testing CAN bus communication between microcontrollers using MCP2515 CAN controllers.

Hardware

  • 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)

Project Structure

├── 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

Features

CAN Receiver (Uno R4 WiFi)

  • 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

CAN Transmitter

  • Sends 16-character messages split into two 8-byte CAN frames
  • Generates messages with format: "ALEX " + 8 random letters + " " + sequence number
  • Configurable transmission interval

Python Monitor

  • Monitors CAN bus traffic via Waveshare USB-CAN adapter
  • Parses and displays CAN frames in real-time
  • Supports variable-length frame format

Getting Started

  1. 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
  2. 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
  3. Python Monitoring

    # Update PORT in main.py to match your USB-CAN adapter
    python main.py

Configuration

CAN Settings

  • Bitrate: 500 KBPS
  • Crystal: 8 MHz
  • Frame IDs: 0x123 (first frame), 0x124 (second frame)

Message Format

  • Total Length: 16 characters
  • Frame 1 (0x123): Bytes 0-7
  • Frame 2 (0x124): Bytes 8-15
  • Timeout: 1 second for complete message assembly

Dependencies

  • autowp/autowp-mcp2515@^1.2.1 - MCP2515 CAN controller library
  • Arduino_LED_Matrix - LED matrix support (Uno R4 WiFi)
  • pyserial - Python serial communication (for monitoring)

Troubleshooting

  1. No CAN communication

    • Check wiring connections
    • Verify termination resistors (120Ω)
    • Ensure matching bitrates and crystal frequencies
  2. Incomplete messages

    • Check for electrical noise
    • Verify frame timing
    • Monitor timeout messages in serial output
  3. LED Matrix not working

    • Ensure using Arduino Uno R4 WiFi
    • Check LED_Matrix library installation

License

MIT License - Feel free to use and modify for your projects.

About

CAN bus testing project with Arduino Uno R4 WiFi LED matrix support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published