- All products
- Development Boards
- Raspberry Pi
- RPi Accessories
- RPi Hat (Shield)
- CAN RS485 HAT for Raspberry Pi HAT for Raspberry Pi (Waveshare)
- RPi Hat (Shield)
Features
- Standard Raspberry Pi 40-pin GPIO header, compatible with Raspberry Pi series boards.
- CAN interface using the onboard MCP2515 CAN controller through SPI.
- Onboard CAN transceiver for CAN bus communication.
- RS485 interface controlled through the Raspberry Pi UART.
- RS485 supports half-duplex communication.
- Hardware automatic TX/RX control for RS485 without additional programming.
- Onboard TVS protection helps suppress surge voltage and transient spike voltage during RS485 communication.
- Onboard 120Ω terminal resistor for RS485 and CAN interfaces, enabled through the onboard switch.
- Reserved control header for use with other control boards.
- Compact 65mm × 30mm board size.
- Online development resources and example programs are provided by Waveshare.
Principle of Operation
The CAN section uses an MCP2515 CAN controller connected to the Raspberry Pi through the SPI interface. The MCP2515 handles CAN protocol functions and communicates with the external CAN bus through the onboard CAN transceiver.

The RS485 section uses the Raspberry Pi UART interface together with the onboard SP3485 RS485 transceiver. The interface operates in half-duplex mode. The board supports automatic transmit and receive control, allowing the direction of communication to be controlled by the hardware.

The board also includes TVS protection to help protect the RS485 interface against surge and transient voltage conditions. A 120Ω terminal resistor is provided for RS485 and CAN bus termination when required.
Library
The RS485 CAN HAT can be used with the Raspberry Pi Linux environment and does not require a single dedicated library for all communication functions. The required software depends on whether the RS485 or CAN interface is being used and which programming method is selected.
CAN Communication with SocketCAN
For CAN communication, the Raspberry Pi can use the Linux SocketCAN framework. SocketCAN provides a standard CAN network interface under Linux and allows CAN applications to communicate through an interface such as can0.
The CAN interface can be configured using the Linux ip command. For example, a CAN bus bitrate can be configured as follows:
sudo ip link set can0 type can bitrate 1000000
sudo ip link set can0 up
After the interface is enabled, its status can be checked with:
ip -details link show can0
can-utils
can-utils is a collection of Linux command-line utilities for testing and working with CAN interfaces. It is useful for checking the RS485 CAN HAT CAN interface before developing a custom application.
On Raspberry Pi OS, can-utils can be installed using:
sudo apt update
sudo apt install can-utils
After configuring the CAN interface, incoming CAN frames can be monitored with:
candump can0
A CAN frame can be transmitted using:
cansend can0 123#11223344
In this example, 123 is the CAN identifier and 11 22 33 44 are the data bytes.
Python
Python can be used to develop custom applications for the RS485 CAN HAT. For CAN communication, a Python CAN library can communicate with the Linux SocketCAN interface. This allows Python programs to send and receive CAN frames through the can0 interface.
A commonly used Python package is python-can. It can be installed with:
sudo apt install python3-can
After the CAN interface has been configured, a Python application can open the SocketCAN interface and communicate with the CAN bus.
import can
bus = can.Bus(interface="socketcan", channel="can0")
message = can.Message(
arbitration_id=0x123,
data=[0x11, 0x22, 0x33, 0x44],
is_extended_id=False
)
bus.send(message)
for message in bus:
print(message)
The Python CAN library is mainly useful when CAN communication needs to be integrated into a larger Raspberry Pi application, such as a data logger, industrial controller, monitoring system, or automation application.
RS485 Communication with Python
The RS485 interface uses the Raspberry Pi UART. Python applications can access the UART using a serial communication library such as pySerial.
pySerial can be installed with:
sudo apt install python3-serial
The exact serial device name depends on the Raspberry Pi configuration. It may appear as a device such as /dev/serial0 or another serial port assigned by the operating system.
A basic Python serial communication example is:
import serial
ser = serial.Serial(
port="/dev/serial0",
baudrate=9600,
bytesize=8,
parity="N",
stopbits=1,
timeout=1
)
ser.write(b"Hello")
data = ser.read(20)
print(data)
ser.close()
The baud rate, parity, stop bits, timeout, and other serial parameters must be configured according to the RS485 device being connected.
WiringPi
Waveshare also provides example programs using WiringPi. WiringPi is a Raspberry Pi GPIO library that has been used by many Raspberry Pi projects for GPIO and hardware interfacing.
WiringPi examples can be useful when working with the HAT at a lower level or when using the GPIO and interface control described in the Waveshare examples. For new Raspberry Pi applications, however, the appropriate Linux interfaces or supported GPIO libraries should be considered depending on the Raspberry Pi OS version being used.
CAN Communication Software Structure
The CAN communication path can be understood as:
Python / C Application
↓
SocketCAN
↓
can0
↓
MCP2515 CAN Controller
↓
CAN Transceiver
↓
CANH / CANL Bus
RS485 Communication Software Structure
The RS485 communication path can be understood as:
Python / C Application
↓
Linux Serial Interface
↓
Raspberry Pi UART
↓
SP3485 RS485 Transceiver
↓
RS485 A / B Bus
Recommended Software by Interface
- CAN testing: SocketCAN + can-utils
- CAN Python applications: python-can + SocketCAN
- CAN C applications: Linux SocketCAN API
- RS485 Python applications: pySerial
- RS485 C applications: Linux serial port interface
- Waveshare examples: Python and C examples supplied with the product resources
Note: The software configuration depends on the Raspberry Pi model, Raspberry Pi OS version, communication parameters, and the external RS485 or CAN device. The CAN bitrate and RS485 serial parameters must match the connected equipment for reliable communication.
Simple Code
The board supports Python and C example programs provided by Waveshare. For CAN communication, the Linux CAN interface can be enabled and tested using commands such as:
sudo ip link set can0 up type can bitrate 1000000
sudo ifconfig can0 txqueuelen 65536
sudo ifconfig can0 up
To receive CAN messages:
candump can0
To send a CAN message:
cansend can0 000#11.22.33.44
Waveshare also provides C and Python demonstration programs for both CAN and RS485 communication.
Applications
- Raspberry Pi CAN bus communication
- Raspberry Pi RS485 communication
- Industrial communication projects
- Long-distance device communication
- CAN bus development and testing
- RS485 sensor and controller communication
- Embedded communication systems
- Automation and control projects
- Development and testing of CAN and RS485 devices
Pinout

CAN Bus
- 3V3: 3.3V power input
- GND: Ground
- SCK: SPI clock input
- MOSI: SPI data input
- MISO: SPI data output
- CS: Chip/data command selection, Raspberry Pi CE0
- INT: Interrupt output, Raspberry Pi BCM GPIO 25
RS485 Bus
- 3V3: 3.3V power input
- GND: Ground
- RXD: UART receive
- TXD: UART transmit
- RSE: RS485 transmit/receive control, Raspberry Pi BCM GPIO 4
The RSE pin does not need to be used when the hardware automatic transmit/receive function is enabled. The module is factory configured for automatic receive and transmit control.
Wiring
RS485 Connection
Connect the RS485 interface of the HAT to the corresponding RS485 device:
- A: Connect to the A line of the external RS485 device.
- B: Connect to the B line of the external RS485 device.
- GND: Connecting the signal ground is recommended for improved communication stability and noise immunity, especially for long-distance communication.
CAN Connection
Connect the CAN bus lines to the corresponding CAN device:
- CAN H: Connect to CAN H.
- CAN L: Connect to CAN L.
For CAN communication, the communication speed must be configured correctly on the connected devices. CAN bus termination should also be configured according to the bus topology.
Specifications
- Brand: Waveshare
- Product: RS485 CAN HAT
- Operating Voltage: 3.3V
- CAN Controller: MCP2515
- CAN Transceiver: SIT65HVD230DR
- RS485 Transceiver: SP3485
- Communication: CAN / RS485
- RS485 Mode: Half-duplex
- RS485 Control: UART
- CAN Interface: SPI
- Terminal Resistor: 120Ω
- Mounting Hole Size: 3.0mm
- Dimensions: 65mm × 30mm
Resources
Features
- Standard Raspberry Pi 40-pin GPIO header, compatible with Raspberry Pi series boards.
- CAN interface using the onboard MCP2515 CAN controller through SPI.
- Onboard CAN transceiver for CAN bus communication.
- RS485 interface controlled through the Raspberry Pi UART.
- RS485 supports half-duplex communication.
- Hardware automatic TX/RX control for RS485 without additional programming.
- Onboard TVS protection helps suppress surge voltage and transient spike voltage during RS485 communication.
- Onboard 120Ω terminal resistor for RS485 and CAN interfaces, enabled through the onboard switch.
- Reserved control header for use with other control boards.
- Compact 65mm × 30mm board size.
- Online development resources and example programs are provided by Waveshare.
Principle of Operation
The CAN section uses an MCP2515 CAN controller connected to the Raspberry Pi through the SPI interface. The MCP2515 handles CAN protocol functions and communicates with the external CAN bus through the onboard CAN transceiver.

The RS485 section uses the Raspberry Pi UART interface together with the onboard SP3485 RS485 transceiver. The interface operates in half-duplex mode. The board supports automatic transmit and receive control, allowing the direction of communication to be controlled by the hardware.

The board also includes TVS protection to help protect the RS485 interface against surge and transient voltage conditions. A 120Ω terminal resistor is provided for RS485 and CAN bus termination when required.
Library
The RS485 CAN HAT can be used with the Raspberry Pi Linux environment and does not require a single dedicated library for all communication functions. The required software depends on whether the RS485 or CAN interface is being used and which programming method is selected.
CAN Communication with SocketCAN
For CAN communication, the Raspberry Pi can use the Linux SocketCAN framework. SocketCAN provides a standard CAN network interface under Linux and allows CAN applications to communicate through an interface such as can0.
The CAN interface can be configured using the Linux ip command. For example, a CAN bus bitrate can be configured as follows:
sudo ip link set can0 type can bitrate 1000000
sudo ip link set can0 upAfter the interface is enabled, its status can be checked with:
ip -details link show can0can-utils
can-utils is a collection of Linux command-line utilities for testing and working with CAN interfaces. It is useful for checking the RS485 CAN HAT CAN interface before developing a custom application.
On Raspberry Pi OS, can-utils can be installed using:
sudo apt update
sudo apt install can-utilsAfter configuring the CAN interface, incoming CAN frames can be monitored with:
candump can0A CAN frame can be transmitted using:
cansend can0 123#11223344In this example, 123 is the CAN identifier and 11 22 33 44 are the data bytes.
Python
Python can be used to develop custom applications for the RS485 CAN HAT. For CAN communication, a Python CAN library can communicate with the Linux SocketCAN interface. This allows Python programs to send and receive CAN frames through the can0 interface.
A commonly used Python package is python-can. It can be installed with:
sudo apt install python3-canAfter the CAN interface has been configured, a Python application can open the SocketCAN interface and communicate with the CAN bus.
import can
bus = can.Bus(interface="socketcan", channel="can0")
message = can.Message(
arbitration_id=0x123,
data=[0x11, 0x22, 0x33, 0x44],
is_extended_id=False
)
bus.send(message)
for message in bus:
print(message)The Python CAN library is mainly useful when CAN communication needs to be integrated into a larger Raspberry Pi application, such as a data logger, industrial controller, monitoring system, or automation application.
RS485 Communication with Python
The RS485 interface uses the Raspberry Pi UART. Python applications can access the UART using a serial communication library such as pySerial.
pySerial can be installed with:
sudo apt install python3-serialThe exact serial device name depends on the Raspberry Pi configuration. It may appear as a device such as /dev/serial0 or another serial port assigned by the operating system.
A basic Python serial communication example is:
import serial
ser = serial.Serial(
port="/dev/serial0",
baudrate=9600,
bytesize=8,
parity="N",
stopbits=1,
timeout=1
)
ser.write(b"Hello")
data = ser.read(20)
print(data)
ser.close()The baud rate, parity, stop bits, timeout, and other serial parameters must be configured according to the RS485 device being connected.
WiringPi
Waveshare also provides example programs using WiringPi. WiringPi is a Raspberry Pi GPIO library that has been used by many Raspberry Pi projects for GPIO and hardware interfacing.
WiringPi examples can be useful when working with the HAT at a lower level or when using the GPIO and interface control described in the Waveshare examples. For new Raspberry Pi applications, however, the appropriate Linux interfaces or supported GPIO libraries should be considered depending on the Raspberry Pi OS version being used.
CAN Communication Software Structure
The CAN communication path can be understood as:
Python / C Application
↓
SocketCAN
↓
can0
↓
MCP2515 CAN Controller
↓
CAN Transceiver
↓
CANH / CANL BusRS485 Communication Software Structure
The RS485 communication path can be understood as:
Python / C Application
↓
Linux Serial Interface
↓
Raspberry Pi UART
↓
SP3485 RS485 Transceiver
↓
RS485 A / B BusRecommended Software by Interface
- CAN testing: SocketCAN + can-utils
- CAN Python applications: python-can + SocketCAN
- CAN C applications: Linux SocketCAN API
- RS485 Python applications: pySerial
- RS485 C applications: Linux serial port interface
- Waveshare examples: Python and C examples supplied with the product resources
Note: The software configuration depends on the Raspberry Pi model, Raspberry Pi OS version, communication parameters, and the external RS485 or CAN device. The CAN bitrate and RS485 serial parameters must match the connected equipment for reliable communication.
Simple Code
The board supports Python and C example programs provided by Waveshare. For CAN communication, the Linux CAN interface can be enabled and tested using commands such as:
sudo ip link set can0 up type can bitrate 1000000
sudo ifconfig can0 txqueuelen 65536
sudo ifconfig can0 upTo receive CAN messages:
candump can0To send a CAN message:
cansend can0 000#11.22.33.44Waveshare also provides C and Python demonstration programs for both CAN and RS485 communication.
Applications
- Raspberry Pi CAN bus communication
- Raspberry Pi RS485 communication
- Industrial communication projects
- Long-distance device communication
- CAN bus development and testing
- RS485 sensor and controller communication
- Embedded communication systems
- Automation and control projects
- Development and testing of CAN and RS485 devices
Pinout

CAN Bus
- 3V3: 3.3V power input
- GND: Ground
- SCK: SPI clock input
- MOSI: SPI data input
- MISO: SPI data output
- CS: Chip/data command selection, Raspberry Pi CE0
- INT: Interrupt output, Raspberry Pi BCM GPIO 25
RS485 Bus
- 3V3: 3.3V power input
- GND: Ground
- RXD: UART receive
- TXD: UART transmit
- RSE: RS485 transmit/receive control, Raspberry Pi BCM GPIO 4
The RSE pin does not need to be used when the hardware automatic transmit/receive function is enabled. The module is factory configured for automatic receive and transmit control.
Wiring
RS485 Connection
Connect the RS485 interface of the HAT to the corresponding RS485 device:
- A: Connect to the A line of the external RS485 device.
- B: Connect to the B line of the external RS485 device.
- GND: Connecting the signal ground is recommended for improved communication stability and noise immunity, especially for long-distance communication.
CAN Connection
Connect the CAN bus lines to the corresponding CAN device:
- CAN H: Connect to CAN H.
- CAN L: Connect to CAN L.
For CAN communication, the communication speed must be configured correctly on the connected devices. CAN bus termination should also be configured according to the bus topology.
Specifications
- Brand: Waveshare
- Product: RS485 CAN HAT
- Operating Voltage: 3.3V
- CAN Controller: MCP2515
- CAN Transceiver: SIT65HVD230DR
- RS485 Transceiver: SP3485
- Communication: CAN / RS485
- RS485 Mode: Half-duplex
- RS485 Control: UART
- CAN Interface: SPI
- Terminal Resistor: 120Ω
- Mounting Hole Size: 3.0mm
- Dimensions: 65mm × 30mm
Resources

