Mike's Arduino Post

Thread Starter

dr micron

Joined Jul 18, 2012
4
//Written by: Mike Robakidze 12/12/2010

/* this is the code which you can use to connect DHT 11 sensor and 16X2 LCD
to arduino and show TEMPERATURE AND HUMIDITY read from the DHT sensor on the LCD screen*/

#include "DHT.h" // this is sensor library file
#include <LiquidCrystal.h> // this is LCD library file
#define DHTPIN 7 // define what pin you're going to connect DHT
#define DHTTYPE DHT11 /* define DHT sensor type. this is requirement
from the DHT library file, so my dht sensor
is DHT11 */
// Connect pin 2 of the sensor to whatever your DHTPIN is
/* Connect a 10K resistor from pin 2 (data) to pin 1 (power)
of the sensor*/

/* The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
LiquidCrystal ekrani(12, 11, 5, 4, 3, 2);
DHT dht(DHTPIN, DHTTYPE); // shablonuri texti/ command

void setup()
{
dht.begin();
ekrani.begin(16, 2); // set up the LCD's number of columns and rows:
}

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)
int h = dht.readHumidity();
int t = dht.readTemperature();

// check if returns are valid, if they are NaN (not a number) then something went wrong!

if (isnan(t) || isnan(h))
{
ekrani.print("Failed ekrani ");
}

else
{

ekrani.print("Hum:");
ekrani.print(h);


ekrani.print("temp:");
ekrani.print(t);

delay ( 3000 );
ekrani.clear ();

}

if (t>=23)
{
ekrani.print ( "MAGALI TEMP");
}

delay (3000 );
ekrani.clear ();

}
 
Top