Arduino ESP32 nano and MCP2515 Shield not working

Hello everyone. My project is to make BMW Wonder Wheel control Phone and Music as BLE HID Keyboard. But got a problem with MCP2515 Shield with ESP32 nano, bootloop, periodic rebooting and nothing in serial monitor. With ble-nano 4.2 and other working good, but it can't be used as HID BLE. Example sketches not working too.
Esptool reflash - not help.
Pin numbering arduino/esp32 -not help.
CS pinout changing -not help.

#include <SPI.h>
#include <mcp_can.h>

MCP_CAN CAN(10);

void setup() {
Serial.begin(115200);
  
if(CAN.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ) == CAN_OK) {
Serial.println("MCP2515 Initialized Successfully!");
CAN.setMode(MCP_NORMAL);
} else {
Serial.println("Error Initializing MCP2515...");
while(1); 
}
}

void loop() {
  unsigned long int canId;
  unsigned char len = 0;
  unsigned char buf[8];

  if(CAN.checkReceive() == CAN_MSGAVAIL) {
    CAN.readMsgBuf(&canId, &len, buf); 
    if (canId == 0x2A0) {
      Serial.print("Received CAN Message with ID 0x2A0: ");
      for(int i = 0; i < len; i++) {
        Serial.print(buf[i], HEX); 
        Serial.print(" ");
      }
      Serial.print("Bit representation of 4th byte: ");
      bool bit0 = (buf[3] >> 0) & 0x01;
      bool bit1 = (buf[3] >> 1) & 0x01;
      Serial.print(bit0);
      Serial.print(bit1);
      Serial.println();
    }
  }
  delay(100); 
}

Hello @checka206, you described lots of different tests so I'm not super clear what the issue is. I can give you some pointers though:

  • If your Nano ESP32 reboots in a loop, please follow this procedure to restore its contents.
  • Once this is done, set "Pin Numbering" to "By GPIO number (legacy)" and use that in your next tests.
  • Flash a Blink sample - does it work?
  • Try your sketch without connected hardware - does it work? (as much as it should... maybe set the LED or add a Serial.print to the loop to test)
  • Does this change when hardware is connected, but without powering the device? And when the device is powered?

Hope this helps you troubleshooting!

Hello, thanks for your answer.
1)already did this procedure some times
2)will try GPIO Pin Numbering
3)Other Sketches working well(with serial monitor too)
4) My sketch not running even without mcp2515
5) is it important that esp32 nano powered with usb-c?
Problem is - then I enter CS pin - 10 or D10 in Arduino Numbering its stops working (without Hardware too)

Hello! Im doing similar project iwht bmw can. But dont have rebooting problems. Which esp32 board are you using?