fix printing/sleeping for dht

This commit is contained in:
Mathieu Maret 2019-05-14 21:03:28 +02:00
parent 43ad7977f6
commit 4fc32a30d8
1 changed files with 4 additions and 4 deletions

View File

@ -70,14 +70,14 @@ int32_t channel = 11; //0 for Auto
ADC_MODE(ADC_VCC); ADC_MODE(ADC_VCC);
void setup() void setup()
{ {
Serial.begin(115200);
Serial.print("\nRunning\n");
#ifdef USE_DHT #ifdef USE_DHT
// Power on DHT11 // Power on DHT11
pinMode(DHT_POWER_PIN, OUTPUT); pinMode(DHT_POWER_PIN, OUTPUT);
digitalWrite(DHT_POWER_PIN, HIGH); digitalWrite(DHT_POWER_PIN, HIGH);
#endif #endif
Serial.begin(115200);
Serial.print("\nRunning\n");
#ifdef USE_BME680 #ifdef USE_BME680
if (!bme.begin()) { if (!bme.begin()) {
Serial.println("Could not find a valid BME680 sensor, check wiring!"); Serial.println("Could not find a valid BME680 sensor, check wiring!");
@ -222,6 +222,8 @@ int wifiConnect() {
int doDHTMeasure() int doDHTMeasure()
{ {
#ifdef USE_DHT #ifdef USE_DHT
// Wait for DHT to be ready
delay(2000);
float h = dht.readHumidity(); float h = dht.readHumidity();
// Read temperature as Celsius (the default) // Read temperature as Celsius (the default)
float t = dht.readTemperature(); float t = dht.readTemperature();
@ -265,8 +267,6 @@ int doDHTMeasure()
void loop() void loop()
{ {
// Wait for DHT to be ready
delay(2000);
doDHTMeasure(); doDHTMeasure();
doBMEMeasure(); doBMEMeasure();
ESP.deepSleep(SLEEP_TIME_SECOND * 1000000, WAKE_RF_DEFAULT); ESP.deepSleep(SLEEP_TIME_SECOND * 1000000, WAKE_RF_DEFAULT);