Blog
SHT30 Temperature And Humidity Sensor
Nowadays, sensors of all kinds are all around us. They can monitor various phenomena and conditions, including temperature and humidity. Such sensors are already common in offices and industrial buildings, but they are also becoming increasingly popular in home life and the automotive sector. In companies in the electronics industry, special areas called clean rooms are usually designated to monitor environmental conditions so that parameters of heating or ventilation systems can be adjusted in real time.
What is SHT30 Temperature And Humidity Sensor?
The SHT30 is a common temperature and humidity sensor, a fully calibrated and linearized digital sensor for temperature and humidity, with enhanced digital signals. The IIC communication frequency can reach 1 MHz. It features high reliability and stability. This sensor is widely used in various scenarios. The temperature and humidity sensor used by Xiaomi is the SHT30. This article uses hardware IIC to drive the SHT30.
The SHT30 adopts the advanced CMOSens® technology, which uses a capacitive humidity measurement method and is one of the industry standards. According to its principle, this sensor is a capacitor, with its dielectric material made of polymer, which can absorb or release moisture according to the relative humidity of the environment. Due to this process, the capacitance of the capacitor changes, and this change can be measured electrically, and the humidity level can be accurately determined accordingly. Although the structure of sensors based on CMOSens® technology is slightly complex, it is worth mentioning that CMOSens® is not only used in humidity and temperature sensors, but also in modules for detecting the presence and flow of gases and liquids.
Working Principle
· Schematic Diagram
· SHT30 MCU Connection
Rp is the IIC pull-up resistor. When only one device is connected on the IIC bus, the recommended resistance value is 10K. For other cases, it depends on the situation. This value should not be too small or too large.
SDA and SCL are connected to the pull-up resistor and then to the MCU for data reading.
nRESET is left floating when not in use.
ALERT is left floating when not in use.
SHT30 Write Command
1) Set IIC Start —> IIC status becomes 0x08 (start condition has been sent)
2) Send the IIC write address of SHT30 —> Wait for ACK confirmation, IIC status becomes 0x18 (device address and write command have been sent, ACK has been received)
3) Send the high byte of the control command —> Wait for ACK confirmation, IIC status becomes 0x28 (1 byte data has been sent, ACK has been received)
4) Send the low byte of the control command —> Wait for ACK confirmation, IIC status becomes 0x28 (1 byte data has been sent, ACK has been received)
SHT30 Reads Command (similar to write commands, first write a command data, then read the temperature and humidity data)
(1) Write a command data (same as writing a command) –> The IIC status becomes 0x08 (indicating that the start condition has been sent)
(2) Send the IIC read address of SHT30 –> Wait for confirmation of ACK. The IIC status is 0x40 (the device address and read command have been sent, and ACK has been received)
(3) Enable the host response function, which means that after the host receives the data, it will send an ACK confirmation.
(4) Receive high byte of temperature –> IIC status is 0x50 (Data byte has been received and ACK signal has been returned)
(5) Receive low byte of temperature –> IIC status is 0x50 (Data byte has been received and ACK signal has been returned)
(6) Received temperature CRC byte –> IIC status is 0x50 (Data byte has been received and ACK signal has been returned)
(7) Receive high byte of humidity –> IIC status is 0x50 (Data byte has been received and ACK signal has been returned)
(8) Reception low byte of humidity –> IIC status is 0x50 (Data byte has been received and ACK signal has been returned)
(9) Receive humidity CRC byte –> IIC status is 0x50 (Data bytes have been received and ACK signal has been returned)
(10) Set IIC Stop
Such as reading the periodic data measurement data command (Command 0xE000)
SHT30 Temperature and Humidity Conversion Method
Conversion of signal output: The measurement data is always transmitted in the form of 16-bit values (unsigned integers). These values have been linearized and compensated for the effects of temperature and power supply voltage. The conversion of these raw values to the physical scale can be achieved using the following formula. Relative humidity conversion formula (result in %RH):
SRH and ST represent the raw sensor outputs for temperature and humidity. The calculated result is in decimal format.
SHT30 Sensor Pin Functions
Pin | Definition |
VCC | Positive pole |
GND | Grounding |
SDA | Data signal |
SCL | Clock signal |
Parameters
Model | SHT30 |
Operating voltage | 2.4~5.5V |
Interface output | IIC |
Measurement of temperature range | -40℃ to +125℃ |
Measurement of humidity range | 0~100%RH |
Humidity measurement accuracy | ±3%RH |
Temperature measurement accuracy | ±0.3℃ |
Size | 12mm * 12mm |
SHT30 vs DHT22
Model | SHT30 | |
Communication mode | IIC communication | 1-Wire |
Temperature accuracy | ±0.3℃ | ±0.5°C |
Humidity accuracy | ±3%RH | ±2% RH |
Response speed | Quicker | Relatively slow |
Price | The SHT30 price is relatively high. | The DHT22 price is relatively low. |
SHT30 Arduino
SHT30 Pinout
- SHT30 Arduino
VCC ——> 3.3V GND ——> GND
SCL ——> SCL SDA ——> SDA
- OLED Arduino
VCC ——> 3.3V GND ——> GND
SCL ——> A5 SDA ——> A4
SHT30 Sensor Code
#include
#include
#include
#include
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_ADDR 0x3C // Default I2C address for most OLEDs
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Adafruit_SHT31 sht31 = Adafruit_SHT31();
void setup() {
Serial.begin(9600);
// Initialize I2C communication using A4(SDA) and A5(SCL)
Wire.begin();
// Initialize OLED
if(!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR)) {
Serial.println("OLED initialization failed!");
while(1); // Halt program
}
// Initialize SHT30 sensor
if (!sht31.begin(0x44)) { // Default address 0x44
Serial.println("Could not find SHT30 sensor!");
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0,0);
display.println("Sensor Error!");
display.display();
while(1);
}
// Display startup message with smaller font
display.clearDisplay();
display.setTextSize(1); // Changed from 2 to 1 for smaller font
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Environment Monitor");
display.println("Initializing...");
display.display();
delay(2000);
}
void loop() {
float temp = sht31.readTemperature();
float humi = sht31.readHumidity();
// Validate sensor readings
if (isnan(temp) || isnan(humi)) {
Serial.println("Failed to read from sensor!");
return;
}
// Display data on OLED with smaller font
display.clearDisplay();
display.setTextSize(1); // Changed from 2 to 1 for smaller font
display.setCursor(0,0);
display.print("Temp: ");
display.print(temp, 1); // 1 decimal place
display.println(" C");
display.setCursor(0,16); // Adjusted position for second line
display.print("Humi: ");
display.print(humi, 1);
display.println(" %");
display.display();
// Print to serial monitor
Serial.print("Temperature: ");
Serial.print(temp);
Serial.print(" °C\tHumidity: ");
Serial.print(humi);
Serial.println(" %");
delay(2000); // Update every 2 seconds
}
Effect Demonstration
Usage Instructions
- IIC Address: Make sure the I2C address of the SHT30 is consistent with the setting in the code.
- Power Stability: Ensure the power supply of the SHT30 is stable to avoid the influence of voltage fluctuations on the measurement results.
- Data Verification: After each data reading, perform data verification to ensure the accuracy of the data.
Application Scenarios
The SHT30 temperature and humidity sensor, with its high accuracy, fast response and small size, is widely used in various fields. In smart homes, it is used in thermostats, air conditioning systems and air quality monitoring. In the agricultural sector, it can be applied to greenhouse environment control and intelligent irrigation. In industrial applications, it is commonly found in data center environment monitoring and pharmaceutical storage. Consumer electronic products such as smart watches and weather stations also integrate this sensor. In the medical field, it is used for ward environment monitoring and drug storage. In automotive electronics, it is applied to interior climate control and battery management. In the IoT (Internet of Things) and smart building fields, it is used for building automation and energy management systems. Its digital output and I2C interface make it easy to integrate into various electronic systems.
Relative Information
SHT30 Purchase Link
FAQ
- How to determine if the SHT30 temperature and humidity sensor is damaged?
The following methods can be used to determine if the SHT30 is damaged:
1) Check if the power supply voltage is normal (3.3V – 5V);
2) Use an IIC scanning tool to detect if the device address (0x44/0x45) exists;
3) If the data read continuously returns a fixed value (such as 85°C/0%RH) or the CRC check fails;
4) Measure the sensor power consumption is abnormal (normal standby is about 1.5μA, working is 1mA);
5) Observe physical damage (such as package cracking, pin oxidation). If there is no response after excluding wiring issues, it may be damaged.
- Why is the temperature measured by the SHT30 humidity and temperature sensor inaccurate?
The possible reasons for the inaccurate temperature measurement by the SHT30 sensor include:
- Incorrect sensor placement (close to heating elements, exposed to direct sunlight, or with poor ventilation).
- Unstable power supply or noise interference (power fluctuations or unfiltered IIC lines).
- Aging (drift occurs due to long-term use, requiring recalibration).
- Communication errors (IIC signal is interfered with, CRC check fails).
- Software configuration issues (such as incorrect setting of measurement accuracy or reading timing).
Solution: Check the hardware connection, keep away from heat sources, ensure stable power supply. If necessary, recalibrate or replace the sensor.
- Is SHT30 reliable in high-temperature and high-humidity environments?
It may affect its lifespan in extreme conditions (such as steam and condensate), but it can operate stably in general industrial, agricultural, and household environments.
- What is the maximum data output frequency of the SHT30 temperature and humidity sensor?
In the high repeatability mode (High Repeatability), the SHT30 can support up to 10 measurements per second (10Hz), but the actual frequency is limited by the IIC communication speed and the processing capability of the MCU.
- What should be noted when using SHT30 outdoors?
Moisture and dust protection: It is recommended to add a protective cover to prevent direct contact with rainwater.
Avoid direct sunlight: High temperatures may cause measurement errors.
Anti-condensation: In high humidity environments, condensation may occur, which can affect the lifespan of the sensor.