Link Search Menu Expand Document

Temperature and Humidity Readings with the SHT30

Table of contents

  1. Overview
  2. Install the SHT31 Library
  3. Run the SHT31test.ino sketch from the Adafruit library
  4. Plot Heater status, Temperature and Relative Humidity
  5. Simple Reading of Temperature and Relative Humidity

Overview

This web page demonstrates how to retrieve the temperature and humidity readings SHT30 sensor mounted on the Feather nRF52840 Sense. Because the SHT30 sensor is mounted directly on the Feather nRF52840 the temperature reading is strongly influenced by the temperature of the board. The humidity is not directly affected by proximity to the board, but the humidity on the board may be affected by the board temperature, which may be different from the true ambient temperature in the room.

SHT30 on Adafruit Feather Sense

Reading and processing the raw analog sensor data on an Arduino board is not necessary because the SHT30 chip is connected to the nRF52840 via an I2C digital interface. In the Arduino sketch, the temperature value is obtained by calling the readTemperature method for a SHT30 object. The value is communicated digitally over the I2C interface. The readHumidity method performs the analogous function for the relative humidity value measured by the SHT30 chip.

This web page provides a sample Arduino sketch for obtaining the temperature and relative humidity values measured by the on-board SHT30. The same code should also work with an external SHT30 connected to an Arduino board via I2C. In other words, the code is independent of the physical wiring as long as the I2C connections are correct. The full capabilities of the SHT30 are described in the (old, 2015) datasheet on the Adafruit website or the datasheet from Sensiron, the manufacturer. Sensiron also provides a high level overview of their humidity sensors.

Adafruit provides a software library and instructions with examples for using the SHT3X family of sensors. The source code is available on github. SHT30 usage is also demonstrated in the sample code provided by Adafruit for the Feather nRF52840 Sense.

Install the SHT31 Library

To write Arduino sketches that use the SHT30, you first need to install the Adafruit SHT31 Library. Note that the SHT31 library also works with the SHT30 chip. The following steps use the Arduino Library Manager and assume that you have properly configured the board support page.

From menu at the top of the Arduino IDE, select Sketch –> Include Library –> Manage Libraries…

  1. Enter “SHT3” in the search box to narrow the range of choices. Or, if you prefer, scroll through the entire list of libraries
  2. Choose the “Adafruit SHT31 Library” panel
  3. Click Install

Select and install the Adafruit SHT31 library

Run the SHT31test.ino sketch from the Adafruit library

After installing the library you should test the sensor with the sample sketch provided by Adafruit. In the Arduino IDE, select File –> Examples –> Adafruit SHT31 Library –> SHT31test, which will open up the SHT31test sketch.

Running the SHT31test sketch produces output similar to the following in the Serial Monitor. The temperature and humidity will depend on the ambient conditions where you are when you run the sketch. Note that after 10 readings, I breathed on the sensor, cause a slight increase in temperature and a significant increase in relative humidity.

SHT31 test
Heater Enabled State: DISABLED
Temp *C = 21.49      Hum. % = 52.00
Temp *C = 21.48      Hum. % = 51.91
Temp *C = 21.48      Hum. % = 51.80
Temp *C = 21.46      Hum. % = 51.75
Temp *C = 21.46      Hum. % = 51.62
Temp *C = 21.43      Hum. % = 51.61
Temp *C = 21.48      Hum. % = 51.84
Temp *C = 22.01      Hum. % = 53.51    <-- Breathed on the sensor
Temp *C = 21.70      Hum. % = 61.30
Temp *C = 21.65      Hum. % = 68.52
Temp *C = 21.59      Hum. % = 73.74
...                                    <-- Readings omitted

Heater Enabled State: ENABLED
Temp *C = 21.53      Hum. % = 53.66
Temp *C = 22.15      Hum. % = 53.12
Temp *C = 22.33      Hum. % = 52.39
Temp *C = 22.45      Hum. % = 51.61
Temp *C = 22.53      Hum. % = 50.96
...

The SHT30 has a small heater designed to reduce the effect of condensing moisture on the surface that detects relative humidity. Every 30 readings, the SHT31test sketch alternates between having the heater on and the heater off. A message announcing the state change interrupts the columns of temperature and humidity values.

The heater affects both the temperature and humidity readings. The following section shows those affects graphically.

Plot Heater status, Temperature and Relative Humidity

The SHT31test_noText.ino sketch is a modified version of SHT31test with the primary difference being that the text output to the Serial Monitor is removed. The output is three columns of numerical values – heater status, temperature and relative humidity.

Download the SHT31test_noText.ino sketch and upload it to your board.

Running SHT31test_noText and opening the Serial Plotter should produce output similar to the figure below. The heater status is the middle blue line with the arbitrary levels of 30 for heater off and 35 for heater on. You can clearly see that when the heater is on, the humidity data decreases and the temperature data increases. The changes in relative humidity and temperature have exponential decays, which suggest that the mass of the sensing element contributes to the slow change in readings.

Output of SHT31test_noText.ino

Simple Reading of Temperature and Relative Humidity

The demoSHT30simple.ino sketch is a stripped-down example of reading the temperature and humidity from the SHT30 sensor on the Feather nRF52840 Sense. No on-sensor heater is used and the values of temperature and relative humidity are printed with no text adornments except column headings. This sketch allows the values of temperature and relative humidity to be displayed on the Serial Plotter.

Download the demoSHT30simple.ino