Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Yes—a Raspberry Pi Pico can communicate on a CAN bus using Kevin O’Connor’s open-source can2040 library, but the Pico cannot connect directly to CANH and CANL. The library implements the CAN controller functions in software and RP2040/RP2350 PIO; you still need an external CAN transceiver, correctly wired bus, termination, and another active CAN node. The project documents CAN 2.0B data frames at rates up to 1 Mbit/s.

What can2040 does—and what it does not

Many microcontrollers have a dedicated CAN controller peripheral. The RP2040 does not, so can2040 uses the chip’s Programmable I/O (PIO) hardware and software to implement CAN controller behavior. Kevin O’Connor’s project supports Raspberry Pi RP2040 and RP2350 microcontrollers and documents CAN 2.0B data frames up to 1 Mbit/s.

That makes can2040 a controller implementation, not a complete electrical CAN interface. The Pico’s GPIO signals are not the differential CANH/CANL bus signals. An external transceiver is required to convert between them; connecting Pico GPIO directly to CANH or CANL is not a substitute.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How PIO handles CAN

The implementation uses one PIO block and all four of that block’s state machines. PIO runs timing-sensitive operations alongside the ARM core, which reduces the amount of protocol work the CPU must handle directly.

#1 Best Overall
2Pcs Raspberry Pi Pico Development Board, Raspberry Pi RP2040 Dual-core ARM Cortex M0+ Processor, Running Up to 133 MHz, Support C/C++/Python, 2MB Quad SPI Flash Integrated with SPI/I2C/UART Interface
  • The Raspberry Pi Pico is a beginner-friendly microcontroller board that uses MicroPython to give you a taste of the Internet of Things and microcontrollers. The RP2040 is a well-designed microprocessor that can be utilized in almost any Internet of Things project. It has enough power to complete the task quickly.
  • 【Raspberry Pi RP2040 Microcontroller】Raspberry Pi Pico features Dual-core ARM Cortex M0+ processor, flexible clock running up to 133 MHz. With 264KB of SRAM, and 2MB of on-board Flash memory.Supports up to 16 MB of off chip flash memory via a dedicated QSPI bus
  • 【Multiple Software Support】Pico has rich and complete software support, it comes with a complete Rasberry Pi official C/C++ SDK, Micropython SDK.The programming and burning of Pico need to be carried out on the computer. Supported operating systems and computers include:Raspberry Pie with Raspberry Pi OS,Other platforms equipped with Debian based Linux system Computer with MacOS, Computers with Windows, etc.
  • 【Rich Hardware Interface】Raspberry Pi Pico has 30 GPIO pins, 4 pins for analog signal input and 26 × multi-function GPIO pins, 2 × SPI, 2 × I2C, 2 × UART, 3 × 12-bit ADC, 16 × controllable PWM channels.USB 1.1 supported by host and device, The installation mode can be flexibly selected by users to facilitate welding with other development boards.
  • 【Build Project in Tiny Size】Only 2.1cm*5.1cm ( as small as your thumb). Pico has been designed to use either soldered 0.1" pin-headers or can be used as a surface-mountable 'module'.
  • One state machine handles synchronization and bit sampling.
  • Another transfers received data through the receive FIFO.
  • Another handles CRC and acknowledgement matching.
  • The transmit state machine sends frames while participating in arbitration and acknowledgement.

CAN arbitration depends on nodes observing the bus while transmitting: a node that sends a recessive bit but observes a dominant one yields to the higher-priority frame. The transmit logic’s participation in this process is important; this is not simply a GPIO routine that sends bytes without regard to other bus traffic.

The project’s pio/can2040.pio source says the implementation is designed to run at 32 times the CAN bitrate. It also notes the PIO program’s 32-instruction limit, which constrains how the logic can be arranged. That internal timing figure is not a claim that the bus itself runs 32 times faster.

Rank #2
Freenove Raspberry Pi Pico Board Pre-Soldered Header, Dual-core Arm Cortex-M0+ Microcontroller, Development Board, Python C Java Code, Tutorial Example Projects
  • Raspberry Pi Pico: A tiny, fast, and versatile board built using dual-core Arm Cortex-M0+ processor (Comes with pinout card and stickers)
  • Detailed Tutorial: Provides step-by-step guide with MicroPython, C and Processing (Java) Code (The download link can be found on the product box) (No paper tutorial)
  • Example Projects: Each project has schematics, wiring diagrams, complete code and detailed explanations (Need extra items)
  • Easy to Use: Just connect the board to your computer (installed IDE) with the USB cable to program it
  • Get Support: Our technical support team is always ready to answer your questions

Hardware you need for a working bus

At minimum, the documented test setup needs a functioning CAN transceiver, CANH and CANL wiring, two 120-ohm termination resistors, at least one other CAN-enabled chip, and the same CAN bitrate configured on every node. The can2040 Tools documentation warns that an incomplete physical bus will not work even for debugging.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a transceiver module

A Raspberry Pi Pico paired with a Waveshare SN65HVD230 CAN Board is the example setup named in the project’s Tools documentation. An SN65HVD230 CAN transceiver module is a useful search phrase when looking for that type of hardware. Check the module’s pin labels and electrical requirements against its own documentation and your board; the can2040 software does not make a transceiver unnecessary.

Rank #3
Freenove Raspberry Pi Pico 2 W Board Pre-Soldered Header, Dual Arm Cortex-M33 and Dual Hazard3 RISC-V Microcontroller, Development Board, Tutorial Example Projects
  • Latest Version: Higher core clock speed, double memory, more powerful Arm cores, optional RISC-V cores (compared to the 1 series) (This W version has onboard wireless LAN and Bluetooth)
  • Switchable Cores: Allows users to choose between dual industry-standard Arm Cortex-M33 cores and dual open-hardware Hazard3 cores
  • Compatibility: Delivers a significant performance boost, while retaining software- and hardware-compatible with the 1 series
  • Detailed Tutorial: Provides step-by-step guide with MicroPython, C and Processing (Java) Code (The download link can be found on the product box) (No paper tutorial)
  • Example Projects: Each project has schematics, wiring diagrams, complete code and detailed explanations (Need extra items)

Wire and terminate the bus

  • Connect the Pico’s selected CAN RX and TX GPIOs to the corresponding logic-side pins on the transceiver, following the module’s pinout.
  • Connect the transceiver’s CANH and CANL pins to the matching bus lines. Do not connect the Pico’s GPIO directly to those bus wires.
  • Provide two 120-ohm termination resistors on the physical bus, as specified by the project’s minimum test setup.
  • Connect at least one other CAN-enabled device and configure all nodes for the same bitrate.

The project’s API example uses GPIO4 and GPIO5 at 500,000 bit/s. Those are illustrative values, not universal Pico pin requirements or a required bus speed. Select GPIOs that suit your wiring and board, and pass the chosen pins and bitrate to the library.

Integrate can2040 with the Pico SDK

The API guide’s example follows this order. Its GPIO and bitrate values are examples; adapt them to the transceiver wiring and bus you have built.

Rank #4
Treedix Breakout Board for PI PICO Flexible PCB Shield Board
  • This breakout board is specially made for Raspberry Pi Pico, with additional pin headers, which are fully compatible with the board
  • The product needs to be soldered by itself, and the pico can be inserted after successful welding
  • The breakout board is gold-plated on both sides and holes are plated, and the material of the PCB board is excellent
  • The breakout board is equipped with Raspberry Pi pico, which is convenient for users to develop and integrate flexibly
  • Note: The package does not include Raspberry Pi pico. This product needs to be soldered and assembled by yourself
  1. Allocate the controller state. Provide storage for a struct can2040.
  2. Set up PIO. Call can2040_setup() and select PIO0 or PIO1. The implementation uses all four state machines in the selected PIO block.
  3. Register callbacks. Use can2040_callback_config() to register receive, transmit, and error handling.
  4. Connect the PIO interrupt. Enable the PIO IRQ and call can2040_pio_irq_handler() from the interrupt handler.
  5. Start the bus. Call can2040_start() with the system clock, CAN bitrate, RX GPIO, and TX GPIO.

Callbacks run in IRQ context. Keep them short: the API guide recommends copying message data for processing later in normal context rather than doing lengthy work in the callback. Receive overflow is reported as CAN2040_NOTIFY_ERROR. The library does not perform receive filtering, so an application that needs to accept only selected messages must filter them itself.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Timing, memory, and interrupt considerations

Although PIO handles timing-sensitive CAN work, the implementation remains sensitive to interrupt latency. The API guide recommends minimizing work in higher-priority interrupts and considering whether can2040 code, callbacks, and vector tables should be placed in RAM.

Best Value
Pico 2 W with Color Soldered Header Compatible with Raspberry Pi Pico 2 W
  • RPi Pico 2 W Microcontroller Board (pre-soldered header (color-coded)), Based on Official RP2350 Chip, Dual-core & Dual-architecture Design. Upgraded hardware from Pico 2 with wireless communication, onboard antenna, features 2.4GHz 802.11n WIFI and Bluetooth 5.2.
  • Adopts unique dual-core and dual-architecture design: dual-core Arm Cortex-M33 processor and dual-core Hazard3 RISC-V processor, flexible clock running up to 150 MHz.
  • Onboard Infineon CYW43439 wireless chip, supports WIFI 4 wireless and Bluetooth 5.2.
  • 520KB of SRAM, and 4MB of on-board Flash memory.
  • Castellated module allows soldering direct to carrier boards. USB 1.1 with device and host support. Low-power sleep and dormant modes. Drag-and-drop programming using mass storage over USB.

The guide notes that on an RP2040 running at 125 MHz, a 32-bit flash load can take at least 320 ns. Flash stalls can therefore affect CAN timing. Treat the library’s documented maximum bus rate as a supported capability, not a guarantee that every application will meet timing under every interrupt, memory, and bus-load condition.

Compatibility, build requirements, and license

  • RP2040: The API documentation specifies Pico SDK 1.3.0 or later.
  • RP2350: It specifies Pico SDK 2.0.0 or later and the -DPICO_RP2350 compiler flag.
  • Without the full Pico SDK: The C source files can be built separately, but SDK headers are still needed.
  • License: The API documentation identifies the project as GPLv3. Review the license terms for your intended use and distribution.

For Arduino projects, the separate ACAN2040 wrapper offers a higher-level route for RP2040 and RP235x boards, including Pico and Pico W. It still requires an external CAN transceiver.

When to use can2040 instead of a dedicated CAN controller

can2040 is a practical option when you want to use an RP2040 or RP2350 board and are comfortable integrating its C API or an Arduino wrapper. A dedicated CAN-controller solution may be preferable if you want protocol work handled outside the Pico’s PIO and CPU resources, or if your chosen board already integrates the required CAN hardware. Either way, verify what the hardware includes: a controller and a transceiver are different parts of the interface.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Electrical hardware: can2040 needs an external transceiver; some integrated CAN boards may include one.
  • Resource and timing budget: can2040 uses one PIO block and requires attention to interrupt latency. Dedicated controllers move protocol work elsewhere.
  • Software integration: can2040 provides a Pico SDK C API, with ACAN2040 as an Arduino wrapper option.
  • Documented protocol scope: the project specifies CAN 2.0B data frames up to 1 Mbit/s.
  • Physical bus validation: correct CANH/CANL connections, two 120-ohm terminations, a second active node, and matching bitrates are part of a functioning setup.
  • License and version: the project is GPLv3; check the maintained repository revision and its documentation for the requirements that apply to your build.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.