SHT30 Temperature and Humidity Sensor
Module Source
Purchase Link: https://item.taobao.com/item.htm?spm=a1z09.2.0.0.204e2e8d2hPeAl&id=556043263770&_u=h2t4uge5cf4f
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1kisMJspcV6Qdr1ye9ElOlQ
Specifications
Operating Voltage: 2.4-5.5V
Operating Current: 0.21500uA
Temperature Measurement Range: -40125°C
Temperature Measurement Accuracy: ±0.3°C
Humidity Measurement Range: 0~100%RH
Humidity Measurement Accuracy: ±2%RH
Output Method: IIC
Pin Count: 4 Pin
Hardware Connection
- VCC: Connect to the 5V of the development board.
- GND: Connect to the GND of the development board.
- SCL (Clock Line): Connect to A5 (SCL) on the development board.
- SDA (Data Line): Connect to A4 (SDA) on the development board.
Usage Method
Install Library
To easily read data from the SHT30, we can use the existing Arduino library, the Adafruit_SHT31
library. First, install this library. You can do so via the Arduino IDE's Library Manager: open the Arduino IDE, go to Tools -> Manage Libraries, then search for SHT31 and install the Adafruit SHT31
library.
Enter the code:
#include <Wire.h>
#include <Adafruit_SHT31.h>
Adafruit_SHT31 sht31 = Adafruit_SHT31();
void setup() {
Serial.begin(9600);
if (!sht31.begin(0x44)) { // 使用SHT30的默认I2C地址(请根据你的传感器检查地址是否匹配)
Serial.println("Couldn't find SHT30");
while (1) delay(1);
}
}
void loop() {
float temp = sht31.readTemperature();
float hum = sht31.readHumidity();
if (!isnan(temp)) { // 检查读数是否有效
Serial.print("Temp *C = "); Serial.println(temp);
} else {
Serial.println("Failed to read temperature");
}
if (!isnan(hum)) { // 检查湿度读数是否有效
Serial.print("Hum. % = "); Serial.println(hum);
} else {
Serial.println("Failed to read humidity");
}
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