bonjour je viens vers vous au sujet d'un problème avec ma rtc 3231 avec la lib rct.lib.
quand je prend le programme rtc lib et que je mais la rtc l'heure et que je simule une coupe la rtc garde l'heure .
Mais quand je le fait avec mon programme la rtc redémarre a 00:00:00 et je comprend pas pourquoi si vous pourriez m'aider merci . voila ce que j'ai fait dans mon programme ,j'ai juste fait un copier colle des fonction pour la rtc car mon programme est trop long.
#include <UTFT.h>
#include <URTouch.h>
#include <UTFT_SdRaw.h>
#include <UTFT_Buttons.h>
#include <SPI.h>
#include <SdFat.h>
#include <DHT.h>
#include <Wire.h> //http://arduino.cc/en/Reference/Wire (included with Arduino IDE)
#include <OneWire.h>
#include "RTClib.h"
#include <EEPROM.h>
#include <Adafruit_Sensor.h>
RTC_DS3231 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
// déclaration de la typo
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
void setup()
{
Wire.begin();
//HORLOGE
#ifndef ESP8266
while (!Serial); // for Leonardo/Micro/Zero
#endif
Serial.begin(9600);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// following line sets the RTC to the date & time this sketch was compiled
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
//rtc.adjust(DateTime(2021, 9, 19, 10, 26, 0));
}
void Home(){
switch(affichage){
case 0:
// arriere plan, bouton, intitulé de variable , etc
myFiles.load(0, 0, 320, 240, "MENU.RAW");
affichage=true;// on passe a true pour ignoré ces instruction a la prochaine boucle
break;
/* jusque la pas de souci*/
case 1:
//AFFICHAGE DE L HEURE
//HORLOGE
myGLCD.setFont(BigFont);
DateTime now = rtc.now();
if (now.hour()<10){myGLCD.print("0",100,0);myGLCD.printNumI(now.hour(),118,0);} else {myGLCD.printNumI(now.hour(),100,0);}
myGLCD.print(":",130,0);
if (now.minute()<10){myGLCD.print("0",140,0);myGLCD.printNumI(now.minute(),158,0);} else {myGLCD.printNumI(now.minute(),140,0);}
myGLCD.print(":",170,0);
if (now.second()<10){myGLCD.print("0",180,0);myGLCD.printNumI(now.second(),198,0);} else {myGLCD.printNumI(now.second(),180,0);}
myGLCD.setFont(SmallFont);
myGLCD.setColor(0,0,0);
myGLCD.setBackColor(255,255,255);
if (now.day()<10){myGLCD.print("0",0,220);myGLCD.printNumI(now.day(),18,220);} else {myGLCD.printNumI(now.day(),0,220);}
myGLCD.print("/",15,220);
if (now.month()<10){myGLCD.print("0",25,220);myGLCD.printNumI(now.month(),35,220);} else {myGLCD.printNumI(now.month(),25,220);}
myGLCD.print("/",45,220);
if (now.year()<10){myGLCD.print("0",55,220);myGLCD.printNumI(now.year(),73,220);} else {myGLCD.printNumI(now.year(),55,220);}
break;
}
}