Toggle Nav

Interfacing SHT20 Temperature and Humidity Sensor with Arduino

Table of Contents

SHT20 Temperature and Humidity Sensor Features

The SHT20 temperature and humidity module is high-precious, full calibrated, with very low power consumption and high response speed. This sensor is a combination of a capacitive humidity sensor and a silicon band gap temperature sensor. The key features are:

  • Temperature measurement range: -40 to +125 °C
  • Temperature measurement accuracy: 0.3 °C
  • Humidity measurement range: 0 to 100%
  • Humidity measurement accuracy: 3% RH
  • Communication Protocol: I2C

SHT20 Temperature and Humidity Sensor Pinout

This module has 4 pins:

  • VCC: Module power supply – 2.1-3.6 V
  • GND: Ground
  • SDA: Serial Data Input/Output for I2C protocol
  • SCL: Serial Clock Input for I2C protocol

You can see the pinout of this module here.

Required Materials

Hardware Components

Arduino UNO R3 × 1
SHT20 Temperature and Humidity Sensor × 1
Male to Female jumper wire × 1

Software Apps

Arduino IDE

Interfacing SHT20 Temperature and Humidity Sensor with Arduino

Step 1: Circuit

The following circuit shows how you should connect your Arduino Board to the SHT20 module. Connect wires accordingly.

Step 2: Library

Download the DFRobot_SHT20-master library here.

Then go to Include Library and install the library.

Tip

If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Step 3: Code

Upload the following code to the Arduino. Then open the Serial Monitor.

/*
modified on Apr 10, 2021
Modified by MehranMaleki from Arduino Examples
https://electropeak.com/learn/
*/

#include <Wire.h>
#include "DFRobot_SHT20.h"

DFRobot_SHT20 sht20;

void setup()
{
    Serial.begin(9600);
    Serial.println("SHT20 Example!");
    sht20.initSHT20();                         // Init SHT20 Sensor
    delay(100);
    sht20.checkSHT20();                        // Check SHT20 Sensor
}

void loop()
{
    float humd = sht20.readHumidity();         // Read Humidity
    float temp = sht20.readTemperature();      // Read Temperature
    Serial.print(" Temperature: ");
    Serial.print(temp, 1);
    Serial.print("C");
    Serial.print("\t Humidity: ");
    Serial.print(humd, 1);
    Serial.println("%");
    delay(1000);
}

In the above code, at first, the relevant library is included and the sensor starts working. Then, every second, we take the temperature and humidity data from the sensor and display it on the Serial Monitor.

Liked What you see?

Get updates and learn from the best

More To Explore

Leave a Reply

Your email address will not be published. Required fields are marked *