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.
48 lines
857 B
48 lines
857 B
// https://www.youtube.com/watch?v=-AvF2TsB2GI&list=PLGs0VKk2DiYw-L-RibttcvK-WBZm8WLEP&index=50 |
|
|
|
#include <Arduino.h> |
|
|
|
#include <Adafruit_Sensor.h> |
|
#include <DHT.h> |
|
// #include <DHT_U.h> |
|
|
|
#define DHTTYPE DHT11 |
|
#define DHTPIN 2 |
|
|
|
DHT dht(DHTPIN, DHTTYPE); |
|
|
|
float humidity; |
|
float tempC; |
|
float tempF; |
|
|
|
int setTime = 500; |
|
|
|
|
|
void setup() { |
|
// put your setup code here, to run once: |
|
Serial.begin(9600); |
|
Serial.println("DHT11 test!"); |
|
|
|
dht.begin(); |
|
delay(setTime); |
|
|
|
|
|
} |
|
|
|
void loop() { |
|
// put your main code here, to run repeatedly: |
|
humidity = dht.readHumidity(); |
|
tempC = dht.readTemperature(); |
|
tempF = dht.readTemperature(true); |
|
|
|
Serial.print("Humidity: "); |
|
Serial.print(humidity); |
|
Serial.print(" Temperature: "); |
|
Serial.print(tempC); |
|
Serial.print(" *C "); |
|
Serial.print(tempF); |
|
Serial.println(" *F"); |
|
|
|
delay(setTime * 2); |
|
|
|
}
|
|
|