-
-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can i use this library with a raspberry pi pico? #119
Comments
I have tested the library for communication between a Raspberry Pi Pico and an ESP32 DOIT DevKit V1. Raspberry Pi PICO is using MCP2515 CAN Controller Module while ESP32 is using SN65HVD230 CAN Transceiver Module. CANSender from ESP32 to CANReceiver on Raspberry Pi PICO example sketches can work, however it requires a minor modification to the library's MCP2515.h header file. But before that, check which SPI pins your Raspberry Pi PICO board is using by default, this can be done easily using the code below while referring to the PICO pinout diagram:
Then proceed to wire up your PICO board to the MCP2515 module. Take note that some documentations stated that the MCP2515 can work at 3.3V but NO, the MCP2515 CAN Controller chip can work from 2.75V to 5.5V (https://ww1.microchip.com/downloads/en/DeviceDoc/MCP2515-Stand-Alone-CAN-Controller-with-SPI-20001801J.pdf) BUT the TJA1050 CAN Transceiver chip can only work from 4.75V to 5.25V (https://www.nxp.com/docs/en/data-sheet/TJA1050.pdf). So be sure to hook it to 5V. You might also come across some forums stating that the Raspberry Pi PICO board GPIOs are not 5V tolerant and you should connect the pins to a logic level shifter first before connecting it to the MCP2515 module. For my case, the logic level shifter method did not work. Directly connecting the module to the SPI pins on the Raspberry Pi PICO board did the trick, although I am not sure how long the pins can continue to withstand the logic levels from the module, this requires an oscilloscope to verify (which I am too broke to own one D:, although a cheap one might do the trick ). Coming back, navigate to where the CAN library is stored at (on Windows, it is under Documents > Arduino > libraries > CAN), then open the "MCP2515.h" header file. From line 15 to line 22
replace this segment of code with
upload the CANReceiver sketch to your Raspberry Pi PICO board, hook everything up and enjoy :D. As my application only requires transmission of CAN data from ESP32 to the Raspberry Pi PICO board, I am unable to verify if the reverse setup will work or not. Also I have only tested the example sketch so far and have yet to build stuff on top of it. II will update here if I face any issues when working with this library on Raspberry Pi PICO board. Appreciate if anyone can share their results here too. |
Hi, i wanted to know if it was possible to use this library with a raspberry pi pico with some tweaks. I've used it with arduino uno so far, and i'd like to use it on a raspberry pi pico aswell, obviously using the MCP2515. I'm asking this because the pi pico is now cheaper than an arduino nano. If nothing can be done then i guess i'll just buy a nano. Thanks in advance!
The text was updated successfully, but these errors were encountered: