A place for all the arduino code I write.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
756 B

#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);
}