/*
The circuit:
* LCD RS pin to digital pin 7
* LCD Enable pin to digital pin 8
* LCD D4 pin to digital pin 9
* LCD D5 pin to digital pin 10
* LCD D6 pin to digital pin 11
* LCD D7 pin to digital pin 12
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
// include the library code:
#include <LiquidCrystal.h>
#include <SimpleDHT.h>
int pinDHT11 = 2;
SimpleDHT11 dht11;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12 );
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
//lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
//lcd.print(millis() / 1000);
lcd.print("Sample DHT11...");
lcd.clear();
// read with raw sample data.
byte temperature = 0;
byte humidity = 0;
byte data[40] = {0};
if (dht11.read(pinDHT11, &temperature, &humidity, data)) {
lcd.print("Read DHT11 failed");
delay(1000);
lcd.clear();
return;
}
//lcd.print("Sample OK: ");
lcd.print("TEMP = "); lcd.print((int)temperature); lcd.print(" *C");
lcd.setCursor(0,2);
lcd.print("HUMD = "); lcd.print((int)humidity); lcd.print(" % ");
// DHT11 sampling rate is 1HZ.
delay(1000);
}
Comments