Normal, il faut mettre à l'heure la RTC.
A moins que cela ait été fait avec un autre programme, dans le code je ne vois aucun appel à Clock.setTime ou Clock.setDate.
comment faire alors ?
je comprend pas encore tout sa fait une semaine que je suis sur arduino
bon j'ai ca
#include "RTClib.h"
#include <LiquidCrystal_I2C.h>
RTC_DS1307 RTC;
LiquidCrystal_I2C lcd(0x27, 16,2);
void setup () {
lcd.init();
lcd.backlight();
Serial.begin(57600);
Wire.begin();
lcd.begin(16,2);
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(2018, 12, 22, 17, 36, 0));
}
}
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();
delay(1000);
}
si je clic sur moniteur serie une page apparait et je vois l'heure exacte du rtc defiler que dois je faire maintenant pour que ce code l heure ce mette a jour ?
// LIBRAIRIES
#include <DS3231.h>
#include <DHT.h> // inclure les librairies
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// ECRAN
LiquidCrystal_I2C lcd(0x27, 16,2); // Initialise le module 1602 I2C
LiquidCrystal_I2C lcd2 (0x3f,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
// FIN
// DATE
DS3231 Clock;
bool Century=false;
bool h12;
bool h24;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits; // Alarm
bool ADy, A12h, Apm; // Alarm
//FIN
// DHT 22
const int relayPin = 13; // PIN 13 pour test sur une LED de la carte
const int DHTPIN = 13;
// Type de capteur utiliser
#define DHTTYPE DHT22 // DHT 11
DHT dht(DHTPIN, DHTTYPE);// Initialise le capteur DHT11
// FIN
void setup() {
// LCD1 / LCD2 INITIALISATION
lcd.init(); // initialisation du LCD1
lcd2.init(); // initialisation du LCD2
lcd.backlight();
lcd2.backlight();
lcd.print("Initialisation...."); //afficher un message sur l'afficheur LCD
lcd2.print("Initialisation...."); //afficher un message sur l'afficheur LCD
delay (2500) ;
delay (2500);
Wire.begin();
Wire.begin();
lcd.begin(16,2);
lcd2.begin(16,2);
// EDITER MESSAGE LCD2
lcd2.init(); // initialize the lcd
lcd2.backlight();
lcd2.setCursor(5,0);
lcd2.print("Salut");
lcd2.setCursor(2,1);
lcd2.print("Mugen Zaraki");
// FIN
}
void loop() {
//DATE LCD
lcd.setCursor(0,0);
// nom du jour
switch (Clock.getDoW())
{ case 1: lcd.print("Lun "); break;
case 2: lcd.print("Mar "); break;
case 3: lcd.print("Merc"); break;
case 4: lcd.print("Jeu "); break;
case 5: lcd.print("Vend "); break;
case 6: lcd.print("Same "); break;
case 7: lcd.print("Dim "); break;
}
// jour emplacement
lcd.setCursor(4,0);
if (Clock.getDate() <10){
lcd.print("0");
}
lcd.print(Clock.getDate(), DEC);
lcd.print(" ");
// mois
switch (Clock.getMonth(Century))
{ case 1: lcd.print("Janv"); break;
case 2: lcd.print("Fev "); break;
case 3: lcd.print("Mars"); break;
case 4: lcd.print("Avr "); break;
case 5: lcd.print("Mai "); break;
case 6: lcd.print("Juin"); break;
case 7: lcd.print("Juil"); break;
case 8: lcd.print("Aout"); break;
case 9: lcd.print("Sept"); break;
case 10: lcd.print("Oct "); break;
case 11: lcd.print("Nov "); break;
case 12: lcd.print("Dec ");
}
lcd.print(" 2018");
lcd.print(Clock.getYear(), DEC);
//FIN
// BOUCLE TEMPERATURE
// Lecture de température et de l'humiditer environ 250 millisecondes
// La durer des capteurs peuvent etre regler jusqu'a 2 secondes (capteur tres lent)
float h = dht.readHumidity();
// Lit la temperature en degres Celsius (valeur par defaut
float t = dht.readTemperature();
float c = dht.readTemperature(true);
// Vérifie si toutes les lectures ont échoué et quitte le début (pour réessayer).
if (isnan(h) || isnan(t) || isnan(c)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// FIN
// Temperature et humidité LCD
lcd.setCursor(0, 1);
lcd.print("");
lcd.print(t);
lcd.print(" C");
lcd.setCursor(9, 1);
lcd.print("");
lcd.print(h);
lcd.print(" % ");
Serial.print("Temperature = ");
Serial.print(t);
Serial.print(" *C ");
Serial.print("Humidity = ");
Serial.print(h);
Serial.print(" %\t ");
Serial.println();
if (h >= 75 && h <= 80) // si hum. est = ou sup. a 75 ET hum infer. ou = a 80 relais ouvert
{
digitalWrite(relayPin, HIGH);
}
else
{
digitalWrite(relayPin, LOW); // Sinon relais fermé
}
delay(1000);// Delai d'une seconde entre les mesures
}
// FIN
Pour afficher un message sur ton lcd, tu positionnes le curseur avec setCursor puis tu affiches avec print. Le curseur est automatiquement positionné à la suite, donc tu continues avec un autre print pour afficher la suite...
je comprend pas ta reponse
je voulais savoir comment etre sur que mon module RTC soit a jour
Il doit y avoir un programme pour ça dans les exemples de la bibliothèque