Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
WouterW007
Portable-Arduino-Temp-Humidity-Sensor-with-LCD-
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
Portable-Arduino-Temp-Humidity-Sensor-with-LCD-
/
Temp_Humidity_Display_LCD.cpp
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
52 lines (46 loc) · 1.58 KB
main
Breadcrumbs
Portable-Arduino-Temp-Humidity-Sensor-with-LCD-
/
Temp_Humidity_Display_LCD.cpp
Copy path
Top
File metadata and controls
Code
Blame
52 lines (46 loc) · 1.58 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <DFRobot_DHT11.h>
#include <Adafruit_MotorShield.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x20, 16, 2); // Set LCD’s address to be 0x20. Let it display 2 lines with 16 characters per line
dht11 DHT;
#define DHT11_PIN 4
void setup() {
lcd.begin();
lcd.backlight(); // open LCD’s backlight
Serial.begin(9600); // Set serial port’s baud rate to be 9600
// serial port prints ”Type, status, Humidity(%), Temperature(C)”
Serial.println("Type,\tstatus,\tHumidity(%),\tTemperature(C)");
lcd.print("Humidity(%):"); //LCD screen prints ”Humidity(%):”
lcd.setCursor(0, 1); //cursor to be moved to the first character in the 2nd line
lcd.print("Temp(C):"); //LCD screen prints”Temp(C):”
}
void loop() {
int chk; //for storage of data collected by DHT11 sensor
Serial.print("DHT11, \t"); // read data collected by DHT11 sensor
chk = DHT.read(DHT11_PIN);
switch (chk) {
case DHTLIB_OK:
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error, \t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error, \t");
break;
default:
Serial.print("Unknown error, \t");
break;
}
// serial port shows temperature and humidity
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.println(DHT.temperature, 1);
//LCD screen prints temperature and humidity
lcd.setCursor(12, 0);
lcd.print(DHT.humidity, 1);
lcd.setCursor(8, 1);
lcd.print(DHT.temperature, 1);
delay(1000);
}
You can’t perform that action at this time.