SHT20 Temperature and Humidity Sensor
The SHT20, developed by Swiss company Sensirion, is a digital temperature and humidity sensor based on the world-leading CMOSens® digital sensing technology. It offers exceptional reliability and long-term stability. The sensor is factory-calibrated across the full range and features a two-wire digital interface, allowing direct connection to microcontrollers. This significantly shortens development time, simplifies peripheral circuitry, and reduces costs. Additionally, its compact size, fast response, low energy consumption, immersibility, strong anti-interference ability, integrated temperature and humidity measurement, and the ability to measure dew point make it highly suitable for various applications with excellent cost-performance.
Module Source
Purchase Link: https://item.taobao.com/item.htm?spm=a21n57.1.0.0.700a523chCfvAP&id=615550651141&ns=1&abbucket=0
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1HrQkwECvGgQSHvt_RNdLdA
Specifications
Operating Voltage:2.1~3.6V
Operating Current:0.1~1000uA
Temperature Accuracy:±0.3℃
Temperature Range:-40~125℃
Humidity Range: 0~100 %RH
Humidity Accuracy:±3%RH
Output Method: IIC
Pin Count:4 Pin4
Hardware Connection
Wiring SHT20 Sensor to the Development Board via I2C Communication Interface:
- VCC: Connect to the 3.3V output of the development board.
- GND: Connect to the GND pin of the development board.
- SDA: Connect to the A4 pin of the development board (SDA pin).
- SCL: Connect to the A5 pin of the development board (SCL pin).
Usage Method
Install Library
- Open the Arduino IDE.
- Go to the menu bar and click on “Tools” > “Manage Libraries…”.
- In the search box, enter "SHT20".
- Find and install the SHT20 library, such as the “DFRobot_SHT20” library.
Enter the code:
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 10, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include <Wire.h>
#include "DFRobot_SHT20.h"
DFRobot_SHT20 sht20;
void setup(){
Serial.begin(9600);
sht20.initSHT20(); // 初始化SHT20传感器
delay(100);
}
void loop(){
sht20.checkSHT20(); // 检查SHT20传感器
Serial.print("Temperature in Celsius: ");
Serial.print(sht20.readTemperature());
Serial.println(" C");
Serial.print("Humidity in %: ");
Serial.print(sht20.readHumidity());
Serial.println(" %");
delay(1000); // 等待1秒
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35