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

Arduino Temp & Humidity Sensor LCD

Uploaded by

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

Arduino Temp & Humidity Sensor LCD

Uploaded by

Hahaha
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Arduino Temperature and Humidity Sensor - LCD Lesson

[Link]

SKETCH

#include <LiquidCrystal_I2C.h>

#include "DHT.h"

#define DHTPIN 2

#define DHTTYPE DHT11

LiquidCrystal_I2C lcd(0x3F, 16, 2); // I2C address 0x3F, 16 column and 2 rows

DHT dht(DHTPIN, DHTTYPE);


void setup()

[Link](); // initialize the sensor

[Link](); // initialize the lcd

[Link](); // open the backlight

void loop()

delay(2000); // wait a few seconds between measurements

float humi = [Link](); // read humidity

float tempC = [Link](); // read temperature

[Link]();

// check if any reads failed

if (isnan(humi) || isnan(tempC)) {

[Link](0, 0);

[Link]("Failed");

} else {

[Link](0, 0); // start to print at the first row

[Link]("Temp: ");

[Link](tempC); // print the temperature

[Link]((char)223); // print ° character

[Link]("C");

[Link](0, 1); // start to print at the second row

[Link]("Humi: ");

[Link](humi); // print the humidity

[Link]("%");

You might also like