Contents

Interfacing SHT31 Temperature Humidity Sensor with Arduino

SHT31 Temperature Humidity Sensor Features

The SHT31 sensor module is a temperature and humidity sensor with high accuracy and quick response time.

Specifications:

  • Temperature measurement range: -40 to +90 degrees Celsius
  • Temperature measurement accuracy: 3 degrees Celsius
  • Humidity measurement range: 0 – 100% RH
  • Humidity measurement accuracy: 2% RH
  • Communication protocol: I2C
  • Data transition: up to 1MHz frequency
  • Address pin included: To adjust I2C protocol address

SHT31 Temperature Humidity Sensor Pinout

This Module has 6 pins:

  • GND: Ground
  • VCC: Module power supply – 5V
  • SCL: Serial Clock Input for I2C Protocol
  • SDA: Serial Data Input/Output for I2C Protocol
  • RST: Reset pin
  • ADD: Address adjusting pin for I2C Protocol (If it is LOW, the address will be 0x44 and If it is, HIGH the address will be 0x45)

You can see the pinout of this module in the image below.

Required Materials

Hardware Components

Arduino UNO R3 × 1
SHT31 Temperature Humidity Sensor × 1
Male to Male jumper wire × 1

Software Apps

Arduino IDE

Interfacing SHT31 Temperature Humidity Sensor with Arduino

Step 1: Circuit

The following circuit show how you should connect Arduino to SHT31 sensor. Connect wires accordingly.

Step 2: Library

Go to Library manager and install the Adafruit SHT31 Library

Note

If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Step 3: Code

Upload the following code to Arduino. Then open the Serial Monitor.

   /*
modified on Dec 30, 2020
Modified by MehranMaleki from Arduino Examples
Home
*/ #include <Arduino.h> #include <Wire.h> #include "Adafruit_SHT31.h" Adafruit_SHT31 sht31 = Adafruit_SHT31(); void setup() { Serial.begin(9600); while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens Serial.println("SHT31 test"); //Set to 0x45 for alternate i2c addr if (! sht31.begin(0x44)) { Serial.println("Couldn't find SHT31"); while (1) delay(1); } } void loop() { float t = sht31.readTemperature(); float h = sht31.readHumidity(); // check if 'is not a number' if (! isnan(t)) { Serial.print("Temperature = "); Serial.print(t); Serial.print("*C"); Serial.print("\t\t"); } else { Serial.println("Failed to read temperature"); } // check if 'is not a number' if (! isnan(h)) { Serial.print("Humidity = %"); Serial.println(h); } else { Serial.println("Failed to read humidity"); } delay(1000); }

In this code, the humidity and temperature data will be received from the sensor every second and displayed on the Serial Monitor.  

The output is as follows:

Liked What You See?​
Get Updates And Learn From The Best​

Leave a Reply

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