For really effective help you should provide more information.
What exact type of microcontroller are you using?
to whcih IO-pins do you have the SD-card connecteded?
Does your SD-Card-reader have pullup-resistors?
did you do a test if SD-card alone is working correctly ?
did you do a test if the rtc-module is working correctly?
Hello Stefan
I use node mcu ESP 8266 MOD microcontroller
I use D1 as SCL, D2 as SDA, D5 as SCK, D6 Miso, D7 mosi and D8 CS
No, I dont think so it's a standard SD card module
yes. it works
yes, it also works
the main problem is the ds3231 didn't work if I include sd program
I am sorry I dont have one, I am new so I tend to do it with notes rather than image
For SD I use D5 as SCK, D6 Miso, D7 mosi and D8 CS
For DS I use D1 as SCL, D2 as SDA
Yes, for that part I dont use a test... I immediately use the working program and test it if it works and it does... so I am just going to send the code that I use, I hope that's okay, still quite new with this stuff and didn't quite learn how to use the testing code.
#include <SPI.h>
#include <SD.h>
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop() {
// nothing happens after setup
}
I use Sdfile from an example but it's not that much of a difference except for the SPI part which I don't understand what it does. also I use Readwrite from SD examples to do this not the datalogger one, because i don't understand string, i use it once and still don't know what i do with it.
if you want effectice help you have to write more words.
This is not whatsApping for fun. This is serious engineering work even if it is just a hobby.
This says nothing about what
you have tested. You will have to clearly name the component. SD-Card or RTC.
Trying to be fast by not writing the real and SPECIFIC names just slows everything down because I have to ask back for confirmation.
And this line is missing in your combined code.
This means you open the file again and again and again in function loop.
And this is what is wrong in your code.
You should open the file and then after writing the time into the file you have to close the file again
This says nothing about what
you have tested. You will have to clearly name the component . SD-Card or RTC.
Trying to be fast by not writing the real and SPECIFIC names just slows everything down because I have to ask back for confirmation.
Ok does the code that starts with
DS3231
I use example code, I use SD library, and RTClib. Not the actual DS3231 lib because it didn't work after multiple tries of verifying in the Arduino app.
Ok does the code that starts with
DS3231 shows how time is printed and the time is increasing.
Yes so this down here is when I combine the SD module code with RTC