Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use Adafruit Feather RP2040 CAN Bus: Examples, Pinouts, and Specs

Image of Adafruit Feather RP2040 CAN BusDesign with Adafruit Feather RP2040 CAN Bus in Cirkit Designer

Introduction

The Adafruit Feather RP2040 CAN Bus is a compact and versatile microcontroller board designed for robust communication in automotive, industrial, and IoT applications. Powered by the Raspberry Pi RP2040 chip, this board integrates CAN Bus capabilities, making it ideal for projects requiring reliable communication between devices in a network. Its small form factor and compatibility with the Feather ecosystem make it a powerful tool for developers and hobbyists alike.

Explore Projects Built with Adafruit Feather RP2040 CAN Bus

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino UNO WiFi CAN Bus Interface with Sensor/Actuator Module: A project utilizing Adafruit Feather RP2040 CAN Bus in a practical application
Arduino UNO WiFi CAN Bus Interface with Sensor/Actuator Module

This circuit features two Arduino UNO R4 WiFi microcontrollers interfaced with NS-LS2 light sensors and CAN_SN65HVD230 CAN bus transceivers. The Arduinos are configured to read light intensity data from the NS-LS2 sensors and communicate with each other over a CAN network, likely for a distributed sensing application. Power distribution is managed with 3.3V and 5V connections to the respective components, and the ground connections are shared across the devices to complete the circuit.

Open Project in Cirkit Designer

Common Applications


Technical Specifications

The following table outlines the key technical details of the Adafruit Feather RP2040 CAN Bus:

Parameter Specification
Microcontroller Raspberry Pi RP2040 (Dual-core ARM Cortex-M0+ @ 133 MHz)
Flash Memory 8 MB QSPI Flash
RAM 264 KB SRAM
CAN Bus Controller MCP2515 with MCP2562 CAN transceiver
Operating Voltage 3.3V logic level
Input Voltage 3.3V to 6V (via USB-C or LiPo battery)
Connectivity CAN Bus, I2C, SPI, UART
GPIO Pins 21 GPIO pins (3.3V logic)
Power Options USB-C, LiPo battery (with built-in charging circuit)
Dimensions 51mm x 23mm x 8mm
Weight 5.5g

Pin Configuration

The Adafruit Feather RP2040 CAN Bus features a standard Feather pinout. Below is the pin configuration:

Pin Name Description
1 USB USB-C connector for power and programming
2 BAT LiPo battery input
3 3V3 3.3V output
4 GND Ground
5 A0-A5 Analog input pins (3.3V max)
6 D0-D13 Digital I/O pins (3.3V logic)
7 SCL/SDA I2C communication pins
8 RX/TX UART communication pins
9 CANH/CANL CAN Bus high and low lines
10 EN Enable pin to turn the board on/off
11 RST Reset pin

Usage Instructions

Getting Started

  1. Powering the Board:

    • Connect the board to your computer via the USB-C port for power and programming.
    • Alternatively, use a 3.7V LiPo battery for portable applications.
  2. Installing Software:

    • Download and install the latest version of the Arduino IDE or CircuitPython.
    • Install the necessary libraries for CAN Bus communication (e.g., Adafruit_MCP2515).
  3. Connecting to a CAN Bus Network:

    • Use the CANH and CANL pins to connect the board to the CAN Bus network.
    • Ensure proper termination resistors (typically 120Ω) are present at both ends of the CAN Bus.

Example Circuit

Below is a simple example of connecting the Adafruit Feather RP2040 CAN Bus to a CAN Bus network:

+-------------------+       +-------------------+
| Feather RP2040    |       | CAN Bus Device    |
|                   |       |                   |
| CANH ------------ CANH    CANH ------------ CANH
| CANL ------------ CANL    CANL ------------ CANL
+-------------------+       +-------------------+

Example Code

The following Arduino sketch demonstrates how to send and receive messages on the CAN Bus using the Adafruit Feather RP2040 CAN Bus:

#include <Adafruit_MCP2515.h>

// Create an MCP2515 instance for CAN Bus communication
Adafruit_MCP2515 CAN;

// Define a CAN message object
struct CANMessage {
  uint32_t id;       // Message ID
  uint8_t data[8];   // Data payload (up to 8 bytes)
  uint8_t length;    // Length of the data payload
};

void setup() {
  Serial.begin(115200); // Initialize serial communication for debugging
  while (!Serial);

  // Initialize the CAN Bus at 500 kbps
  if (!CAN.begin(500000)) {
    Serial.println("Failed to initialize CAN Bus!");
    while (1);
  }
  Serial.println("CAN Bus initialized successfully.");
}

void loop() {
  // Create a message to send
  CANMessage message;
  message.id = 0x123;          // Set the message ID
  message.length = 2;          // Set the data length
  message.data[0] = 0xAB;      // First byte of data
  message.data[1] = 0xCD;      // Second byte of data

  // Send the message
  if (CAN.sendMessage(&message)) {
    Serial.println("Message sent successfully!");
  } else {
    Serial.println("Failed to send message.");
  }

  delay(1000); // Wait 1 second before sending the next message
}

Important Considerations


Troubleshooting and FAQs

Common Issues

  1. CAN Bus Communication Fails:

    • Solution: Verify the wiring of CANH and CANL. Ensure proper termination resistors are in place.
  2. Board Not Recognized by Computer:

    • Solution: Check the USB-C cable and port. Ensure the board is in bootloader mode if necessary.
  3. Message Not Sent or Received:

    • Solution: Confirm the CAN Bus speed matches across all devices. Check for conflicts in message IDs.

FAQs

Q: Can I use this board with CircuitPython?
A: Yes, the Adafruit Feather RP2040 CAN Bus is fully compatible with CircuitPython. Install the necessary libraries from the Adafruit CircuitPython bundle.

Q: What is the maximum CAN Bus speed supported?
A: The MCP2515 controller supports speeds up to 1 Mbps.

Q: Can I power the board with a LiPo battery?
A: Yes, the board includes a built-in charging circuit for 3.7V LiPo batteries.


Additional Resources


This documentation provides a comprehensive guide to using the Adafruit Feather RP2040 CAN Bus. Whether you're a beginner or an experienced developer, this board offers a powerful platform for your next CAN Bus project.