Hardware Reference
In-Depth Information
float light = sensor_reading/1024*100;
// Display temperature
Serial.print("Temperature: ");
Serial.print((int)temperature);
Serial.println(" C");
// Display humidity
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.println("%");
// Display light level
Serial.print("Light: ");
Serial.print(light);
Serial.println("%");
Serial.println("");
// Wait 500 ms
delay(500);
}
Let's now see the details. It starts by importing the library for the DHT sensor:
#include "DHT.h"
And create a DHT instance:
DHT dht (DHTPIN, DHTTYPE);
In the setup() function of the sketch, we have to initialize the sensor:
dht.begin();
And the Serial port:
Serial.begin( 9600 );
Search WWH ::




Custom Search