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