SHT31 Temperature & Humidity Sensor Features
SHT31 is a digital temperature and humidity sensor. This module uses I2C communication and there are two SCL and SDA pins that are needed to be hooked up in order to communicate to this sensor. This sensor is ideal for temperature and humidity sensing.
Temperature measurement range: -40° +125°/ Accuracy ±0.3C°
Humidity measuring range: 0-100% RH°/ Accuracy ±2%
You can download the datasheet of this module here.
SHT31 Temperature & Humidity Sensor Datasheet
1 file(s) 953.93 KB
SHT31 Temperature Sensor Pinout
This sensor has 4 pins:
- VCC: Module power supply –2.4-5 V
- GND: Ground
- SDA: I2C data
- SCL: I2C clock
You can see pinout of this module in the image below.
Required Materials
Hardware Components
Software Apps
Interfacing SHT31 Sensor with Arduino
Step 1: Circuit
The following circuit shows how you should connect Arduino to SHT31 sensor. Connect wires accordingly.
Step 2: Installing Library
Download the SHT31 sensor library from the link below and then install.
Tip
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 your Arduino. This code displays the temperature and humidity read in the serial monitor. You can also use the Serial plotter to draw graphs.
/*
SHT31 Temperature & Humidity Sensor
modified on 20 Sep 2020
by Mohammad Reza Akbari @ Electropeak
Home
Based on Library Example
*/
#include "Wire.h"
#include "SHT31.h"
uint32_t start;
uint32_t stop;
SHT31 sht;
void setup()
{
Serial.begin(115200);
Wire.begin();
sht.begin(0x44); //SHT31 I2C Address
Wire.setClock(100000);
uint16_t stat = sht.readStatus();
Serial.print(stat, HEX);
Serial.println();
}
void loop()
{
sht.read();
Serial.print("Temperature:");
Serial.print(sht.getTemperature(), 1);
Serial.print("\t");
Serial.print("Humidity:");
Serial.println(sht.getHumidity(), 1);
delay(50);
}
After running the code, you will see the following image in the serial output.
Comments (2)
Mohammadreza,
Thank you, your code works and I have learnt about i2c bus.
Gary 29/3/2022
Hi,
You’re quite welcome.