SD module "initialization failed" message

Hello, I am very new to Arduino and electronics and I'm running into an issue I don't know how to solve. I'm working on a school project for which I need to measure the voltage of a circuit every second and record it to a storage device for later inspection. I am using an Arduino Leonardo ETH with a DS3231 RTC module, a DC0-25V Voltage sensor from Amazon and a AZDelivery SD TF module card memory shield also from Amazon. I've gotten the RTC and the voltage sensor to work flawlessly but the SD card module is causing me some problems. I connected the wires like this: GND to GND, VCC to 5V, MISO to digital pin 12, MOSI to digital pin 11, SCK to digital pin 13 and CS to either digital pin 10 or digital pin 4. I've tried quite a few things to fix my problem, like:

  • The CardInfo and ReadWrite examples from the SD library.
  • The CardInfo (I believe it has a different name but it does the same thing) example from
    the SDFat library.
  • (like I said before) switching the CS pin between either pin 10 or pin 4.
  • formatting the SD card using the standard option on my PC and using a SD card formatter
    from the SD Association.
  • formatting my SD card to FAT16 and FAT32.
  • using a spare SD card to check if the one I intended to use wasn't broken.
  • using a spare SD card module to check if the one I was using wasn't broken.
    I tried all of those things yet I always get the same message: "initialization failed". But weirdest of all sometimes (about 1 in 30 tries) the SD card initializes correctly but it says my Sd card isn't formatted correctly. I used all the most recent versions (at the moment, 2 December 2024) for the libraries and the Arduino IDE software. I don't understand where the problems arises, does anyone with more knowledge and experience know what I am doing wrong? Does anyone know of some common issues that may arise and possibly how to solve them? Any help, even not a direct answer, will be highly appreciated. Thanks!

Doesn't the Leonardo ETH have a built in uSD card slot?
https://docs.arduino.cc/retired/boards/arduino-leonardo-eth/
If you want to use an SPI device, the SPI pins are available only on the ICSP pins.

Mine looks very different to that one, and doesn't have a built in SD port. Mine might be a regular Leonardo but the IDE software says its a Leonardo ETH.

Yes, but the module runs on 5V and has a built in transformer which changes it to 3.3V for the card.

Prove it.

The Leonardo has the SPI pins only on the ICSP connector, not on D11-13.

I do not see a difference... or an SD card slot... with Leonardo.

Pins 11/12/13 on a Leonardo ain't the SPI pins. Check the pinout diagram or schematic of the Leonardo ETH, I have no reason to believe that it's different. Use the 6-pin header.

Thank you so much, it works now! :smiley: I guess I should have done some more research but oh well.

1 Like

Sorry that I missed that and hence repeated your answer.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.