Skip to content

Interop with Other Devices

The RS485 CAN HAT speaks standard CAN 2.0B and EIA/TIA-485 (RS-485), so it connects directly to any device that implements these protocols. This page covers the practical details of getting a clean, reliable link between the HAT and third-party hardware.

Wiring

Connect CAN-H to CAN-H and CAN-L to CAN-L between all devices on the bus. Reversing the pair will produce bit errors or complete communication failure. A 120-ohm termination resistor should be present at each physical end of the bus.

Baud Rate

Every node on the bus must use the same bitrate. The demo code defaults to 100 kbps (bitrate 100000). If you are connecting to an automotive ECU or industrial device, check its documentation for the expected rate and match it on the Pi side.

CAN IDs

CAN is a broadcast protocol — all nodes see all frames. However, if your receiving application filters on specific arbitration IDs, make sure the transmitting device sends with a matching ID. The demo code uses 0x123.

Frame Loss

If you observe dropped frames during sustained high-throughput transmissions, reduce the bitrate or increase the txqueuelen on the Pi. Long bus runs at high bitrates are more susceptible to signal integrity issues, especially without proper termination.

  • No ACK errors. CAN requires at least two active nodes on the bus. If the HAT is the only device connected and powered, transmitted frames will not be acknowledged and the MCP2515 will report errors. Connect a second node (even a passive listener) before testing sends.
  • Mismatched extended/standard frames. The demo code uses standard (11-bit) IDs (is_extended_id=False). If your remote device sends extended (29-bit) IDs, update your receive filter accordingly.
  • Missing termination. Without 120-ohm resistors at both ends of the bus, reflections corrupt the signal at higher bitrates. Short bench wires (under 30 cm) are often forgiving, but anything longer needs proper termination.

Wiring

Connect A to A and B to B between all devices. A shared GND connection between devices is recommended to prevent ground-potential differences from corrupting the differential signal.

Baud Rate

Both sides must agree on the baud rate. The demo code uses 115200 bps. Industrial Modbus devices commonly run at 9600 or 19200 bps — adjust the serial.Serial() baud rate parameter to match.

USB-to-485 Adapters

A USB-to-RS-485 adapter plugged into a laptop is the simplest way to test the HAT’s RS-485 output. Open a serial terminal (such as minicom, picocom, or PuTTY) on the adapter’s serial port at the matching baud rate and you should see data from the Pi immediately.

  • Half-duplex collisions. RS-485 on this board is half-duplex — only one device should be transmitting at a time. If both sides transmit simultaneously, data will be corrupted. Implement a clear request/response protocol or use a master/slave model.
  • A/B polarity. Some manufacturers label their RS-485 terminals with ”+” and ”-” instead of “A” and “B”, and the mapping is not always consistent. If data appears garbled, try swapping A and B. The data will be inverted but otherwise intact, which means every byte will be wrong in a predictable way.
  • Baud rate mismatch. Unlike CAN (which will produce outright errors), an RS-485 baud rate mismatch often results in garbage characters rather than a clean failure. If you see random bytes instead of your expected payload, double-check rates on both sides.