I am using an arduino uno bought in a kit with a LCD/button shield and a DHT11, both parts bougth from dealextreme, although also available from a lot of other places.
The DHT11 is connected to the arduino:
* pin 1 (signal) – digital 2
* pin 2 (Vcc) – 5v
* pin 3 (gnd) – gnd
(The cables are taken from a discarded PC cabinet)
Then the display is put on top and the sketch is downloaded:
sketch:
#include "DHT.h"
#include <liquidcrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#define DHTPIN 2 // what pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);
void setup() {
lcd.begin(16,2);
dht.begin();
}
void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
lcd.setCursor(5,1);
lcd.println("Failed to read from DHT");
} else {
lcd.setCursor(5,1);
lcd.print(h);
lcd.print(" %");
lcd.setCursor(5,0);
lcd.print(t);
lcd.print(" *C");
}
}
The LiquidCrystal library should come with the arduino ide, the DHT library can be downloaded from http://playground.arduino.cc/Main/DHTLib.
Pingback: Arduino and BMP085 | Mortens meninger