Skip to content

Commit

Permalink
wait 2 sec after power on, check acquireresult
Browse files Browse the repository at this point in the history
  • Loading branch information
chaeplin committed May 25, 2016
1 parent acf67df commit 8e96548
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions examples/DHT_esp8266/DHT_esp8266.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,25 @@ void dht_wrapper() {
DHT.isrCallback();
}

void setup()
{
void setup() {
startMills = millis();
Serial.begin(115200);

/*
while (!Serial) {
yield(); // wait for serial port to connect.
}
*/

Serial.println("");
Serial.println("DHT Example program using DHT.acquire and DHT.acquireAndWait");
Serial.println("");

// delay 2 sec before start acquire
while ( (millis() - startMills) < 2000 ) {
yield();
}

// blocking method
acquirestatus = 0;
acquireresult = DHT.acquireAndWait(1000);
Expand All @@ -48,8 +58,7 @@ void setup()
}
}

void loop()
{
void loop() {
if (bDHTstarted) {
acquirestatus = DHT.acquiring();
if (!acquirestatus) {
Expand All @@ -64,17 +73,21 @@ void loop()
}

if ((millis() - startMills) > REPORT_INTERVAL) {
Serial.println("");

Serial.print("Humidity (%): ");
Serial.println(h);
if ( acquireresult == 0 ) {
Serial.println("");

Serial.print("Temperature (oC): ");
Serial.println(t);
Serial.print("Humidity (%): ");
Serial.println(h);

Serial.print("Dew Point (oC): ");
Serial.println(d);

Serial.print("Temperature (oC): ");
Serial.println(t);

Serial.print("Dew Point (oC): ");
Serial.println(d);

} else {
Serial.println("Is dht22 connected");
}
startMills = millis();

// to remove lock
Expand Down

1 comment on commit 8e96548

@chaeplin
Copy link
Owner Author

@chaeplin chaeplin commented on 8e96548 May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result // disconnecting dht22

DHT Example program using DHT.acquire and DHT.acquireAndWait


Humidity (%): 41.10
Temperature (oC): 28.50
Dew Point (oC): 13.99

Humidity (%): 41.50
Temperature (oC): 28.60
Dew Point (oC): 14.23

Humidity (%): 41.60
Temperature (oC): 28.60
Dew Point (oC): 14.26

Humidity (%): 41.60
Temperature (oC): 28.60
Dew Point (oC): 14.26
Is dht22 connected
Is dht22 connected
Is dht22 connected
Is dht22 connected
Is dht22 connected
Is dht22 connected
Is dht22 connected

Humidity (%): 48.70
Temperature (oC): 32.20
Dew Point (oC): 20.01

Humidity (%): 48.90
Temperature (oC): 32.20
Dew Point (oC): 20.08

Humidity (%): 48.90
Temperature (oC): 32.20
Dew Point (oC): 20.08
Is dht22 connected
Is dht22 connected
Is dht22 connected

Humidity (%): 39.10
Temperature (oC): 32.00
Dew Point (oC): 16.33
�```

Please sign in to comment.