MKR CAN Shield with 2 MKRWifi1010 WIRING issue

Hi everybody, very simple question:
-what is wrong in the below wiring that is not working, meaning the SENDER sends out but the the RECEIVER DON'T get anything?

As you can imagine I went through all the (very few!) available documentation and I went out of troubleshhoting attempts.... :grinning:

As you can imagine I started from the Arduino official library and related codes as following:

A) for the sender:

// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include <CAN.h>
//get rid of magical numbers 
#define IOPIN4 4
//definition of PORTS or better said of PINS
const int LED1 = IOPIN4; //LED1 label is a generic one that can be semantically contextualized

void setup() {
  pinMode(LED1, OUTPUT); // will be used to turn the led on and off
  Serial.begin(9600);
  while (!Serial);

  Serial.println("CAN Sender");

  // start the CAN bus at 500 kbps
  if (!CAN.begin(500E3)) {
    Serial.println("Starting CAN failed!");
    while (1);
  }
}

void loop() {
  // send packet: id is 11 bits, packet can contain up to 8 bytes of data
  Serial.print("Sending packet ... ");

  CAN.beginPacket(0x12);
  CAN.write('h');
  CAN.write('e');
  CAN.write('l');
  CAN.write('l');
  CAN.write('o');
  CAN.endPacket();

  Serial.println("done");

  delay(1000);

  // send extended packet: id is 29 bits, packet can contain up to 8 bytes of data
  Serial.print("Sending extended packet ... ");

  CAN.beginExtendedPacket(0xabcdef);
  CAN.write('w');
  CAN.write('o');
  CAN.write('r');
  CAN.write('l');
  CAN.write('d');
  CAN.endPacket();

  Serial.println("done");
  digitalWrite(LED1, HIGH);
  delay(1000);
  digitalWrite(LED1, LOW);
  delay(1000);
}

B) for the receiver:

// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include <CAN.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);

  Serial.println("CAN Receiver");

  // start the CAN bus at 500 kbps
  if (!CAN.begin(500E3)) {
    Serial.println("Starting CAN failed!");
    while (1);
  }
}

void loop() {
  // try to parse packet
  int packetSize = CAN.parsePacket();

  if (packetSize) {
    // received a packet
    Serial.print("Received ");

    if (CAN.packetExtended()) {
      Serial.print("extended ");
    }

    if (CAN.packetRtr()) {
      // Remote transmission request, packet contains no data
      Serial.print("RTR ");
    }

    Serial.print("packet with id 0x");
    Serial.print(CAN.packetId(), HEX);

    if (CAN.packetRtr()) {
      Serial.print(" and requested length ");
      Serial.println(CAN.packetDlc());
    } else {
      Serial.print(" and length ");
      Serial.println(packetSize);

      // only print packet data for non-RTR packets
      while (CAN.available()) {
        Serial.print((char)CAN.read());
      }
      Serial.println();
    }

    Serial.println();
  }
}

But on the Receiver serial monitor there is no sign of life, despite the BLU led I've implemented, as you surely understood, for debugging purposes, IS ALWAYS BLINKING.

Thanks a lot for specific and actionable suggestions here.

BR

Andrea

Try changing the CS pin to 3. I think the default in the CAN.h library is pin 10.

@jornmoe
Please see the date of the last post before writing the answer.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.