Home » ESP32 and SHT20 temperature sensor example

ESP32 and SHT20 temperature sensor example

by shedboy71

In this example we will connect a SHT20 temperature sensor to an ESP32.

Lets look at the SHT20 sensor

The SHT20 humidity and temperature sensor of Sensirion has become an industry standard in terms of form factor and intelligence: Embedded in a reflow solderable Dual Flat No leads (DFN) package of 3 x 3mm foot print and 1.1mm height it provides calibrated, linearized sensor signals in digital, I2C format.

The SHT2x sensors contain a capacitive type humidity sensor, a band gap temperature sensor and specialized analog and digital integrated circuit – all on a single CMOSens® chip. This yields in an unmatched sensor performance in terms of accuracy and stability as well as minimal power consumption.

Every sensor is individually calibrated and tested. Lot identification is printed on the sensor and an electronic identification code is stored on the chip – which can be read out by command. Furthermore, the resolution of SHT2 can be changed by command (8/12bit up to 12/14bit for RH/T) and a checksum helps to improve communication reliability.

 

Parts List

Name Link
ESP32
SHT20
Connecting cables

 

Schematics

Couldn't find a good part for fritzing

Its an I2C device that needs 3.3v and GND, so its not that difficult to wire

 

Code

There is a library to make things easy and it is – https://github.com/DFRobot/DFRobot_SHT20

#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(" Humidity:");
Serial.print(humd, 1);
Serial.print("%");
Serial.println();
delay(1000);
}

 

Output

Open the serial monitor and you should see something similar to this

SHT20 Example!
End of battery: no
Heater enabled: no
Disable OTP reload: yes
Temperature:24.1C Humidity:50.6%
Temperature:24.0C Humidity:50.6%
Temperature:24.0C Humidity:50.6%
Temperature:24.0C Humidity:50.6%
Temperature:25.8C Humidity:51.1%
Temperature:27.5C Humidity:55.8%
Temperature:28.2C Humidity:60.2%

 

Links

Sensirion_Humidity_Sensors_SHT20_Datasheet.pdf

 

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.