The SHT31 is a high-accuracy digital humidity and temperature sensor designed and manufactured by Sensirion. It offers excellent performance and a wide range of features, making it ideal for advanced consumer products, industrial systems, and Internet of Things (IoT) applications. Its precision and reliability are well-suited for environmental monitoring, weather stations, smart home automation, and HVAC systems.
Pin Number | Name | Description |
---|---|---|
1 | VDD | Supply voltage |
2 | GND | Ground |
3 | SDA | Serial Data Line for I2C |
4 | SCL | Serial Clock Line for I2C |
5 | nRESET | Active low reset pin |
6 | ALERT | Alert pin (optional use) |
7 | ADDR | I2C address selection pin |
To use the SHT31 sensor in a circuit:
#include <Wire.h>
#include "SHT31.h"
SHT31 sht31 = SHT31();
void setup() {
Serial.begin(9600);
Wire.begin();
if (!sht31.begin(0x44)) { // Set to 0x45 if ADDR pin is tied to VDD
Serial.println("Could not find a valid SHT31 sensor, check wiring!");
while (1) delay(1);
}
}
void loop() {
float temp = sht31.getTemperature();
float hum = sht31.getHumidity();
if (!isnan(temp)) { // Check if 'temp' is not an error value
Serial.print("Temp *C = "); Serial.println(temp);
} else {
Serial.println("Failed to read temperature");
}
if (!isnan(hum)) { // Check if 'hum' is not an error value
Serial.print("Hum. % = "); Serial.println(hum);
} else {
Serial.println("Failed to read humidity");
}
delay(1000);
}
Q: Can the SHT31 sensor be used outdoors? A: Yes, but it should be protected from direct exposure to water and sunlight.
Q: How can I extend the I2C cable length? A: Use shielded cables and lower the pull-up resistor value to maintain signal integrity.
Q: What is the purpose of the ALERT pin? A: The ALERT pin can be used to trigger an interrupt on the host microcontroller when humidity or temperature exceeds programmed limits.
Q: How do I calibrate the sensor? A: The SHT31 is factory-calibrated. However, for critical applications, you may perform additional calibration using known humidity and temperature references.
Q: Is there a sleep mode to reduce power consumption? A: Yes, the SHT31 supports a low-power mode that can be activated via I2C commands.
This documentation provides a comprehensive guide to integrating and using the SHT31 sensor in various applications. For further information, consult the manufacturer's datasheet and application notes.