SlideShare a Scribd company logo
1 of 14
DHT11 & DHT22
Ability Enhance Course: Internet of Things (IoT)
17 January 2023
DHT11 & DHT22
• The DHT11 and DHT22 sensors are used to measure
temperature and relative humidity.
DHT11 & DHT22
• These sensors
contain a chip that
does analog to digital
conversion and spit
out a digital signal
with the temperature
and humidity.
DHT Pinout
Exercise:
• Obtain the Temperature and Relative Humidity Readings of the Room
on the serial monitor using a DHT11 Sensor along with ESP32 and
Arduino IDE.
Libraries:
• To read from the DHT sensor, we’ll use the DHT library from
Adafruit.
• To use this library, you also need to install the Adafruit Unified
Sensor library.
• Follow the next steps to install those libraries.
Libraries:
• Open your Arduino IDE and go to Sketch > Include
Library > Manage Libraries. The Library Manager should
open.
• Search for “DHT” on the Search box and install the DHT library
from Adafruit.
• After installing the DHT library from Adafruit, type “Adafruit
Unified Sensor” in the search box. Scroll all the way down to
find the library and install it.
• After installing the libraries, restart your Arduino IDE.
Circuit
Code
#include "DHT.h"
#define DHTPIN 4 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
}
Code
void loop() {
// Wait a few seconds between measurements.
delay(1000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
Code
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Code
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F("°F"));
}

More Related Content

What's hot

VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESkarthik kadava
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adcPRADEEP
 
Interfacing bluetooth with arduino
Interfacing bluetooth with arduinoInterfacing bluetooth with arduino
Interfacing bluetooth with arduinoJairaj Jangle
 
8051 Timers / Counters
8051 Timers / Counters8051 Timers / Counters
8051 Timers / CountersPatricio Lima
 
Sensors and actuators
Sensors and actuatorsSensors and actuators
Sensors and actuatorsnazibhmd
 
Introduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and ProgrammingIntroduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and ProgrammingEmmanuel Obot
 
Esp8266 NodeMCU
Esp8266 NodeMCUEsp8266 NodeMCU
Esp8266 NodeMCUroadster43
 
Sensors and microcontroller interfacing
Sensors and microcontroller interfacingSensors and microcontroller interfacing
Sensors and microcontroller interfacingmohamed albanna
 
Door lock-using-rfid-technology
Door lock-using-rfid-technology Door lock-using-rfid-technology
Door lock-using-rfid-technology Ho Vu
 
Rf bases door lock system
Rf bases door lock systemRf bases door lock system
Rf bases door lock systemSikander Bodh
 
Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]Alwin Arrasyid
 
Project ideas ece students
Project ideas ece studentsProject ideas ece students
Project ideas ece studentsVatsal N Shah
 
Coin based mobile charger project report
Coin based mobile charger project reportCoin based mobile charger project report
Coin based mobile charger project reportkaushal chaubey
 
Interfacing methods of microcontroller
Interfacing methods of microcontrollerInterfacing methods of microcontroller
Interfacing methods of microcontrollerDiwaker Pant
 
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino unoRahat Sood
 

What's hot (20)

VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLES
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adc
 
Interfacing bluetooth with arduino
Interfacing bluetooth with arduinoInterfacing bluetooth with arduino
Interfacing bluetooth with arduino
 
8051 Timers / Counters
8051 Timers / Counters8051 Timers / Counters
8051 Timers / Counters
 
Sensors and actuators
Sensors and actuatorsSensors and actuators
Sensors and actuators
 
Introduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and ProgrammingIntroduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and Programming
 
Esp8266 NodeMCU
Esp8266 NodeMCUEsp8266 NodeMCU
Esp8266 NodeMCU
 
Sensors and microcontroller interfacing
Sensors and microcontroller interfacingSensors and microcontroller interfacing
Sensors and microcontroller interfacing
 
Voice controlled home appliances
Voice controlled home appliancesVoice controlled home appliances
Voice controlled home appliances
 
Door lock-using-rfid-technology
Door lock-using-rfid-technology Door lock-using-rfid-technology
Door lock-using-rfid-technology
 
Rf bases door lock system
Rf bases door lock systemRf bases door lock system
Rf bases door lock system
 
Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]
 
Project ideas ece students
Project ideas ece studentsProject ideas ece students
Project ideas ece students
 
8051 block diagram
8051 block diagram8051 block diagram
8051 block diagram
 
Light sensors seminar
Light sensors seminarLight sensors seminar
Light sensors seminar
 
Coin based mobile charger project report
Coin based mobile charger project reportCoin based mobile charger project report
Coin based mobile charger project report
 
Embedded Systems and IoT
Embedded Systems and IoTEmbedded Systems and IoT
Embedded Systems and IoT
 
PPT ON Arduino
PPT ON Arduino PPT ON Arduino
PPT ON Arduino
 
Interfacing methods of microcontroller
Interfacing methods of microcontrollerInterfacing methods of microcontroller
Interfacing methods of microcontroller
 
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino uno
 

Similar to DHT11 & DHT22.pptx

IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019Jong-Hyun Kim
 
ESP32 WiFi & Bluetooth Module - Getting Started Guide
ESP32 WiFi & Bluetooth Module - Getting Started GuideESP32 WiFi & Bluetooth Module - Getting Started Guide
ESP32 WiFi & Bluetooth Module - Getting Started Guidehandson28
 
Cassiopeia ltd Arduino follow-up workshop 2018
Cassiopeia ltd   Arduino follow-up workshop 2018Cassiopeia ltd   Arduino follow-up workshop 2018
Cassiopeia ltd Arduino follow-up workshop 2018tomtobback
 
Sensors and Journalism Seminar, University of British Columbia - Day 1
Sensors and Journalism Seminar, University of British Columbia - Day 1Sensors and Journalism Seminar, University of British Columbia - Day 1
Sensors and Journalism Seminar, University of British Columbia - Day 1ferguspitt
 
RAHUL NASKAR IOT.ppt
RAHUL NASKAR IOT.pptRAHUL NASKAR IOT.ppt
RAHUL NASKAR IOT.pptPrakasBhowmik
 
DeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonDeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonGabriel Arnautu
 
Sensors and Journalism Seminar, University of British Columbia - Day 1
Sensors and Journalism Seminar, University of British Columbia - Day 1Sensors and Journalism Seminar, University of British Columbia - Day 1
Sensors and Journalism Seminar, University of British Columbia - Day 1ferguspitt
 
Robotics lab module 3 ppt 4
Robotics lab module 3 ppt 4Robotics lab module 3 ppt 4
Robotics lab module 3 ppt 4premkumar1891
 
All about ir arduino - cool
All about ir   arduino - coolAll about ir   arduino - cool
All about ir arduino - coolVlada Stoja
 
Arduino Teaching Program
Arduino Teaching ProgramArduino Teaching Program
Arduino Teaching ProgramMax Kleiner
 
maXbox starter30 Web of Things
maXbox starter30 Web of ThingsmaXbox starter30 Web of Things
maXbox starter30 Web of ThingsMax Kleiner
 
Programming Addressable LED Strips
Programming Addressable LED StripsProgramming Addressable LED Strips
Programming Addressable LED Stripsatuline
 
Adafruit Huzzah Esp8266 WiFi Board
Adafruit Huzzah Esp8266 WiFi BoardAdafruit Huzzah Esp8266 WiFi Board
Adafruit Huzzah Esp8266 WiFi BoardBiagio Botticelli
 
XBee and RFID
XBee and RFIDXBee and RFID
XBee and RFIDTinker
 
INTERNSHIP [Autosaved].pptx
INTERNSHIP [Autosaved].pptxINTERNSHIP [Autosaved].pptx
INTERNSHIP [Autosaved].pptxSanjanaN25
 

Similar to DHT11 & DHT22.pptx (20)

Es project sensor
Es project sensorEs project sensor
Es project sensor
 
IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019
 
ESP32 WiFi & Bluetooth Module - Getting Started Guide
ESP32 WiFi & Bluetooth Module - Getting Started GuideESP32 WiFi & Bluetooth Module - Getting Started Guide
ESP32 WiFi & Bluetooth Module - Getting Started Guide
 
Cassiopeia ltd Arduino follow-up workshop 2018
Cassiopeia ltd   Arduino follow-up workshop 2018Cassiopeia ltd   Arduino follow-up workshop 2018
Cassiopeia ltd Arduino follow-up workshop 2018
 
Sensors and Journalism Seminar, University of British Columbia - Day 1
Sensors and Journalism Seminar, University of British Columbia - Day 1Sensors and Journalism Seminar, University of British Columbia - Day 1
Sensors and Journalism Seminar, University of British Columbia - Day 1
 
RAHUL NASKAR IOT.ppt
RAHUL NASKAR IOT.pptRAHUL NASKAR IOT.ppt
RAHUL NASKAR IOT.ppt
 
DeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonDeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel Edison
 
Sensors and Journalism Seminar, University of British Columbia - Day 1
Sensors and Journalism Seminar, University of British Columbia - Day 1Sensors and Journalism Seminar, University of British Columbia - Day 1
Sensors and Journalism Seminar, University of British Columbia - Day 1
 
Robotics lab module 3 ppt 4
Robotics lab module 3 ppt 4Robotics lab module 3 ppt 4
Robotics lab module 3 ppt 4
 
All about ir arduino - cool
All about ir   arduino - coolAll about ir   arduino - cool
All about ir arduino - cool
 
Arduino Teaching Program
Arduino Teaching ProgramArduino Teaching Program
Arduino Teaching Program
 
maXbox starter30 Web of Things
maXbox starter30 Web of ThingsmaXbox starter30 Web of Things
maXbox starter30 Web of Things
 
IOT beginnners
IOT beginnnersIOT beginnners
IOT beginnners
 
IOT beginnners
IOT beginnnersIOT beginnners
IOT beginnners
 
Programming Addressable LED Strips
Programming Addressable LED StripsProgramming Addressable LED Strips
Programming Addressable LED Strips
 
Adafruit Huzzah Esp8266 WiFi Board
Adafruit Huzzah Esp8266 WiFi BoardAdafruit Huzzah Esp8266 WiFi Board
Adafruit Huzzah Esp8266 WiFi Board
 
Audible Objects
Audible ObjectsAudible Objects
Audible Objects
 
XBee and RFID
XBee and RFIDXBee and RFID
XBee and RFID
 
XBee and RFID
XBee and RFIDXBee and RFID
XBee and RFID
 
INTERNSHIP [Autosaved].pptx
INTERNSHIP [Autosaved].pptxINTERNSHIP [Autosaved].pptx
INTERNSHIP [Autosaved].pptx
 

Recently uploaded

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 

Recently uploaded (20)

Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 

DHT11 & DHT22.pptx

  • 1. DHT11 & DHT22 Ability Enhance Course: Internet of Things (IoT) 17 January 2023
  • 2. DHT11 & DHT22 • The DHT11 and DHT22 sensors are used to measure temperature and relative humidity.
  • 3. DHT11 & DHT22 • These sensors contain a chip that does analog to digital conversion and spit out a digital signal with the temperature and humidity.
  • 5. Exercise: • Obtain the Temperature and Relative Humidity Readings of the Room on the serial monitor using a DHT11 Sensor along with ESP32 and Arduino IDE.
  • 6. Libraries: • To read from the DHT sensor, we’ll use the DHT library from Adafruit. • To use this library, you also need to install the Adafruit Unified Sensor library. • Follow the next steps to install those libraries.
  • 7. Libraries: • Open your Arduino IDE and go to Sketch > Include Library > Manage Libraries. The Library Manager should open. • Search for “DHT” on the Search box and install the DHT library from Adafruit. • After installing the DHT library from Adafruit, type “Adafruit Unified Sensor” in the search box. Scroll all the way down to find the library and install it. • After installing the libraries, restart your Arduino IDE.
  • 8.
  • 9.
  • 11. Code #include "DHT.h" #define DHTPIN 4 // Digital pin connected to the DHT sensor #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); Serial.println(F("DHTxx test!")); dht.begin(); }
  • 12. Code void loop() { // Wait a few seconds between measurements. delay(1000); // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true) float f = dht.readTemperature(true);
  • 13. Code // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println(F("Failed to read from DHT sensor!")); return; } // Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false);
  • 14. Code Serial.print(F("Humidity: ")); Serial.print(h); Serial.print(F("% Temperature: ")); Serial.print(t); Serial.print(F("°C ")); Serial.print(f); Serial.print(F("°F Heat index: ")); Serial.print(hic); Serial.print(F("°C ")); Serial.print(hif); Serial.println(F("°F")); }