I am trying to create a file using the date that I read from my ds3231, although it is not working. I want it to do it thorugh the ds 3231 because i need to record data daily on the sd card.
PLEASE HELPPP
Here is my code:
#include <DS3232RTC.h> // GitHub - JChristensen/DS3232RTC: Arduino Library for Maxim Integrated DS3232 and DS3231 Real-Time Clocks
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4); //sometimes the adress is not 0x27. Change to 0x3f if it dosn't work.
#include <SD.h>
#include <SPI.h>
File myFile;
int pinCS = 10;
char filename[] = "00000000.CSV";
String todayDay, todayMonth, todayYear;
String todayHour, todayMinute, todaySeconds;
void setup()
{
Serial.begin(9600);
setSyncProvider(RTC.get); // the function to get the time from the RTC
if (timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
lcd.init(); //Start the LC communication
lcd.backlight();
pinMode(pinCS, OUTPUT);
if (SD.begin())
{
Serial.println("SD card is ready.");
}
else {
Serial.println("FAIL!!!!");
return;
}
}
void loop()
{
todayDay = day();
todayMonth = month();
todayYear = year();
todayHour = hour();
todayMinute = minute();
todaySeconds = second();
String date = String(todayMonth + "-" + todayDay + "-" + todayYear);
String dateFile = String(""" + todayMonth + "-" + todayDay + "-" + todayYear + ".csv" + """);
Serial.println(dateFile);
String todayTime = String(todayHour + "-" + todayMinute + "-" + todaySeconds);
dateFile.trim();
myFile = SD.open(dateFile,FILE_WRITE);
if (myFile)
{
myFile.println(todayTime);
myFile.close();
}
else
{
Serial.println("Error opening the File");
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(date);
lcd.setCursor(0, 1);
lcd.print(todayTime);
delay(1000);
}
HERE is my error message!!
RTC has set the system time
SD card is ready.
"2-10-2020.csv"
Error opening the File