I’m trying to send a CANMessage from one photon to another. No Photon reports an error via errorStatus()
, but nothing is received by the other photon.
I am using the tranceiver SN65HVD230
for both Photons.
This is my code for the photons:
Transmitting Photon:
CANChannel can(CAN_D1_D2);
void setup() {
can.begin(125000);
pinMode(D7, OUTPUT);
}
uint8_t s = 0;
void loop() {
CANMessage message;
message.id = 0x1;
message.len = 1;
message.data[0] = s;
can.transmit(message);
digitalWrite(D7, s);
s = !s;
delay(100);
}
Recveiving Photon:
CANChannel can(CAN_D1_D2);
void setup() {
can.begin(125000);
RGB.control(true);
RGB.color(0x0000ff);
delay(1000);
RGB.color(0xff00ff);
delay(1000);
}
void printStatus() {
auto status = can.errorStatus();
if(status == CAN_BUS_OFF) {
RGB.color(0xffff00);
} else if (status == CAN_ERROR_PASSIVE) {
RGB.color(0x00ffff);
} else {
RGB.color(0xff00ff);
}
}
uint8_t s = 1;
void loop() {
RGB.color(0, 0, s ? 255 : 0);
printStatus();
CANMessage message;
if(can.receive(message)) {
RGB.color(0, 255, s ? 255 : 0);
s = !s;
delay(1000);
}
}
This is my wiring:
What am I doing wrong here? May SN65HVD230
be the wrong tranceiver?
Related topics: