Source: https://mokxi.com/parts/sht31
Updated: 2026-11-10

Part

# Temperature and humidity, SHT31

Temperature and humidity over I2C at 0x44, a CRC on every word, 15 ms a reading.

See every part

- 4 pins
- 3 settings
- In 1 project
- In 1 lesson

Drawn live by the editor's own code, at the size you see it.

At a glance

## The Temperature and humidity, SHT31 in brief

What it is, and every setting the properties panel gives it.

The SHT31 is Sensirion’s digital temperature and humidity sensor, on breakouts such as the GY-SHT31-D. It is what weather stations and CO2 monitors move up to from a DHT22: it shares the I2C bus instead of needing a pin of its own, it answers at 0x44 or 0x45, and every two-byte word it returns carries a checksum, so a corrupted reading is caught rather than printed. There are no registers to set; every request is a sixteen-bit command. In Mokxi two sliders on the part set the temperature, from -40 to 125 °C, and the humidity. The model follows Sensirion’s command set: the soft reset and power-on times, single-shot measurements of up to 15 ms during which the sensor refuses to be read, periodic mode, the status register with its heater bit, and the CRC on every word. It does not warm itself with the heater or add the real part’s small errors.

Family

Sensors

Pins

4

address

68

temperature

22

humidity

45

Pins

## 4 pins

Named as the editor names them, so a wire lands where you expect it.

Pin

What it does

VIN

Supply, 2.15 V to 5.5 V.

GND

Ground.

SCL

I2C clock. The module carries the pull-ups.

SDA

I2C data.

How to use it

## How to use the SHT31 humidity sensor with an Arduino

VIN to 5 V, GND to ground, SDA to A4 and SCL to A5; the board has the pull-ups. In the air quality monitor the SHT31 shares those two wires with an SGP30 gas sensor and an HT16K33 four-digit display, three devices on one bus, each at its own address. The SHT31 is at 0x44 with its ADDR strap left low.

sht31.begin(0x44) checks that it answers. readTemperature() and readHumidity() each start a measurement, wait for it and check the checksum, returning NAN if anything went wrong. The monitor does something extra: it feeds the SHT31’s humidity to the SGP30, which reads more accurately when it knows how wet the air is. Drag the two sliders on the SHT31 and the display’s temperature and humidity turns follow.

The monitor calls measure() and then getTemperatureCentis() and getHumidityCentis(), which give whole hundredths. Printing the library’s floats works on every board here, but on an Uno do your arithmetic in those whole numbers, as this sketch does.

Part pin

Board pin

VIN

5 V

GND

GND

SDA

A4

SCL

A5

The sensor runs from 2.15 to 5.5 V, so it wires to an ESP32 or a Pico’s 3.3 V and default I2C pins unchanged, and on those boards float arithmetic on the readings is fine.

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

Temperature and humidity in hundredths, from the air quality sketch

Common errors

## Common Temperature and humidity, SHT31 errors and fixes

What goes wrong

The fix

A read straight after the measure command gets no answer.

The sensor refuses reads while it measures, up to 15 ms at high repeatability. The library waits for you; raw Wire code has to wait before requesting the six bytes.

begin() fails on a board that worked elsewhere.

The ADDR strap decides between 0x44 and 0x45. Match the address in begin() to the strap, or set the part’s address property to match your code.

A readings line shows nan.

The library returns NAN when a checksum fails or the sensor did not answer. Check the wiring and keep the I2C wires short.

Arithmetic on the readings will not link on an Uno.

Use getTemperatureCentis() and getHumidityCentis() after measure(); they return whole hundredths you can add, compare and scale.

Questions

## Questions and answers

### Is the SHT31 more accurate than a DHT22?

Typically yes: about plus or minus 2 %RH and 0.3 °C, with a checksum on every reading. It also shares the I2C bus instead of needing its own timing-critical pin.

### What does the SHT31 heater do?

It warms the sensor to drive off condensation after very humid conditions. The command switches it on and the status register reports it; in the simulation it does not change the reading.

### Can two SHT31 sensors share one bus?

Yes, two: one with ADDR low at 0x44 and one with it high at 0x45.

### Are the SHT30 and SHT35 read the same way?

Yes. They use the same commands and the same library; they differ in accuracy grade.

How it is modeled

## What is true about the Temperature and humidity, SHT31, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

The command set, the power-on and reset times, the three measurement durations and
the NACK while measuring, periodic mode with Fetch and Break, the CRC on every word,
the status register and its heater, reset and command bits, all from the SHT3x-DIS
datasheet (version 7).

### Not modeled

Clock stretching (the commands that ask for it are taken, and a read during the
measurement is refused as in the no-stretch mode), the ALERT pin and its limits, the
heater's actual warming, the accuracy figures (±2 %RH and ±0.3 °C typical) and the
response time.

From SHT31 temperature and humidity sensor, in full.

Projects

## See the Temperature and humidity, SHT31 in a project

One built-in project uses it. It opens in the editor, already wired.

Lessons

## Where it turns up in a lesson

One lesson places it in its own circuit.

### Learn articles

1 lesson

- Arduino SHT31: Library, Example and Wiring

Boards

## The boards it is shown on

This board has a built-in project with the Temperature and humidity, SHT31 in it.

- Arduino Uno R3

Libraries

## Arduino libraries for the Temperature and humidity, SHT31

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

- Adafruit SHT31 Library

Keep going

## Keep going

- I2C Explained: Addresses, Acknowledges and Pull-Ups
- Arduino Temperature Data Logger Lab, Step by Step
- Temperature and humidity, DHT22
- Pressure, humidity and temperature, BME280
- Temperature sensor, TMP117

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Temperature and humidity, SHT31

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
