replace the deepsleep by a delay. The deepsleep looks not functional, same for lightsleep.

This commit is contained in:
nago 2025-04-02 23:34:47 +02:00
parent 68db78cd5e
commit 1180e340fb

View File

@ -16,7 +16,7 @@ ESP8266WebServer server(HTTP_PORT);
#endif
// Durée de sommeil en microsecondes (par exemple, 5 secondes)
const int sleepDuration = 5 * 1000000;
const int sleepDuration = 1 * 1000000;
// Fonction pour configurer et connecter au réseau Wi-Fi
void setup_wifi() {
@ -120,6 +120,19 @@ void goToDeepSleep() {
ESP.deepSleep(sleepDuration);
}
void goToLightSleep() {
DebugPort.println("Going to light sleep...");
wifi_set_opmode(NULL_MODE); // Turn off Wi-Fi
wifi_fpm_set_sleep_type(LIGHT_SLEEP_T); // Set light sleep mode
wifi_fpm_open();
//gpio_pin_wakeup_enable(GPIO_ID_PIN(D1), GPIO_PIN_INTR_LOLEVEL); // Enable wakeup on GPIO
//wifi_fpm_do_wakeup_gpio(true);
//wifi_fpm_set_wakeup_gpio_mode(WAKEUP_GPIO_MODE_KEEP_HIGH);
wifi_fpm_set_wakeup_cb(loop);
wifi_fpm_do_sleep(sleepDuration); // Sleep
delay(20); // Short delay to allow the ESP8266 to enter sleep mode
}
// Fonction d'initialisation principale
void setup() {
@ -139,11 +152,14 @@ void setup() {
// Boucle principale
void loop() {
server.handleClient();
readTicPort();
delay(1000);
// Si aucune requête n'est en cours, mettre l'ESP8266 en mode deep sleep
/*
if (server.client().available() == 0) {
goToDeepSleep();
}
goToLightSleep();
}*/
}