0% found this document useful (0 votes)
18 views

Temperature and Humidity Sensor Lesson

The document discusses a temperature and humidity sensor and how to use it with an Arduino. The sensor measures ambient temperature and relative humidity and outputs these as electrical signals. Arduino code is provided to read data from the sensor and check for errors.

Uploaded by

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

Temperature and Humidity Sensor Lesson

The document discusses a temperature and humidity sensor and how to use it with an Arduino. The sensor measures ambient temperature and relative humidity and outputs these as electrical signals. Arduino code is provided to read data from the sensor and check for errors.

Uploaded by

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

Arduino Temperature

and Humidity Sensor


Lesson
https://arduinogetstarted.com/tutorials/arduino-temperatur
e-humidity-sensor
What is A temperature and
humidity sensor, also
known as a humidity and
temperature temperature sensor, is a
type of sensor that
measures both the
and humidity ambient temperature
and relative humidity in

sensor
the surrounding
environment.
These sensors are designed

What is to provide accurate and


reliable readings of
temperature and humidity,

temperature making them valuable for a


wide range of applications,
including weather

and humidity monitoring, indoor climate


control systems,
agricultural and

sensor greenhouse management,


HVAC systems, and many
more.
HVAC stands for Heating,
Ventilation, and Air
Conditioning. It refers to
the technology, systems,

What and processes used to


control the indoor
environment of buildings
HVAC? to ensure comfort, air
quality, and thermal
regulation. HVAC systems
are commonly found in
residential, commercial,
and industrial buildings.
The temperature sensing
component of the sensor

What is detects the ambient


temperature using
various techniques, such

Temperature as a thermistor or an
integrated temperature
sensor. It converts the

Sensing? temperature into an


electrical signal that can
be processed and
measured by the sensor.
The humidity sensing

What is
component measures the
relative humidity (RH) in the
air. This is typically done
using a capacitive humidity

Humidity sensor or a resistive humidity


sensor. These sensors change
their electrical properties

Sensing? based on the moisture


content in the air, allowing
them to estimate the relative
humidity.
There are various humidity
and temperature sensor

Integrated
modules available that
combine the temperature
and humidity sensing
components into a single

sensor package. These modules


often have built-in signal
conditioning circuitry,

modules calibration data, and


communication protocols to
simplify their integration
with microcontrollers or
other devices.
Common humidity and temperature sensor types include the
DHT11, DHT22 (or AM2302), BME280, SHT series, and
HDC1080, among others. These sensors may have different
measurement ranges, accuracies, response times, and
communication interfaces, so it's important to choose the
sensor that best fits your specific requirements.
When using an Arduino or
similar microcontroller, there
are libraries and example
codes available to interface
with these sensors, making it
relatively straightforward to
read and process
temperature and humidity
data from them.
#include "DHT.h" // include DHT
libraries

#define DHTPIN 2 // define the


arduino pin connection to DHT

#define DHTTYPE DHT11 // define


SKETCH

the sensor type

DHT dht(DHTPIN, DHTTYPE); //


declare DHT object
void setup() {

Serial.begin(9600);

dht.begin(); // initialize the sensor

}
void loop() {
// wait a few seconds between
measurements.
delay(2000);
// read humidity
float humi = dht.readHumidity(); //
read temperature as Celsius
float tempC = dht.readTemperature();
// read temperature as
Fahrenheit
float tempF =
dht.readTemperature(true); //
check if any reads failed
if (isnan(humi) || isnan(tempC) ||
isnan(tempF)) {
Serial.println("Failed to read from
DHT sensor!");
The line if (isnan(humi) || isnan(tempC) ||
isnan(tempF)) in Arduino is a conditional statement
that checks if any of the variables humi, tempC, or
tempF contains the value NaN (Not a Number).
what is if
(isnan(humi) || In Arduino programming, the function isnan() is used
to check if a floating-point value is NaN. NaN is a
isnan(tempC) || special value that represents the result of an invalid
or undefined mathematical operation, such as the
isnan(tempF)) square root of a negative number.

in arduino The logical OR operator || is used to combine


multiple conditions. In this case, the if statement
evaluates to true if any of the conditions is true. So, if
any of the variables humi, tempC, or tempF is NaN,
the code inside the if statement will be executed.
} else {
Serial.print("Humidity: ");
Serial.print(humi);
Serial.print("%");
Serial.print(" | ");
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.print("°C ~ ");
Serial.print(tempF);
Serial.println("°F");
}
}
"Exploring the world of electronics is like
deciphering nature's secrets. Just as a keen
observer decodes the language of
temperature and humidity, an Arduino
paired with sensors becomes our interpreter,
revealing the poetry written by the
environment. In this lesson, we connect with
the elements, translating their whispers into
data, and embark on a journey where every
degree and percent is a verse, telling a story
of the atmospheric dance. Welcome to the
symphony of Arduino and the Temperature
and Humidity Sensor – where curiosity
meets code, and science becomes art."

You might also like