15

I need to add a second SD card reader to my Raspberry Pi for the project www.samplerbox.org (the RPi will be embedded in a box, so I need a user-SD-card reader).

Here is what I would like to use (it is a very common electronic part):

enter image description here

How to wire this to the RaspberryPi? Via GPIO? (if so, how?) Via USB port? (if so, how to wire these pins to a standard USB plug?)

UPDATE: Here are the 2 * 8 pins : GND, 3V3, 5V, CS, MOSI, SCK, MISO, GND:

enter image description here

8
  • Do you plan to boot from the external SD card? Or is the Pi to boot from the internal SD card. What will the external SD card be used for?
    – joan
    Commented Mar 13, 2015 at 16:27
  • @joan No I don't plan to boot on it, the external SD card will be there to let the user load/save some data. The user won't acess to the internal SD card (RPi embedded in a box). Easier to understand with a picture : www.samplerbox.org
    – Basj
    Commented Mar 13, 2015 at 16:30
  • 2
    You can save yourself a lot of trouble if you just give the user a USB stick for data. Implementing a second SD card interface will be very difficult. Just bring a USB port out to the outside of your box.
    – joan
    Commented Mar 13, 2015 at 16:35
  • 2
    You further can use a SDCard to USB adapter, which is a tradeoff between both. Just google SDCard USB adapter.
    – user236012
    Commented Mar 13, 2015 at 17:08
  • 5
    While I agree it may be easier to use a USB stick, it should not be difficult to interface a SD Card. All SD support SPI and run on 3.3V (many of these boards have level converters to interface to 5V). I have used a similar adapter on Arduino, and am going to try on Pi. There is FAT software for Arduino. (NOTE I don't expect to access it via standard kernel drivers.)
    – Milliways
    Commented Mar 13, 2015 at 23:32

5 Answers 5

10

It seems like it is a SPI device. You should first need to enable SPI using raspi-config. Then you'll need to wire:

(Reader) GND  --  GND       (GPIO-Raspberry Pi2) 
         3V3  --  3.3 V (Pin 1)
         5V   --  NC
         CS   --  GPIO8 (Pin24)
         MOSI --  GPIO10 (Pin 19)
         SCK  --  GPIO11 (Pin 23)
         MISO --  GPIO9 (Pin 21)
         GND  -- NC
3
  • 3
    Any idea about how to have better transfer rate than 1 megabyte / sec with such technique? Is there another way than USB SD reader that can allow 10 MB/sec ?
    – Basj
    Commented Mar 6, 2016 at 9:40
  • 2
    high speeds are about more than one line for a SD card data, it seems you don't have them here, and it's not a simple-wiring setup over SPI interface Commented May 26, 2016 at 2:11
  • Note that it may be better to supply such modules with 5V instead of 3.3V. The 3.3V supply supports only limited loads, and drawing too much current from it will lead to a situation where not enough power is available to the Pi SoC. A single SD card is unlikely to exhaust cause problems, but a bunch of 3.3V devices will. Commented Mar 21, 2022 at 7:52
6

Raspberry pi pinout

You should connect GND, 5V and 3V3 to the appropriate pins on the pi. Then MOSI and MISO are also marked in the picture, SCK should connect to SCLK (this is the 10MHz clock which should be driven by the pi) and finally connect the CS pin to CS0 (Chip-Select, so you can connect 2 SD or other SPI-compliant devices).

According to the first reply on this thread, if you're running kernel version greater than 3.2.20 it should support the SPI hardware on the board and should give you 1MB/s throughput with little CPU load, which is impressive.

If your kernel is of a higher version but is compiled without SPI device support you should recompile it with an appropriate configuration (see the mentioned thread again).

6
  • 3
    Thanks for this answer! But 1 MB/s is far too low (compared to a USB reader), and for my project, I need to load 100MB in a very short time (this is possible from RPi microSD reader, possible from a USB SD card reader, so I need the same from this PCB SD reader)
    – Basj
    Commented Mar 30, 2015 at 6:58
  • You won't see a faster rate with this SD reader and the pi combination. 1MB/s is achieved utilizing the specialized SPI interface hardware on the pi. If you use any other GPIO connectors you'll have to implement it with the CPU, achieving far lower rates, around 180KB/s. If you need faster rates, use a USB reader as others suggested, which as I recall got me around 4MB/s but maybe others can give more precise numbers.
    – Egal
    Commented Mar 30, 2015 at 9:43
  • 2
    Arghh... So sad we can't get more than 1MB/s with this reader. Is it possible to turn this reader into a USB SD reader (with additionnal components?)
    – Basj
    Commented Mar 30, 2015 at 10:37
  • 2
    You can get a module that handles SPI (and other protocols) to USB like thie one for about $20: digikey.co.il/product-search/en?v=768&mpart=VA800A-SPI But I wouldn't go that way. I didn't read the spec so I don't know if the module identifies itself as Mass Storage class, or some other more generic USB class in which case you'll need to wrap it with your own driver. It'll be MUCH easier to get a simple USB SD card reader.
    – Egal
    Commented Mar 30, 2015 at 19:43
  • 2
    Sure, but I need a USB SD card reader that can be mounted on PCB (not only for me, but my project samplerbox.org will be opensource, so I want that it's easy for anyone to source the components)
    – Basj
    Commented Mar 30, 2015 at 20:54
2

An excellent blog post tutorial has been posted here:

http://blogsmayan.blogspot.com/p/interfacing-sd-card.html

Please review that detailed posting for a complete answer to connecting your SD card reader to the Pi.

There is a companion You Tube video available here:

https://www.youtube.com/watch?v=ihqXzQgaIaw

1
  • Cool article indeed. I just looked quickly, is there something about transfer rate @Kolban ?
    – Basj
    Commented Jul 28, 2017 at 22:42
1

Without knowing much about the card reader itself, I will give the best answer I can.

The reader seems to have markings on it next to the GPIO pins. Connect them to the corresponding pins on the RPI using some female-female jumper cables (or a more permanent method for your application). If they do not have a corresponding pin, attach them to a free pin on the pi and take note of it.

The API for the reader may need some extra configuring to allow file transfer through the other pins, but I cannot help you with this part.

Hopefully this should work!

1
  • I added the pins labels and photo in the question. Is it possible to go from these pins to GPIO or to USB ?
    – Basj
    Commented Mar 29, 2015 at 18:51
0

Based on your description of your need and visiting your project page, an alternative would be to make your RPi boot off a USB stick and use the internal card reader to accept cards from the user.

1
  • Thank you for your answer. It could be an idea, we need to think about it. Inserting/removing the microSD card might be too small / difficult for an every day use. For my project, I need it to be as handy as inserting/removing a SD card from a digital camera. I'll think about it... PS: could you add a link about "how to boot off a USB stick" on a RPi in your answer, for future reference?
    – Basj
    Commented Jul 12, 2018 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.