micro:bit and SHT21 humidity and temperature sensor example

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 sensors are available both in large and small volumes.This is the breakout for the sensor that I bought.

The SHT2x humidity sensor series contains a capacitive-type humidity sensor, a band-gap temperature sensor, and specialized analog and digital integrated circuits – all on a single CMOSens® chip. This yields superior sensor performance in terms of accuracy and stability as well as minimal power consumption.

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

 

Schematic

 

microbit and sht21
microbit and sht21

 

 

Code

 

I used the following library – https://github.com/markbeee/SHT21

[codesyntax lang=”cpp”]

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

SHT21 SHT21;

void setup()
{
 SHT21.begin();
 Serial.begin(9600);
}

void loop()
{
 Serial.print("Humidity(%RH): ");
 Serial.print(SHT21.getHumidity());
 Serial.print(" Temperature(C): ");
 Serial.println(SHT21.getTemperature());
 
 delay(1000);
}

[/codesyntax]

 

Output

 

Humidity(%RH): 39.43 Temperature(C): 20.85
Humidity(%RH): 39.49 Temperature(C): 20.83
Humidity(%RH): 39.77 Temperature(C): 22.19
Humidity(%RH): 40.14 Temperature(C): 23.34
Humidity(%RH): 40.51 Temperature(C): 24.21
Humidity(%RH): 40.78 Temperature(C): 24.26
Humidity(%RH): 40.87 Temperature(C): 24.09
Humidity(%RH): 40.90 Temperature(C): 23.91

 

Links

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

New SHT21 Digital Humidity And Temperature Sensor Module Replace

Leave a Comment

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :