Different SD card initialization failed

Hi all,

I could not succeed in making my sd module working. every time the initialization fails.

I am using Arduino uno wifi, tried various sdhc cards 8, 16 and 32GB.
The wirering is cheched and rewired multiple times.
All kinds of sketches are used and also different SS pins (10 and 4 are used).
My module is the following:

The most simple code used:

#include <SD.h>
#include <SPI.h>
//#include "SdFat.h"

//SdFat SD;
int pinCS = 4;

void setup() {
  pinMode(pinCS, OUTPUT);
  digitalWrite(pinCS, HIGH);

  // SD Card Initialization
  if (SD.begin(4))
    Serial.println("SD card is ready to use.");
  } else
    Serial.println("SD card initialization failed");
void loop() {
  // empty

Help is appreciated.

Seeing your code would be appreciated

Sample code added. As you can see also experimented with SdFat library. But whatever sketch i use it doen't wordk. Now i read sometimes that the max size for sd card is 2 GB. Soes anybody know?

Which one exactly? If it's the Rev2, you might have tried to use pins 10, 11, 12 and 13 which are, according to the schematic, not the SPI pins.

Please edit your post, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.

It is the REV 2

So how did you wire it? Pins 11, 12 and 13 and a pin for CS or the pins on the SPI header and a pin for CS?

Also tried pin 10 and changed the code accordingly. Also tried 2 sd card modules.

Wrong pins. An Uno is not the same as an Uno Wifi Rev2 from that perspective. From the schematic of the Uno WiFi Rev2 (https://content.arduino.cc/assets/UNOWiFiREV2V4.0_sch.pdf)


Oke what pins should i use?

Do i have to connect MOSI to PC0, MISO to PC1, SCK to PC2 and CS to pin 4 as i already did?

I have done the wiring like that and now it's working fine.
Thanx a lot Sterretje. Dutch?

Yes, but living in South Africa.

Under each reply is a solution checkbox. Tick the one under the most useful reply to let others know that the problem is solved.


My Arduino D1 occupies those 6 pins with the WiFi module, there are no 6 pin SPI only the Wifi esp8266 metalic body than covers integrated circuits

Is a there a way to attach a photo?

Drag and drop.

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