Hi everyone,
I'm working on a project that uses an Arduino Uno with:
- A flow meter (YF-S201)
- An I2C LCD (20x4)
- An RTC DS3231
- An SD card module (with AMS1117 voltage regulator)
Everything was working perfectly yesterday — I was logging data to the SD card multiple times. But today, the SD card module refuses to initialize. I get the usual "SD card initialization failed!" message, even with the same code that worked before.
What I've tried so far:
- Changed the SD card (2GB and 8GB, both FAT32 formatted)
- Switched CS pin from D10 to D4 (and updated code)
- Tried two different SD card modules: one 3.3V and one with 5V AMS1117 regulator
- Used minimal test sketch with
SD.begin()and file write - Checked and swapped jumper wires
- Tested with a different Arduino Uno
- Set
pinMode(CS, OUTPUT)beforeSD.begin()
Wiring (current setup with Arduino Uno):
Flow Meter YF-S201
- VCC (Red) → 5V
- GND (Black) → GND
- Signal (Yellow) → D2 (interrupt)
I2C LCD (20x4)
- VCC → 5V
- GND → GND
- SDA → A4
- SCL → A5
RTC DS3231
- VCC → 5V
- GND → GND
- SDA → A4
- SCL → A5
SD Card Module (AMS1117 version, 5V)
- VCC → 5V
- GND → GND
- CS → D10 (or D4 when testing)
- MOSI → D11
- MISO → D12
- SCK → D13
Here’s the test sketch I’m using:
#include <SD.h>
#include <SPI.h>
#define SD_CS 10 // or 4 when testing alternative CS
void setup() {
Serial.begin(9600);
pinMode(SD_CS, OUTPUT);
Serial.println("Initializing SD card...");
if (!SD.begin(SD_CS)) {
Serial.println("SD card initialization failed!");
return;
}
Serial.println("SD card initialized.");
File testFile = SD.open("test.txt", FILE_WRITE);
if (testFile) {
testFile.println("SD card test successful.");
testFile.close();
Serial.println("Write successful.");
} else {
Serial.println("Failed to open file for writing.");
}
}
void loop() {}
It was working fine yesterday, now nothing I try makes it work. Is it possible that the SD card module is damaged somehow? Or could it be SPI interference?