Thursday, 12 December 2013

LCD Temperature & Humidity

Next step, display the Temperature and Humidity on an LCD display. Like this:

2013 12 12 15 23 18

The circuit for this is:

2013 12 12 15 21 15

And the board layout is:

2013 12 12 15 23 04

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: