Added deepsleep
This commit is contained in:
@@ -60,10 +60,6 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// Wait a few seconds between measurements.
|
|
||||||
millicounter = millis();
|
|
||||||
|
|
||||||
if (millicounter >= millitotal) {
|
|
||||||
// Reading temperature or humidity takes about 250 milliseconds!
|
// Reading temperature or humidity takes about 250 milliseconds!
|
||||||
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
|
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
|
||||||
h = dht.readHumidity();
|
h = dht.readHumidity();
|
||||||
@@ -85,17 +81,8 @@ void loop() {
|
|||||||
client.end();
|
client.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
//set new milli counter
|
|
||||||
//millis will overflow after approx. 52 days. To prevent errors we're checking the limits
|
|
||||||
if (millis() + (MEASURESECONDS * 1000) <= ULONG_MAX) {
|
|
||||||
millitotal = millis() + (MEASURESECONDS * 1000);
|
|
||||||
} else {
|
|
||||||
millitotal = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ESP.deepSleep(MEASURESECONDS * 1000000);
|
||||||
//ESP.deepSleep(MEASURESECONDS * 1000);
|
|
||||||
//Let the esp chill a bit
|
//Let the esp chill a bit
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user