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

Arduino Temperature and 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)
24 views2 pages

Arduino Temperature and 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
You are on page 1/ 2

Arduino Temperature and Humidity Sensor - LCD Lesson

https://arduinogetstarted.com/tutorials/arduino-temperature-humidity-sensor-lcd

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()

dht.begin(); // initialize the sensor

lcd.init(); // initialize the lcd

lcd.backlight(); // open the backlight

void loop()

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

float humi = dht.readHumidity(); // read humidity

float tempC = dht.readTemperature(); // read temperature

lcd.clear();

// check if any reads failed

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

lcd.setCursor(0, 0);

lcd.print("Failed");

} else {

lcd.setCursor(0, 0); // start to print at the first row

lcd.print("Temp: ");

lcd.print(tempC); // print the temperature

lcd.print((char)223); // print ° character

lcd.print("C");

lcd.setCursor(0, 1); // start to print at the second row

lcd.print("Humi: ");

lcd.print(humi); // print the humidity

lcd.print("%");

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy