|
|
|
@ -2,10 +2,47 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include <Arduino.h> |
|
|
|
#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() { |
|
|
|
void setup() { |
|
|
|
// put your setup code here, to run once:
|
|
|
|
// put your setup code here, to run once:
|
|
|
|
|
|
|
|
Serial.begin(9600); |
|
|
|
|
|
|
|
Serial.println("DHT11 test!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dht.begin(); |
|
|
|
|
|
|
|
delay(setTime); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void loop() { |
|
|
|
void loop() { |
|
|
|
// put your main code here, to run repeatedly:
|
|
|
|
// 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); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|