MKR Wifi 1010 + MKR CAN shield

I'm trying to read CAN messages in the Serial Monitor of the Arduino IDE, but it's not working. I'm using the MKR WiFi 1010 together with the MKR CAN Shield. The CAN bus baud rate is 666.666 kbit/s — I verified this with another tool and confirmed that messages are being sent. I've installed the CAN library and connected the CAN Shield to the CAN network (CANL, CANH, and GND). Despite this setup, I don't see any messages in the Serial Monitor. Has anyone experienced this or knows what might be going wrong?

My code:

#include <CAN.h>

void setup() {
  Serial.begin(115200);
  while (!Serial);
  Serial.println("CAN Receiver");

  // Start de CAN-bus op 666666 kbps
  if (!CAN.begin(666666)) {
    Serial.println("Starting CAN failed!");
    while (1);
  } else {
    Serial.println("CAN started at 666666 kbps");
  }

  // Voeg deze regel toe om alle CAN-ID's te accepteren
  CAN.filter(0, 0); // accepteer alle ID's
}

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();
  }
}


Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.