SKU:SEN0385
Introduction
This is a SHT31 Temperature &
Humidity sensor housed in a
weather-proof enclosure. The
sensor is designed to be waterproof so you can use it safely in outdoor projects. Please note that
although the sensor is waterproof, it is not suggested to submerge it in water. For in-water
measurement,
DS18B20
Sensor is highly recommended.
Thanks to Sensirion’s CMOSens® technology, highly integrated capacitive humidity sensing
components and band-gap temperature sensing components, the SHT31 offers high reliability
and long-term stability with low power consumption, fast response and strong anti-interference
ability. The sensor supports I2C communication, and is compatible with 3.3V/5V controllers like
Arduino, micro:bit, ESP32.
SHT31 is the standard version of the SHT3x series. It provides humidity accuracy ± 2%RH@0%
RH~100% RH (at 25°C), and temperature accuracy±0.2°C@ 0°C ~90°C (typical).
Specification
•
•
•
•
Operating Voltage: 3.3~5V
Operating Current: <1.5mA
Humidity Detection Range: 0%RH~100%RH
Humidity Accuracy: ±2%RH
•
•
•
•
Temperature Detection Range: -40℃~125℃
Temperature Accuracy: ±0.2℃
Communication: I2C
Cable Length: about 1m
PinOut
Color
Red
Black
Green
Yellow
Name
VCC
GND
SDA
SCL
Description
+
-
Data line
Clock line
Tutorial
Note: The I2C address of this sensor is 0x44. Please make sure the I2C address is correct
when using it.
Requirements
•
Hardware
o
DFRduino UNO R3
(or similar) x 1
o
SHT31 Temperature & Humidity Sensor (Weather-proof) x1
o
Jumper wires
Software
o
Arduino IDE
o
Download and install the
SHT3X Library
(About
how to install the library?)
API Function List
•
•
/**
* @brief Get the measured temperature (in degrees Celsius).
* @return Return the temperature data of float type.
*/
float getTemperatureC();
/**
* @brief Get the measured temperature (in degrees Fahrenheit).
* @return Return the temperature data of float type.
*/
float getTemperatureF();
/**
* @brief Get measured humidity(%RH).
* @return Return the humidity data of float type.
*/
float getHumidityRH();
Connection Diagram
Sample Code 1-Single Measurement Mode
In single measurement mode, the sensor collects data every time the controller board sends out
the data collecting command. The power consumption could be very low in this mode since users
can read data according to their needs.
/*!
* @brief Construct the function
* @param pWire I2C bus pointer object and construction device, can both pass or
not pass parameters, Wire in default.
* @param address Chip I2C address, two optional addresse.
*/
/*!
* @file singleMeasurement.ino
* @brief Read ambient temperature (C/F) and relative humidity (%RH) in single-
read mode.
* @n Experimental phenomenon: the chip defaults in this mode, we need to send
instructions to enable the chip collect data,
* which means the repeatability of the read needs to be set (the difference
between the data measured by the chip under the same measurement conditions)
* then read the temperature and humidity data and print the data in the serial
port.
* @n Single measure mode: read data as needed, power consumption is relatively
low, the chip idle state only costs 0.5mA.
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence
The MIT License (MIT)
* @author [fengli](li.feng@dfrobot.com)
* @version V1.0
* @date 2019-08-21
* @get from https://www.dfrobot.com
* @url https://github.com/DFRobot/DFRobot_SHT3x
*/
#include
<DFRobot_SHT3x.h>
/*!
* @brief Construct the function
* @param pWire I2C bus pointer object and construction device,
not pass parameters,
* Wire in default.
* @param address Chip I2C address, two optional addresses 0x44
default).
* @param RST RST Chip reset pin, 4 in default.
* @n I2C address is determined by the pin addr on the chip.
* @n When the ADR is connected to VDD, the chip I2C address is
* @n When the ADR is connected to GND, the chip I2C address is
*/
DFRobot_SHT3x
sht3x(&Wire,/*address=*/0x44,/*RST=*/4);
//DFRobot_SHT3x
sht3x;
void setup()
{
Serial.begin(9600);
//Initialize the chip
while
(sht3x.begin()
!=
0)
{
Serial.println("Failed to Initialize the chip, please confirm the wire
connection");
delay(1000);
}
/**
both can pass or
and 0x45(0x45 in
0x45.
0x44.
* readSerialNumber Read the serial number of the chip.
* @return Return 32-digit serial number.
*/
Serial.print("Chip serial number");
Serial.println(sht3x.readSerialNumber());
/**
* softReset Send command resets via I2C, enter the chip's default mode single-
measure mode,
* turn off the heater, and clear the alert of the ALERT pin.
* @return Read the register status to determine whether the command was
executed successfully,
* and return true indicates success.
*/
if(!sht3x.softReset()){
Serial.println("Failed to Initialize the chip....");
}
/**
* heaterEnable(): Turn on the heater inside the chip to enable the sensor get
correct humidity value in wet environments.
* @return Read the status of the register to determine whether the command was
executed successfully,
* and return true indicates success.
* @note Heaters should be used in wet environments, and other cases of use
will result in incorrect readings
*/
//if(!sht3x.heaterEnable()){
// Serial.println("Failed to turn on the heater....");
//}
Serial.println("------------------Read adta in single measurement mode---------
--------------");
}
void loop()
{
Serial.print("Ambient Temperature(°C/F):");
/**
* getTemperatureC Get the meansured temperature(℃).
* @return Return float temperature data.
*/
Serial.print(sht3x.getTemperatureC());
Serial.print(" C/");
/**
* getTemperatureF:Get the meansured temperature(℉).
* @return Return float temperature data.
*/
Serial.print(sht3x.getTemperatureF());
Serial.print(" F ");
Serial.print("Relative Humidity(%RH):");
/**
* getHumidityRH: Get the meansured humidity (%RH)
* @return Return float humidity data
*/
Serial.print(sht3x.getHumidityRH());