#include <DHT.h>// include adafruit library unified sensor
#define DHTPIN A0 // Set DHT pin:
#define DHTTYPE DHT22 // Set DHT type, DHT 22
DHT dht = DHT(DHTPIN, DHTTYPE);// Initialize DHT sensor for normal 16mhz Arduino:
void setup() {
Serial.begin(9600); // Begin serial communication at a band rate of 9600:
dht.begin(); // Setup sensor:
}
void loop() {
delay(2000); // Wait a few seconds between measurements:
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old'
float h = dht.readHumidity();// Read the humidity in %:
float t = dht.readTemperature(); // Read the temperature as Celsius:
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" % ");
Serial.print("\nTemperature: ");
Serial.print(t);
Serial.print(" \xC2\xB0");
Serial.println("C | ");
}
#include <DHT.h>
# define pin A0
# define type DHT22