Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
24 views2 pages

Codigo 3.1.12

This document contains code to display temperature and humidity readings from a DHT sensor on an LCD screen. It includes libraries for the LCD screen and DHT sensor, defines the sensor pin and type, initializes the LCD screen, and has a loop to read the sensor values and display them on the LCD with units and error handling.

Uploaded by

Kro Montenegro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Codigo 3.1.12

This document contains code to display temperature and humidity readings from a DHT sensor on an LCD screen. It includes libraries for the LCD screen and DHT sensor, defines the sensor pin and type, initializes the LCD screen, and has a loop to read the sensor values and display them on the LCD with units and error handling.

Uploaded by

Kro Montenegro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// Include the libraries we need

#include <LiquidCrystal_PCF8574.h>
#include <DHT.h>

LiquidCrystal_PCF8574 lcd(8*27); // set the LCD address to 0*27 for a 16 chars and
2 line display

#define DHTPIN 23

// Uncomment whatever type you're using!


#define DHTTYPE DHT11 // DTH 11
//#define DHTTYPE DHT22 //DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 //DHT 21 (AM2302)

DHT dht(DHTPIN, DHTTYPE);

char grados = 223;

void setup() {
// put your setup code here, to run once:
dht.begin();

lcd.begin(20, 4); // inicialize the lcd


delay(200);
lcd.setBackligt(255);
lcd.print("Humedad:");
lcd.setCursor(0,1);
lcd.print("Temperatura:");
}

void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor reading may also be up to 2 seconds
float h = dht.readHumidity();
//Read temperature as Celsius (the default)
float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {
lcd.setCursor(13,0);
lcd.print("error!");
lcd.setCursor(13,1);
lcd.print("error!");
return;
}

lcd.setCursor(13,0);
lcd.print(h,0);
lcd.print("% ");
lcd.setCursor(13,1);
lcd.print(t,0);
lcd.print((char) grado);
lcd.print("C ");

delay(1000);

You might also like