SD card not found

My groupmates in research are working on a project. We are using a data logging shield module (it contains both Real Time Clock and SD card module) and we have problems accessing our SD card through it. We tried to use the default pin for CS (pin 10 as we are using Arduino mega 2560) and we tried using the CS pin in the module and reroute it to another working pin which was tested through the usage of LED.

The SD card cannot be found through the code of "const int cspin = 21; if(SD.begin(cspin)){Serial.println("SD Card not found")}else{Serial.println("SD Card ready to use")}"

Please check the codes below. (Note: we rerouted the CS pin to pin 21 and used 3 different SD cards, 2 adapters and 1 real SD card)

I ONLY have a picture of the data logging shield module. I can't show the other part of it though

Oh and one more thing, the codes aren't done because we are trying to adjust with our budget so I forgot to change some parts.

final_res.ino (4.82 KB)

  teacher = SD.open("TeacherList.txt", FILE_WRITE);

You try to open an SD file before you have called SD.begin which might mess things up.

Pete

@el supremo

first of all, thank you for your time for checking my post

I tried changing it's line of code and moved it after the if, else statements in the setup. Still, the output was "SD Card not found". I don't know why but this is the second module that didn't find the SD card, similar to the first module.

Edit:
FYI, the first module we used was a micro SD Module and it worked last year around december but it didn't work last january when classes resumed. That's why we changed module and the module we acquired to replace it is a data logging shield with an RTC branded by deek-robot.

Did you move this too:?

  teacher.close();

My experience with SD problems has been that it was caused by a wiring problem but I usually use breadboards. That shouldn't be the case when you're using a shield and pin 10, but in your photo the wire connected to CS isn't soldered and won't make a good connection.

Pete

Yes, I moved the teacher.close(); too

I didn't solder it yet because it wasn't working and while trying the code, and the wire itself (even attaching a LED, that is connected to a GND, lights up).

Note: default values of our LED is ON whenever it is connected to a GND.

See attachment to have the picture of it.

The LED being on may indicate that you've got the right pin but it does not indicate that you will have a good connection when the processor tries to send data to the SD card.

Pete

Already soldered it, used an example from the SD library, research on the module's default pins for the SD card and still not working... The board might actually be the one at fault but I still think there is something missing from this.

I'm just gonna try do more researching and I hope people can also help too. I really need this to work by this day. (+8:00 GMT) and it's 12:00 here now. :frowning: