Go Down

Topic: SD card Initialization failed during the data logger interface with Arduino Uno (Read 485 times) previous topic - next topic

Suvendu_dash

I try to collect the LDR data and save it in SD card. but i find out Initialization failed status during checking the serial monitor. Plz give some solutions in this regards. I attach the Code and the Serial Monitor Screen Short.
 

Code: [Select]

#include<SD.h>
#include <SPI.h>

#define SD_ChipSelectPin 10  
File myFile;
int LDRPin = A0;
int val=0;

void setup() {
  
pinMode(LDRPin, INPUT);
Serial.begin(9600);
Serial.println("Initialising SD card...");
if(!SD.begin(SD_ChipSelectPin))
{
  Serial.println("Initialization failed");
  return;
}
  Serial.println("Initialization success");
  
}

void loop() {

val=analogRead(LDRPin);
myFile=SD.open("test.txt", FILE_WRITE);
if(myFile)
{
  myFile.print(val);
  Serial.print(val);
  myFile.print(",");
  Serial.print(",");
  myFile.println(millis());
  Serial.println(millis());
  myFile.close();
}
else
{
  Serial.println("Error in opening file");
}
delay(1000);
}


ieee488


Suvendu_dash


GolamMostafa

Quote
I changed it from CS pin 10 to 4 but facing the same problem.
Please, make a physical wiring change in your SD Card. The CS-pin of the SD Card must be connected to DPin-4 of the UNO. Also, operate the SD card on 3.3V.



I executed your codes without any change (except #define SD_ChipSelectPin 4) in my UNO, and the codes are working fine.


ieee488

Please, make a physical wiring change in your SD Card. The CS-pin of the SD Card must be connected to DPin-4 of the UNO. Also, operate the SD card on 3.3V.



I am looking at my Seeed Studio SD card shield, and I don't see what you have in the photo.


GolamMostafa


Suvendu_dash


GolamMostafa

You module has the CS-pin, connect it to Dpin-4 of the UNO and execute the program. The program of your original post should work; it works for me.

Suvendu_dash

Is their any certain file format is required for SD card??

My SD card file format is FAT32. 

Suvendu_dash

Thanks to Everyone ...due to some connection problem i'm not getting the data..now it's solved.

GolamMostafa


Go Up