From 4fc32a30d858302132c68522fa5e8ba5e7c4cc31 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Tue, 14 May 2019 21:03:28 +0200 Subject: [PATCH] fix printing/sleeping for dht --- deepSleep.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deepSleep.ino b/deepSleep.ino index b7c8a3b..cf9162e 100644 --- a/deepSleep.ino +++ b/deepSleep.ino @@ -70,14 +70,14 @@ int32_t channel = 11; //0 for Auto ADC_MODE(ADC_VCC); void setup() { + Serial.begin(115200); + Serial.print("\nRunning\n"); #ifdef USE_DHT // Power on DHT11 pinMode(DHT_POWER_PIN, OUTPUT); digitalWrite(DHT_POWER_PIN, HIGH); #endif - Serial.begin(115200); - Serial.print("\nRunning\n"); #ifdef USE_BME680 if (!bme.begin()) { Serial.println("Could not find a valid BME680 sensor, check wiring!"); @@ -222,6 +222,8 @@ int wifiConnect() { int doDHTMeasure() { #ifdef USE_DHT + // Wait for DHT to be ready + delay(2000); float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); @@ -265,8 +267,6 @@ int doDHTMeasure() void loop() { - // Wait for DHT to be ready - delay(2000); doDHTMeasure(); doBMEMeasure(); ESP.deepSleep(SLEEP_TIME_SECOND * 1000000, WAKE_RF_DEFAULT);