Raspberry Pi Pico (RP2040) SD Card (Read & Write) with MicroPython and C/C++ | Digi-Key Electronics
Описание
SD cards are popular ways to store data that can be transferred between computers and consumer electronics (e.g. digital cameras). They can be found in the tiny microSD format and still store gigabytes of data. SD card protocol supports the faster 4-bit SD mode as well as the 1-bit SPI mode. Some microcontrollers support SD mode for faster transfers, but the SPI mode is simple and popular for low data-rate logging (e.g. sensor data and timestamps).
In this tutorial, we show you how to read and write to an SD card from a Raspberry Pi Pico using MicroPython and C/C++. We will demonstrate the simpler SPI format, as the Pico has a built-in SPI peripheral.
Note that you will need to format your SD card using the FAT32 filesystem on your operating system. Here are some guides to help you do that:
- Windows: https://helpdeskgeek.com/windows-10/how-to-format-an-sd-card-on-windows-10/
- Mac: https://havecamerawilltravel.com/photographer/how-to-format-sd-card-on-mac/
- Linux: https://linuxize.com/post/how-to-format-usb-sd-card-linux/
A written tutorial along with all of the code in this video can be found here: https://www.digikey.com/en/maker/projects/raspberry-pi-pico-rp2040-sd-card-example-with-micropython-and-cc/e472c7f578734bfd96d437e68e670050
The sdcard.py driver for MicroPython can be found here: https://github.com/micropython/micropython/blob/master/drivers/sdcard/sdcard.py
FATFS API documentation for interacting with files in MicroPython can be found here: https://docs.micropython.org/en/latest/reference/filesystem.html
The third party library for working with SD cards in C/C++ can be found here: https://github.com/carlk3/no-OS-FatFS-SD-SPI-RPi-Pico
FATFS API documentation for interacting with files in C can be found here: http://elm-chan.org/fsw/ff/00index_e.html
Product Links:
https://www.digikey.com/en/products/detail/raspberry-pi/SC0915/13624793
https://www.digikey.com/en/products/detail/adafruit-industries-llc/4682/12822319
Related Videos:
Intro to Raspberry Pi Pico and RP2040 - MicroPython Part 1: Blink - https://www.youtube.com/watch?v=JCk9QaCH5QU
Intro to Raspberry Pi Pico and RP2040 - C/C++ Part 1: VS Code and Blink - https://www.youtube.com/watch?v=B5rQSoOmR5w
Intro to Raspberry Pi Pico and RP2040 - C/C++ Part 2: Debug with Picoprobe - https://www.youtube.com/watch?v=jnC5LrTx470
Related Project Links:
https://www.digikey.com/en/maker/projects/raspberry-pi-pico-and-rp2040-micropython-part-1-blink/58b3c31ac93649849b58824caa00529c
https://www.digikey.com/en/maker/projects/raspberry-pi-pico-and-rp2040-cc-part-1-blink-and-vs-code/7102fb8bca95452e9df6150f39ae8422
https://www.digikey.com/en/maker/projects/raspberry-pi-pico-and-rp2040-cc-part-2-debugging-with-vs-code/470abc7efb07432b82c95f6f67f184c0
Maker.io - https://www.digikey.com/en/maker
Digi-Key’s Blog – TheCircuit https://www.digikey.com/en/blog
Connect with Digi-Key on Facebook https://www.facebook.com/digikey.electronics/
And follow us on Twitter https://twitter.com/digikey
Рекомендуемые видео









![[Тим Тин] - Новая Чирлидерша Против Капитана Команды! Я Влюбилась в Парня Соперницы](/images/video/2026-06-02/e2/3e/e23e83de4fe49a2ad711e61dab3c06ca.jpg?width=640)









