Gravity: DHT20 I2C Temperature and Humidity Sensor Wiki - DFRobot



The DHT20 temperature & humidity sensor is the newly upgraded version of the DHT11. The DHT20 features a brand-new ASIC dedicated chip, an improved MEMS semiconductor capacitive humidity sensor element and a standard on-chip temperature element. All sensors are factory calibrated and characterized by low power, high precision & stability, fast response, and strong anti-interference. Moreover, the DHT20 performance parameters of accuracy, power supply voltage, measurement range and response time have been enhanced greatly over the previous generation, making it more cost-effective. Besides that, the DHT20 temperature & humidity sensor employs I2C digital output protocol, which is very suitable for HVAC, automobiles, data loggers, weather stations, home appliances, and other related temperature and humidity detection and controlled areas.



Board Overview

Num Label Description
1 D I2C data line SDA
2 C I2C clock line SCL
3 - GND power negative
4 + Power positive

Tutorial for Arduino

Download the program to UNO, open the serial monitor to check temperature and humidity.


Read Sensor Data

Connection Diagram

Sample Code

 *@file getData.ino
 *@brief Read ambient temperature and relative humidity and print them to serial port.
 *@copyright   Copyright (c) 2010 DFRobot Co.Ltd (
 *@licence     The MIT License (MIT)
 *@author [fengli](
 *@version  V1.0
 *@date  2021-6-24
 *@get from

#include <DFRobot_DHT20.h>
 * @brief Construct the function
 * @param pWire IC bus pointer object and construction device, can both pass or not pass parameters, Wire in default.
 * @param address Chip IIC address, 0x38 in default.
DFRobot_DHT20 dht20;
void setup(){

  //Initialize sensor
    Serial.println("Initialize sensor failed");

void loop(){
  //Get ambient temperature
  Serial.print("temperature:"); Serial.print(dht20.getTemperature());Serial.print("C");
  //Get relative humidity
  Serial.print("  humidity:"); Serial.print(dht20.getHumidity()*100);Serial.println(" %RH");



Expected Results

Open the serial monitor and set the baud rate to 115000, then you can see the temperature and humidity data.


Q1: After uploading the code, there is no data output or the output value is obviously wrong?
A: Caused by power fluctuations,first connect the sensor to the controller, and then supply power to the entire system to solve the problem

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping_car1.png Get Gravity: I2C DHT20 Temperature and Humidity Sensor from DFRobot Store or DFRobot Distributor.