Bonsoir,
toujours pour mon projet de volets, j'ai essayé de câbler et d'utiliser un module RTC DS1307
J'ai suivi la page du randomnerdtuto :
J'ai adapté le câblage à ma carte ESP32-S3-wroom-1
DS1307 ESP32
SCL --> GPIO 9
SDA --> GPIO 8
VCC --> 3V3
GND --> GND
Les ports semblent OK puisque le scanner I2C trouve deux adresses
Mais quand je charge le code proposé :
/*
Rui Santos & Sara Santos - Random Nerd Tutorials
Complete project details at https://RandomNerdTutorials.com/esp32-ds1307-real-time-clock-rtc-arduino/
Based on the RTClib Library examples: github.com/adafruit/RTClib/blob/master/examples
*/
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include "RTClib.h"
RTC_DS1307 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup () {
Serial.begin(115200);
delay(2000);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
//Serial.flush();
//while (1) delay(10); //supprimé sinon ça démarre jamais
delay(2000);
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// 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(2014, 1, 21, 3, 0, 0));
}
// When time needs to be re-set on a previously configured device, the
// 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(2014, 1, 21, 3, 0, 0));
}
void loop () {
// Get the current time from the RTC
DateTime now = rtc.now();
// Getting each time field in individual variables
// And adding a leading zero when needed;
String yearStr = String(now.year(), DEC);
String monthStr = (now.month() < 10 ? "0" : "") + String(now.month(), DEC);
String dayStr = (now.day() < 10 ? "0" : "") + String(now.day(), DEC);
String hourStr = (now.hour() < 10 ? "0" : "") + String(now.hour(), DEC);
String minuteStr = (now.minute() < 10 ? "0" : "") + String(now.minute(), DEC);
String secondStr = (now.second() < 10 ? "0" : "") + String(now.second(), DEC);
String dayOfWeek = daysOfTheWeek[now.dayOfTheWeek()];
// Complete time string
String formattedTime = dayOfWeek + ", " + yearStr + "-" + monthStr + "-" + dayStr + " " + hourStr + ":" + minuteStr + ":" + secondStr;
// Print the complete formatted time
Serial.println(formattedTime);
Serial.println();
delay(3000);
}
La console me donne des erreurs et cela ne fonctionne pas :
00:28:29.801 -> Couldn't find RTC
00:28:29.801 ->
00:28:30.397 -> E (4013) i2c.master: I2C transaction unexpected nack detected
00:28:30.397 -> E (4014) i2c.master: s_i2c_synchronous_transaction(924): I2C transaction failed
00:28:30.397 -> E (4015) i2c.master: i2c_master_multi_buffer_transmit(1186): I2C transaction failed
00:28:30.397 -> E (4023) i2c.master: I2C transaction unexpected nack detected
00:28:30.429 -> E (4028) i2c.master: s_i2c_synchronous_transaction(924): I2C transaction failed
00:28:30.429 -> E (4035) i2c.master: i2c_master_receive(1240): I2C transaction failed
00:28:30.429 -> E (4041) i2c.master: I2C transaction unexpected nack detected
00:28:30.429 -> E (4046) i2c.master: s_i2c_synchronous_transaction(924): I2C transaction failed
00:28:30.429 -> E (4054) i2c.master: i2c_master_multi_buffer_transmit(1186): I2C transaction failed
00:28:30.462 -> E (4061) i2c.master: I2C transaction unexpected nack detected
00:28:30.462 -> E (4066) i2c.master: s_i2c_synchronous_transaction(924): I2C transaction failed
00:28:30.462 -> E (4073) i2c.master: i2c_master_transmit_receive(1220): I2C transaction failed
00:28:30.462 -> Sunday, 2000-00-00 45:129:00
00:28:30.462 ->
00:28:33.468 -> E (7081) i2c.master: I2C transaction unexpected nack detected
00:28:33.468 -> E (7081) i2c.master: s_i2c_synchronous_transaction(924): I2C transaction failed
00:28:33.468 -> E (7083) i2c.master: i2c_master_transmit_receive(1220): I2C transaction failed
00:28:33.468 -> Sunday, 2000-00-00 45:129:00
Ces 4 dernières lignes se répètent ensuite en boucle...
C'est mon module qui est HS ? mon code qui est pourri ?
merci d'avance
(pile changée, connexion testées)
