Hookup Sensirion SHT31 Temperature Humidity Sensor to Arduino

Overview

The SHT31 from Sensirion is a factory calibrated sensor for measuring relative humidity & temperature. The SHT31 has increased intelligence, reliability and improved accuracy specifications compared to its predecessor. Unlike the SHT15 this sensor is fully I2C compatible.

The easiest way to use this sensor is using a breakout board. We use the breakout board from Adafruit. This board has the pullup and pulldown resistors already installed. We just need to connect the wires from the SHT31 board to the Arduino and load the software.

Sensor Features

  • Supply voltage range is 2.4 to 5.5 V
  • RH operating range 0 - 100% RH
  • Temperature range is -40 to +125°C (-40 to +257°F)
  • Typical Humidity accuracy is +/- 2%
  • Typical Temperature accuracy is +/- 0.2 °C

Images

SHT31 Temperature Humidity Sensor
SHT31 Sensor Breakout board

(Images are not to scale)

Hardware and Software Parts List

  • Arduino Board
  • Sensirion SHT31 Temperature Humidity Sensor. The one we used was from Adafruit. PN 2857
  • Breadboard hookup wires
  • USB Cable to suite Arduino

Wiring Diagram for the SHT31 to Arduino Board using Default Address 0x44

Connect Arduino to SHT31 Temperature Sensor Hookup

Wiring Diagram for the SHT31 to Arduino Board using Alternative Address 0x45

To use the alternative I2C address we need to pull the ADR pin high. This is pulled to ground on the breakout board via one of the resistors. As shown in the diagram below we have connected the ADR pin to the 5V pin on the Arduino. We will also need to modify the sketch so that when we create the SHT31 object we define the address 0x45. We create the object using cactus_io_SHT31 sht(0x45).

Connect Arduino to SHT31 Temperature Sensor Hookup

The RST pin is used to hardware reset the sensor. We do not use it. The ALR pin is used to signal the microcontroller that a trigger event has occured on the sensor. This could be a maximum or minimum temperature or humidity has been reached. We are not using this functionality. Refer to the product website for more details on this functionality.

Software

We can test this sensor using the simple sketch as shown below. It requires the cactus.io SHT31 Library to communicate with the sensor.

It reads the temperature and humidity every 2 seconds and then displays it on the console.

  • Its blocking code.

Library

The cactus_io_SHT31 library provides the following functions:

  • SHT31() Creates an object using default address of 0x44
  • or SHT31(int address) Creates an object using alternative address. For example SHT31(0x45)
  • begin() Called to initialise the sensor after the object is created
  • setTempCal(float) Allows you to define a temp calibration offset if it reads high
  • getTemperature_C() Returns a float value in degrees celsius
  • getTemperature_F() Returns a float value in degrees fahrenheit
  • getHumidity() Returns a float as a percentage humidity
  • getDewPoint() Returns a float value for dew point

Sample Sketch

Sensirion SHT31 Sample Sketch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "cactus_io_SHT31.h"

cactus_io_SHT31 sht31;
// or cactus_io_SHT31 sht31(0x45); // for the alternative address

void setup(){

Serial.begin(9600);
Serial.println("Sensirion SHT31 Humidity - Temperature Sensor | cactus.io");

if (!sht31.begin()) {
Serial.println("Count not find sensor. Check wiring and I2C address");
while(1) delay(1);
}

Serial.println("Humidity\t\tTemp \t\tTemp");
}

void loop(){

Serial.print(sht31.getHumidity()); Serial.print(" %\t\t");
Serial.print(sht31.getTemperature_C()); Serial.print(" *C\t");
Serial.print(sht31.getTemperature_F()); Serial.print(" *F\t");
Serial.print(sht31.getDewPoint()); Serial.println(" *C\t");

// Add a 2 second delay.
delay(2000);
}

Sketch Output

Connect Arduino to Sensirion SHT31 Humidity - Temperature Sensor

License