Bonjour tout le monde !
J'ai en ma possession une Mega 2560 et le module RTC/SD suivant :
J'arrive pour le moment à écrire sur une carte SD via ce shield, mais je n'arrive pas à utiliser l'horloge temps réel. Je m'explique :
J'utilise le code suivant pour initialiser l'horloge :
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
void setup () {
Serial.begin(57600);
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
// uncomment it & upload to set the time, date and start run the RTC!
//RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.print(" since 1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");
// calculate a date which is 7 days and 30 seconds into the future
DateTime future (now.unixtime() + 7 * 86400L + 30);
Serial.print(" now + 7d + 30s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();
Serial.println();
delay(3000);
}
J'observe sur le moniteur série que l'horloge n'arrive pas à calculer correctement le " now + 7d + 30s ", il me retourne lors de ce calcul 7 jours de différence mais également 12heures de differences et 3s.
Cependant j'observe egalement que cette erreur revient à chaque fois que je compile :
ATTENTION : Faux .github dossier dans la bibliothèque 'RTClib'
Une idée pour corriger cette erreur ? Le but serait en fait de pouvoir enregistrer dans un fichier txt des resultats de mesures d'un capteur, mais avec l'option suivante :
Si il y a plusieurs mesures le meme jour on continue a stocker dans le meme fichier txt en sautant une ligne entre deux mesures
Si ce n'est pas le meme jour on creer un nouveau fichier txt
Je vous remercie d'avance !