Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.

SHT31 Arduino: Complete High-Accuracy Humidity Sensor Guide

When I need reliable humidity and temperature data for a client project, the SHT31 Arduino combination is my default recommendation. After working with dozens of environmental sensors over the years, the SHT31 from Sensirion consistently delivers the accuracy and stability that cheaper alternatives simply can’t match. Whether you’re building a greenhouse controller, a humidor monitoring system, or a precision weather station, this guide covers everything you need to get accurate readings.

Why the SHT31 Stands Out From Other Humidity Sensors

The SHT31 represents Sensirion’s latest generation of digital humidity and temperature sensors built on their CMOSens® technology platform. Unlike the popular DHT11 or DHT22 sensors that many hobbyists start with, the SHT31 comes factory-calibrated with linearized output and genuine I2C communication. No more bit-banging weird proprietary protocols.

From a PCB design perspective, I appreciate that Sensirion has been manufacturing humidity sensors for over 15 years. The internal compensation algorithms handle temperature cross-sensitivity automatically, which means you get consistent readings without writing complex calibration routines yourself.

SHT31 Technical Specifications

Here’s what you’re working with when you specify an SHT31 for your project:

ParameterSpecification
Operating Voltage2.4V to 5.5V
Temperature Range-40°C to +125°C
Temperature Accuracy±0.2°C (typical at 25°C)
Temperature Resolution0.01°C
Humidity Range0% to 100% RH
Humidity Accuracy±2% RH (20-80% range)
Humidity Resolution0.01% RH
CommunicationI2C (up to 1 MHz)
I2C Address0x44 (default), 0x45 (optional)
Current Consumption0.8mA (measuring), 0.2µA (idle)
Response Time8 seconds (τ63%)
Package8-pin DFN (2.5 x 2.5 x 0.9 mm)

The ±0.2°C temperature accuracy and ±2% RH humidity accuracy put the SHT31 in a different league compared to consumer-grade sensors. In independent testing, SHT31 sensors consistently outperform DHT22 and even give the BME280 a run for its money on humidity accuracy.

SHT31 Module Pinout

Most Arduino projects use breakout modules rather than the bare SHT31 chip. These modules include the necessary decoupling capacitors and I2C pull-up resistors. Here’s the typical pinout:

PinNameFunction
1VCCPower Supply (2.4-5.5V)
2GNDGround
3SCLI2C Clock
4SDAI2C Data
5ADRI2C Address Select
6ALAlert Output (optional)

Understanding the ADR Pin

The ADR pin determines the I2C address. Leave it floating or connect to GND for address 0x44. Connect to VCC for address 0x45. This means you can run two SHT31 sensors on a single I2C bus without needing a multiplexer.

The Alert Pin Feature

The AL (Alert) pin is an underused feature. You can program threshold limits for temperature and humidity, and the sensor will pull this pin HIGH when conditions exceed your limits. This is useful for alarm systems where you want hardware-level notification without constantly polling the sensor.

Wiring SHT31 to Arduino

The connection requires only four wires for basic operation. Different Arduino boards have different I2C pins:

SHT31 PinArduino Uno/NanoArduino MegaArduino Leonardo
VCC5V5V5V
GNDGNDGNDGND
SCLA5213
SDAA4202

The SHT31 module typically includes 10kΩ pull-up resistors on the SDA and SCL lines, so you don’t need to add external ones. If you’re experiencing communication issues on a bus with multiple devices, you might need to adjust pull-up values to 4.7kΩ.

Installing the Arduino Library

Before writing code, install the Adafruit SHT31 library through the Arduino Library Manager:

  1. Open Arduino IDE
  2. Navigate to Sketch → Include Library → Manage Libraries
  3. Search for “Adafruit SHT31”
  4. Install the Adafruit SHT31 Library
  5. Also install “Adafruit BusIO” if prompted

Alternatively, you can use RobTillaart’s SHT31 library from GitHub, which offers additional features like configurable measurement repeatability and better error handling.

Basic SHT31 Arduino Code

Here’s a working sketch that reads temperature and humidity:

#include <Wire.h>

#include “Adafruit_SHT31.h”

Adafruit_SHT31 sht31 = Adafruit_SHT31();

void setup() {

  Serial.begin(115200);

  while (!Serial)

    delay(10);

  Serial.println(“SHT31 Sensor Test”);

  if (!sht31.begin(0x44)) {

    Serial.println(“Couldn’t find SHT31”);

    while (1) delay(1);

  }

}

void loop() {

  float temp = sht31.readTemperature();

  float humidity = sht31.readHumidity();

  if (!isnan(temp)) {

    Serial.print(“Temperature: “);

    Serial.print(temp);

    Serial.println(” °C”);

  } else {

    Serial.println(“Failed to read temperature”);

  }

  if (!isnan(humidity)) {

    Serial.print(“Humidity: “);

    Serial.print(humidity);

    Serial.println(” %RH”);

  } else {

    Serial.println(“Failed to read humidity”);

  }

  Serial.println();

  delay(1000);

}

The isnan() check is important. When communication fails, the library returns NaN (Not a Number) rather than a garbage value. Always validate your readings before using them in control logic.

Using the Built-In Heater

The SHT31 includes an internal heater element, a feature most people overlook. The heater serves two purposes:

Condensation removal: In high-humidity environments where condensation might form on the sensor element, the heater can evaporate moisture and restore accurate readings.

Sensor validation: Running the heater should increase the temperature reading by several degrees. If it doesn’t, your sensor might be damaged.

// Enable the heater

sht31.heater(true);

delay(5000);  // Run for 5 seconds

// Disable the heater

sht31.heater(false);

// Check heater status

if (sht31.isHeaterEnabled()) {

  Serial.println(“Heater is ON”);

}

Don’t leave the heater running continuously. It’s meant for brief defogging cycles, not constant operation. Extended heater use will skew your temperature readings significantly.

SHT31 vs DHT22 vs BME280: Which Should You Use?

This is the question I get asked most frequently. Here’s my honest comparison based on real-world testing:

FeatureSHT31DHT22BME280
Temperature Accuracy±0.2°C±0.5°C±0.5°C
Humidity Accuracy±2% RH±2-5% RH±3% RH
CommunicationI2CProprietaryI2C/SPI
Response TimeFastSlowFast
Price~$6~$3~$5
Long-term StabilityExcellentPoorGood
Factory CalibratedYesSort ofYes
Additional SensorsNoNoPressure

My Recommendation

For humidity-critical applications like humidors, mushroom cultivation, or HVAC control, choose the SHT31. Its humidity accuracy and long-term stability are superior.

For general weather stations where you also need barometric pressure, the BME280 is more versatile despite slightly lower humidity accuracy.

Avoid DHT22 for anything beyond basic learning projects. The proprietary protocol is annoying, the response time is slow, and I’ve seen too many DHT22 sensors drift badly after a few months of operation.

Displaying SHT31 Data on OLED

A standalone humidity monitor needs a display. Here’s how to combine the SHT31 with an SSD1306 OLED:

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

#include “Adafruit_SHT31.h”

#define SCREEN_WIDTH 128

#define SCREEN_HEIGHT 64

#define OLED_RESET -1

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

Adafruit_SHT31 sht31 = Adafruit_SHT31();

void setup() {

  Serial.begin(115200);

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {

    Serial.println(“SSD1306 failed”);

    while (1);

  }

  if (!sht31.begin(0x44)) {

    Serial.println(“SHT31 not found”);

    while (1);

  }

  display.clearDisplay();

  display.setTextColor(SSD1306_WHITE);

}

void loop() {

  float temp = sht31.readTemperature();

  float humidity = sht31.readHumidity();

  display.clearDisplay();

  display.setTextSize(1);

  display.setCursor(0, 0);

  display.println(“Environment Monitor”);

  display.setTextSize(2);

  display.setCursor(0, 20);

  display.print(temp, 1);

  display.println(” C”);

  display.setCursor(0, 45);

  display.print(humidity, 1);

  display.println(” %”);

  display.display();

  delay(2000);

}

Both devices use I2C but have different addresses (0x3C for OLED, 0x44 for SHT31), so they coexist on the same bus without conflicts.

Common SHT31 Problems and Solutions

Sensor Not Detected

First, run an I2C scanner sketch to verify the sensor responds. If you see no devices, check your wiring. If you see a device at a wrong address, verify whether your module has the ADR pin tied differently than expected.

Readings Seem Stuck or Frozen

The SHT31 can enter a fault state after electrical noise or power glitches. Issue a soft reset:

sht31.reset();

delay(10);

Humidity Reads High After Exposure to Moisture

If the sensor was exposed to condensation or very high humidity for extended periods, the polymer sensing element can become saturated. Enable the heater for 30-60 seconds to drive off absorbed moisture, then allow the sensor to stabilize for several minutes before trusting the readings.

Temperature Reads Slightly High

Heat from nearby components can affect readings. In your PCB layout, keep the SHT31 away from voltage regulators, microcontrollers, and other heat sources. Use thermal relief on the ground plane if the sensor is soldered directly to a PCB.

Useful Resources and Downloads

ResourceDescriptionLink
SHT31 DatasheetOfficial Sensirion specificationssensirion.com
Adafruit SHT31 LibraryArduino driver librarygithub.com/adafruit
RobTillaart SHT31 LibraryAlternative library with more featuresgithub.com/RobTillaart
Arduino IDEDevelopment environmentarduino.cc/software
I2C Scanner SketchDebugging toolBuilt into Arduino IDE Examples

Frequently Asked Questions

Can I use multiple SHT31 sensors on one Arduino?

Yes. Each SHT31 has two selectable I2C addresses: 0x44 (ADR pin low or floating) and 0x45 (ADR pin connected to VCC). You can connect two sensors directly to the same I2C bus. For more than two sensors, use an I2C multiplexer like the TCA9548A.

How does the SHT31 compare to the SHT30 and SHT35?

The SHT30, SHT31, and SHT35 are variants in the same family with different accuracy grades. The SHT30 has ±3% humidity accuracy, SHT31 has ±2%, and SHT35 has ±1.5%. All share the same footprint, I2C interface, and library compatibility. Choose based on your accuracy requirements and budget.

Why are my humidity readings different from another sensor?

Humidity sensors are notoriously difficult to calibrate accurately. A 2-3% difference between sensors is normal, even within specification. For critical applications, consider purchasing calibrated sensors with certificates, or build your own calibration setup using saturated salt solutions.

Is the SHT31 waterproof?

The standard SHT31 module is not waterproof. However, Sensirion and third-party manufacturers offer weatherproof versions with protective enclosures and PTFE membranes that allow humidity measurement while protecting against liquid water and dust. These are ideal for outdoor weather stations.

How long does the SHT31 take to stabilize after power-on?

The sensor begins providing readings within milliseconds, but for best accuracy, allow 1-2 seconds after power-up before trusting the data. If the sensor was previously stored in very dry or very humid conditions, it may take several minutes to fully equilibrate with the new environment.

Wrapping Up

The SHT31 Arduino pairing delivers professional-grade humidity and temperature sensing at a hobbyist-friendly price point. The I2C interface makes wiring simple, the Adafruit library handles the protocol details, and Sensirion’s factory calibration means you can trust the readings out of the box.

For projects where humidity accuracy matters, skip the DHT sensors entirely and start with the SHT31. Your future self will thank you when you’re not debugging sensor drift issues six months into deployment.

Questions about implementing the SHT31 in your specific application? Leave a comment below with your project details.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.

  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.

Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.