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

Basj
  • 782
  • 3
  • 17
  • 46
  • 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 Mar 13 '15 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 Mar 13 '15 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 Mar 13 '15 at 16:35
  • You could use something like this to do what @Joan mentions https://www.adafruit.com/product/908 – Steve Robillard Mar 13 '15 at 16:38
  • 2
    You further can use a SDCard to USB adapter, which is a tradeoff between both. Just google SDCard USB adapter. – user236012 Mar 13 '15 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 Mar 13 '15 at 23:32
  • @Milliways Oh great if you have a similar adapter, can you post your result here when you'll tried on Pi? What are the pins'labels by the way? (I can't see them on this photo nor on other photos of this product) – Basj Mar 14 '15 at 14:39
  • UPDATE : I added the pins labels and photo in the question. Is it possible to go from these pins to GPIO or to USB ? – Basj Mar 29 '15 at 18:51

5 Answers5

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
Jacobm001
  • 11,898
  • 7
  • 46
  • 56
KeremE
  • 116
  • 1
  • 2
  • 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 Mar 06 '16 at 09: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 – Alexey Vesnin May 26 '16 at 02: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. – Dmitry Grigoryev Mar 21 '22 at 07: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).

Egal
  • 169
  • 2
  • 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 Mar 30 '15 at 06: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 Mar 30 '15 at 09: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 Mar 30 '15 at 10:37
  • 2
    You can get a module that handles SPI (and other protocols) to USB like thie one for about $20: http://www.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 Mar 30 '15 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 http://www.samplerbox.org will be opensource, so I want that it's easy for anyone to source the components) – Basj Mar 30 '15 at 20:54
  • What's the point in connecting both 5V and 3.3V pins? – Dmitry Grigoryev Mar 21 '22 at 07:53
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

Kolban
  • 1,784
  • 2
  • 16
  • 28
  • Cool article indeed. I just looked quickly, is there something about transfer rate @Kolban ? – Basj Jul 28 '17 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!

angussidney
  • 703
  • 9
  • 20
  • I added the pins labels and photo in the question. Is it possible to go from these pins to GPIO or to USB ? – Basj Mar 29 '15 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.

Bruno Bronosky
  • 1,460
  • 17
  • 19
  • 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 Jul 12 '18 at 07:50