chris_daquino
Member
Hi,
I'm trying to make a Teensy 3.2 (transmitter) and a Teensy 3.6 (receiver) communicate through CAN using these cheap MCP2551 Modules:https://www.aliexpress.com/item/32467806585.html?spm=a2g0s.9042311.0.0.22f24c4dP75xAS.
But I'm not receiving anything through Teensy 3.6. I'm even tried swapping both MCP2551 modules as I have 5 of them available, thinking that maybe one of them could be faulty, with no success. I have the photos of my connections attached, and this is my code:
Teensy 3.2 transmitter
Teensh 3.6 receiver
I'm trying to make a Teensy 3.2 (transmitter) and a Teensy 3.6 (receiver) communicate through CAN using these cheap MCP2551 Modules:https://www.aliexpress.com/item/32467806585.html?spm=a2g0s.9042311.0.0.22f24c4dP75xAS.
But I'm not receiving anything through Teensy 3.6. I'm even tried swapping both MCP2551 modules as I have 5 of them available, thinking that maybe one of them could be faulty, with no success. I have the photos of my connections attached, and this is my code:
Teensy 3.2 transmitter
Code:
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
FlexCAN CANBus(500000);
static CAN_message_t msg;
void setup() {
CANBus.begin();
pinMode(LED_BUILTIN, OUTPUT);
delay(1000);
Serial.println("CAN Transmitter Initialized");
}
void loop() {
Serial.println("Sending");
msg.id = 0x1;
msg.len = 1;
msg.buf[0] = 1;
CANBus.write(msg);
//digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
delay(500);
}
Teensh 3.6 receiver
Code:
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
FlexCAN CANBus(500000);
static CAN_message_t msg;
void setup() {
CANBus.begin();
pinMode(LED_BUILTIN, OUTPUT);
delay(1000);
Serial.println("CAN Receiver Initialized");
}
void loop() {
if (CANBus.available()) {
Serial.println("Message Received");
CANBus.read(msg);
Serial.println(msg.buf[0]);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
}