Write ESP DHT22 demo
This commit is contained in:
parent
cc2fe93ed8
commit
547f841124
5 changed files with 61 additions and 24 deletions
4
.gitmodules
vendored
4
.gitmodules
vendored
|
@ -4,3 +4,7 @@
|
||||||
[submodule "dht22/lib/SimpleDHT"]
|
[submodule "dht22/lib/SimpleDHT"]
|
||||||
path = dht22/lib/SimpleDHT
|
path = dht22/lib/SimpleDHT
|
||||||
url = https://github.com/winlinvip/SimpleDHT
|
url = https://github.com/winlinvip/SimpleDHT
|
||||||
|
[submodule "dht22-esp8266/lib/esp8266-dht22"]
|
||||||
|
path = dht22-esp8266/lib/esp8266-dht22
|
||||||
|
url = https://github.com/Defozo/esp8266-dht22.git
|
||||||
|
branch = patch-1
|
||||||
|
|
33
dht22-esp8266/dht22-esp8266.ino
Normal file
33
dht22-esp8266/dht22-esp8266.ino
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#include "lib/esp8266-dht22/dht22.h"
|
||||||
|
#include "lib/esp8266-dht22/dht22.c"
|
||||||
|
|
||||||
|
#define DHT_TYPE DHT22
|
||||||
|
// D1
|
||||||
|
#define DHT_PIN_DATA 5
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
Serial.println("DHT22 Demo");
|
||||||
|
Serial.println("==========");
|
||||||
|
Serial.println("Board: ESP8266");
|
||||||
|
|
||||||
|
Serial.print("Initialising the DHT - ");
|
||||||
|
DHT_init(DHT_PIN_DATA, DHT_TYPE, 1);
|
||||||
|
DHT_begin();
|
||||||
|
|
||||||
|
Serial.println("done");
|
||||||
|
Serial.print("Waiting to warm DHT22 up - ");
|
||||||
|
delay(2000); // Give the DHT22 time to warm up
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
float temp, humidity;
|
||||||
|
|
||||||
|
temp = readTemperature(false);
|
||||||
|
humidity = readHumidity();
|
||||||
|
|
||||||
|
Serial.print("Temperature: "); Serial.print(temp); Serial.println("°C");
|
||||||
|
Serial.print("Humidity: "); Serial.print(humidity); Serial.println("%");
|
||||||
|
|
||||||
|
delay(1000);
|
||||||
|
}
|
1
dht22-esp8266/lib/esp8266-dht22
Submodule
1
dht22-esp8266/lib/esp8266-dht22
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit b949ac35a553e4089f3e81dc7e4d739a02a00f78
|
|
@ -39,4 +39,3 @@ void loop() {
|
||||||
|
|
||||||
delay(2000); // We can only read every 2 seconds
|
delay(2000); // We can only read every 2 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 80ac2b47c9caca07edf75f38289cfd64023872c9
|
Subproject commit 155f77445daa0b4757f79d984865ba68a59a7cf8
|
Loading…
Reference in a new issue