Compare commits
2 Commits
a0eb3ebaeb
...
03329c5220
Author | SHA1 | Date | |
---|---|---|---|
03329c5220 | |||
10e1c134e5 |
@ -15,6 +15,9 @@
|
|||||||
ESP8266WebServer server(HTTP_PORT);
|
ESP8266WebServer server(HTTP_PORT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Durée de sommeil en microsecondes (par exemple, 5 secondes)
|
||||||
|
const int sleepDuration = 5 * 1000000;
|
||||||
|
|
||||||
// Fonction pour configurer et connecter au réseau Wi-Fi
|
// Fonction pour configurer et connecter au réseau Wi-Fi
|
||||||
void setup_wifi() {
|
void setup_wifi() {
|
||||||
delay(10);
|
delay(10);
|
||||||
@ -111,6 +114,12 @@ void setup_serial() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fonction pour mettre l'ESP8266 en mode deep sleep
|
||||||
|
void goToDeepSleep() {
|
||||||
|
DebugPort.println("Going to deep sleep...");
|
||||||
|
ESP.deepSleep(sleepDuration);
|
||||||
|
}
|
||||||
|
|
||||||
// Fonction d'initialisation principale
|
// Fonction d'initialisation principale
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
@ -132,4 +141,9 @@ void setup() {
|
|||||||
void loop() {
|
void loop() {
|
||||||
server.handleClient();
|
server.handleClient();
|
||||||
readTicPort();
|
readTicPort();
|
||||||
|
|
||||||
|
// Si aucune requête n'est en cours, mettre l'ESP8266 en mode deep sleep
|
||||||
|
if (server.client().available() == 0) {
|
||||||
|
goToDeepSleep();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user