For an index to all my stories click this text
This story tells how to attach an SD card to your Pico. Attaching an SD card brings a tremendous amount of extra memory to your Pico. We can use that for storing sensor data, images and webpages for the Pico webserver but also for storing audio. Audio ?? Yes Audio !!
This is a two part story. This part describes how to attach the SD card. Next part shows how to use the SD card with MicroPython.
If you follow this weblog you will know that I was using speech synthesises on the Raspberry Pi Pico and build a talking thermometer and a talking clock. You can read those stories on this weblog. However I wanted more. I wanted to build an audio player. Pico's sound is great and you really only need a few resistors and capacitors to achive it. The problem was capacity. Pico only has 2MB flash memory. And although that is enough to store dozens of programs it is to little to store music files. So I attached an SD card for more storage.
SD card module
The easiest way to attach an SD card to your Pico is to use an SD card module.
This module has several advantages. At the top you can see a voltage regulator. The regulator brings 5V back to 3.3V. The card as well as the Pico operate at 3.3V. The regulator allows you to feed the module with 5V. Use the 5V pin for that. Then there is a 3.3V pin so you can power this adapter straight from Pico's 3.3V out pin.
There is also a range of smd resistors on the board. They will be discussed further on.
The module accepts standard SD cards. Using a micro SD adapter you can also use micro SD's. These adapters are often sold together with your micro SD card.
The module has a double set of header pins, but they are identical. No idea what the purpose is of the double set headers except that they give more stability when putting the adapter on a breadboard.
There are other modules available which are specifically build for micro sdcards. Personally I have not used them but I have seen their pictures and they use the same pins although they have a different pin-layout.
The module is attached to the Pico or Pico W with its's SPI interface. The module is next to GND and 3.3V attached with 4 pins to the Pico.
Mosi ==> GP15And here you can see how this module is connected.
SCK ==> GP14
CS ==> GP13
Miso ==> GP12
SD card adapter
There is another option if you are not afraid to solder.
As you can see the sd card adapters pins almost perfectly match the pins of a standard header. So we can solder the header pins directly to an sd card adapter. This is my favorite way to use the SD-cards.
My soldering skills are not the best, but hey it works !!
There are now two options.
We can use female-male dupont wires to connect the sd card headers to the Pico. The female connecters plug into the headers and the male connectors into the beadboard next to Pico's GPIO pins.
Another option is to plug the headers direct into the breadboard. This is actually a better option as shorter wires are less prone to produce noise when we later attach the audio part.
In the picture there is a label on top of the Pico. I use it all the time for easily identifying the GPIO pins. You can find this label here: http://lucstechblog.blogspot.com/2021/03/raspberry-pico-pin-layout-help.html
And this is how the connections are made. Please note the slanted side of the SD-card adapter. On the previous photo the card is turned around. So please note where the connections are.
Here you can see the breadboard layout. This is the same as on the picture.
If you look closely to the SDcard Module as discussed earlier you can see that there are tiny resistors labeled R1 to R4. These are pull-up resistors and connected to Mosi, SCK, CS and Miso.
In my particular case I only connected a 10K pull-up resistor to the MISO pin. This is required !!! If you omit this resistor the SD card will not function properly. I did not connect pull-up resistors to the other pins and experienced no problems. If you do run into errors add the resistors.
For reference I hereby give you the pin connections again:
Mosi ==> GP15
SCK ==> GP14
CS ==> GP13
Miso ==> GP12
VCC ==> 3V3 out
GND ==> GND
Next step
If you are not confident with soldering you can use the module which fits direct on the breadboard. Otherwise solder the headers to an SD card adapter. When done you are ready for the next step. Using the card with your Pico and MicroPython.
In the next story I am going to show how to install the MicroPython drivers, get the SD card's directory, make and remove subdirectories, save programs, write files, delete files and rename files. I'll also show how to use the SD card as storage for your data.
Till next time,
have fun
Luc Volders