Categories

Follow Us

SHT21 humidity and temperature sensor example

The SHT21 is a low cost humidity and temperature sensor. Its an I2C device so again is very simple to connect to any arduino

The digital SHT2x humidity sensor series is used in high volumes in a wide variety of applications and has today become the de facto industry standard. The SHT2x series consists of a low-cost version with the SHT20 humidity sensor, a standard version with the SHT21 humidity sensor, and a high-end version with the SHT25 humidity sensor. The open cavity mold package – which encapsulates the complete chip except for the humidity sensor area – protects the capacitive humidity sensor against external impact and facilitates excellent long-term stability.

The SHT2x provides calibrated, linearized sensor signals in digital, I2C format. The SHT2x humidity sensor series contains a capacitive-type humidity sensor, a band-gap temperature sensor, and specialized analog and digital integrated circuits ,the resolution of the SHT2x humidity sensor can be changed on command (8/12 bit up to 12/14 bit for RH/T) and a checksum helps to improve communication reliability

This is the breakout for the sensor that I bought. This makes it easy to use the sensor and hook it up to an Arduino

SHT21

SHT21

Here is a simple schematic, again be careful as Vcc is 3.3v with this device

Schematic

Here is a schematic showing the connection, easy device to connect up

 

UNO and SHT21

UNO and SHT21

Lets look at the required libraries and a basic code example, there is not much to this to be honest most of the work is done in the library

Code

There are a couple of libraries to help you out

https://github.com/misenso/SHT2x-Arduino-Library
https://github.com/elechouse/SHT21_Arduino

I used the latter one

 

#include <Wire.h>
#include <SHT2x.h>
 
 
void setup()
{
  Wire.begin();
  Serial.begin(9600);
}
 
void loop()
{
  Serial.print("Humidity: ");
  Serial.println(SHT2x.GetHumidity());
  Serial.print("Temperature(C): ");
  Serial.println(SHT2x.GetTemperature());
  Serial.println();
  delay(1000);
}

 

When you open the serial monitor you should see the temperature and humidity displayed

 

Links

these come in at about $7 for a useful breakout board with this sensor

Humidity Sensor – SHT21 Breakout Board

Share

Comments are closed.