🛠 CAN bus between two R4 Minimas (external transceiver required)
Goal
Exchange messages between two UNO R4 Minimas over CAN. The RA4M1 integrates the CAN *controller*, but the header only exposes controller-level signals: you must add an external transceiver (e.g. SN65HVD230 or MCP2551 module) to drive the differential bus.
Wiring
Per node: transceiver to the board's CAN pins (see the user manual for the exact header mapping), transceiver CANH to CANH and CANL to CANL across nodes, common GND, and 120-ohm termination at each end of the bus.
Sketch (both boards, same code)
#include <CAN.h>
void setup {
Serial.begin(115200);
CAN.begin(500E3); // 500 kbit/s, both nodes identical
}
void loop {
int packet = CAN.parsePacket;
if (packet) {
Serial.printf("id=0x%lX len=%d\n",
CAN.packetId, packet);
while (CAN.available)
Serial.write(CAN.read);
Serial.println;
}
if (millis % 1000 < 20) { // crude 1 Hz beacon
CAN.beginPacket(0x123);
CAN.write('R'); CAN.write('4');
CAN.endPacket;
}
}
Common mistakes
- No transceiver: nothing appears on the bus, the controller alone cannot drive CAN levels.
- Missing terminations: intermittent or zéro frames.
- Different bit rates on the two nodes ; and mind the transceiver's logic supply vs the 5 V board.
Autres tutoriels pour cette carte
Exemples de code pour cette carte
clignotante.inoArduinobouton-poussoir.inoArduinodac-analogique.inoArduinoentree-analogique.inoArduinopwm-respiration.inoArduinoservo-balayage.inoArduino