Nano ESP32 SPI not working

Hey, I am currently trying to build a CAN-bus device based on the nano-esp32. I connected a standard mcp2515 based CAN-shield to the arduino SPI ports given in the documentation.
Weirdly, this has always worked with older regular arduino nano boards (and still does), which is why I am quite sure it is no config error. But with the nano-esp32, no data is sent or received.

An example code I tested can be found in the documentation of the mcp2515 library: GitHub - autowp/arduino-mcp2515: Arduino MCP2515 CAN interface library

I first thought this may be an issue with the 5V supplied by the USB port, as 6-21V are recommended, but using a lab psu with different in-range voltages made no difference.
I already tried using different pins via HSPI, also without any luck.
My following oscilloscope analysis revealed that not only the communication between the nano and the shield is failing, but the nano is not controlling the SPI pins at all. Again in difference to the regular nano, no clock action or switching on the other pins was visible.

So: Am I missing something? Is there a chance of the arduino IDE using a faulty SPI library version? I'm running out of ideas, so I really appreciate your help!

Welcome to the forum

What voltage does the shield work at, bearing in mind that the Arduino is an ESP32 based device which uses 3.3V ?

1 Like

Well, it works at 5V. Thanks.
As I connected 5V to the shields VCC, I did not think about voltages on the SPI pins themselves. This is likely to be at least one of the issues. I'm still wondering why I couldn't see any action on the SPI pins though. Regardless of the operating voltage, this should have been the case

Which version of the pin mapping have you got selected for the board ?

The arduino default. I'm also able to control the correct pins via digitalWrite(), just not when using SPI.

Are you using a library ?

Only the SPI.h library and the autowp-mcp2515 library (see link in question)

Hi @niklasdeg ,
Welcome to the forum..
Think you're looking for what espressif now calls TWAI..
Two-Wire Automotive Interface (TWAI)
Couple of examples in the core..
arduino-esp32 libraries examples TWAI

never used it, just remember seeing it in the core source and docs..

good luck.. ~q

That test is unfortunately not useful, as the library may access the pins in a different way. As per this guide, please set the pin numbering to By GPIO number (legacy), and always refer to pins via their names (write D22 instead of the number 22) in your sketch.

Let us know how that goes!