Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use SHT31: Examples, Pinouts, and Specs

Image of SHT31Design with SHT31 in Cirkit Designer

Introduction

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.

Explore Projects Built with SHT31

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino Nano Weather Station with Ethernet Connectivity: A project utilizing SHT31 in a practical application
Arduino Nano Weather Station with Ethernet Connectivity

This circuit features an Arduino Nano microcontroller interfaced with an Ethernet W5500 module for network connectivity and an SHT31 sensor for temperature and humidity measurements. The Arduino Nano communicates with the Ethernet module via SPI and reads data from the SHT31 sensor using I2C, enabling remote monitoring of environmental conditions.

Open Project in Cirkit Designer
Image of Arduino Nano-Controlled LED Display with RTC and Humidity Sensing: A project utilizing SHT31 in a practical application
Arduino Nano-Controlled LED Display with RTC and Humidity Sensing

This circuit features a Nano 3.0 ATmega328P microcontroller connected to an LED dot display, a real-time clock (RTC DS3231), and a humidity and temperature sensor (SHT21). The microcontroller communicates with the RTC and SHT21 via I2C (using A4 and A5 as SDA and SCL lines, respectively), and it controls the LED display through SPI-like signals (using D10, D11, and D12 for DIN, CS, and CLK). The circuit is designed to display time and environmental data on the LED display, with all components sharing a common power supply and ground.

Open Project in Cirkit Designer

Technical Specifications

Key Technical Details

Pin Configuration and Descriptions

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

Usage Instructions

Integration into a Circuit

To use the SHT31 sensor in a circuit:

  1. Connect the VDD pin to a power supply within the 2.4V to 5.5V range.
  2. Connect the GND pin to the ground of the power supply.
  3. Connect the SDA and SCL pins to the I2C data and clock lines, respectively.
  4. Optionally, connect the nRESET pin to a digital output on your microcontroller if you wish to reset the sensor via software.
  5. Optionally, use the ALERT pin for system alerts based on humidity and temperature thresholds.
  6. Set the ADDR pin to either GND or VDD to select the I2C address.

Best Practices

Example Code for Arduino UNO

#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);
}

Troubleshooting and FAQs

Common Issues

FAQs

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.