The circuit for this is:
And the board layout is:
The code has no error checking at this time::
#include "dht11.h"
#include "LiquidCrystal.h"
// LCD connections
#define RS 0
#define EN 1
#define D4 5
#define D5 4
#define D6 3
#define D7 2
// LCD mode
#define cols 16
#define rows 2
dht11 DHT11;
// sensor pin
#define DHT11PIN 12
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7);
void setup()
{
lcd.begin(cols, rows);
delay(2000);
}
void loop()
{
DHT11.read(DHT11PIN); // make a read to refresh the temp & humid
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Humid (%) ");
lcd.print((float)DHT11.humidity, 2); // humid 2 dec places
lcd.setCursor(0, 1);
lcd.print("Temp (C) ");
lcd.print((float)DHT11.temperature, 2); // temp 2 dec places
delay(2000);
}
No comments:
Post a Comment