Home Code SHT20 temperature sensor and Arduino example

SHT20 temperature sensor and Arduino example

by shedboy71
[lebox id="1"]

In this example we will connect a SHT20 temperature sensor to an Arduino Uno. Lets look at some information about the 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

 

Amount Part Type
1 Temperature and humidity detection sensor module SHT20
1 UNO R3 CH340G/ATmega328P, compatible for Arduino UNO R3

 

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

[codesyntax lang=”cpp”]

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

[/codesyntax]

 

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
Time:203 Temperature:25.3C Humidity:48.6%
Time:1306 Temperature:25.2C Humidity:48.7%
Time:2410 Temperature:25.1C Humidity:48.9%
Time:3514 Temperature:25.1C Humidity:49.0%

Here is a video showing the code being compiled and the serial monitor being opened, I put my finger on the sensor to raise the temperature

 

Links

Sensirion_Humidity_Sensors_SHT20_Datasheet.pdf

 

Share
[lebox id="2"]

You may also like

Leave a Comment