Introduction: Raspberry Pi SHT25 Humidity & Temperature Sensor Python Tutorial

About: We are a group of makers. We work in IoT, IOS app, android app, embedded design, sensor design, raspberry pi, arduino, beaglebone, particle electron, particle photon, Bluetooth.

SHT25 I2C Humidity and Temperature Sensor ±1.8%RH ±0.2°C I2C Mini Module. The SHT25 high-accuracy humidity and temperature sensor has become an industry standard in terms of form factor and intelligence, providing calibrated, linearised sensor signals in digital, I2C format. Here is the demonstration with a Python code using Raspberry Pi.

Step 1: What You Need..!

1. Raspberry Pi

2. SHT25

3. I²C Cable

4. I²C Shield for Raspberry Pi

5. Ethernet Cable

Step 2: Connections

Take a I2C shield for raspberry pi and gently push it over the gpio pins of raspberry pi.

Then connect the one end of I2C cable to SHT25 sensor and the other end to the I2C shield.

Also connect the Ethernet cable to the pi or you can use a WiFi module.

Connections are shown in the picture below.

Step 3: Pyhton Code

The python code for SHT25 can be downloaded from our GitHub repository- Dcube Store

Code can be found here:

https://github.com/DcubeTechVentures/SHT25/blob/master/Python/SHT25.py

We have used SMBus library for python code, the steps to install SMBus on raspberry pi is described here:

https://pypi.python.org/pypi/smbus-cffi/0.5.1

You can also copy the code from here, it is given as follows:

#Distributed with a free-will license.

# Use it any way you want, profit or free, provided it fits in the licenses of its associated works.

# SHT25

import smbus

import time

# Get I2C bus

bus = smbus.SMBus(1)

# SHT25 address, 0x40(64)

# Send temperature measurement command

# 0xF3(243) NO HOLD master

bus.write_byte(0x40, 0xF3)

time.sleep(0.5)

# SHT25 address, 0x40(64)

# Read data back, 2 bytes

# Temp MSB, Temp LSB

data0 = bus.read_byte(0x40)

data1 = bus.read_byte(0x40)

# Convert the data

temp = data0 * 256 + data1

cTemp= -46.85 + ((temp * 175.72) / 65536.0)

fTemp = cTemp * 1.8 + 32

# SHT25 address, 0x40(64)

# Send humidity measurement command

# 0xF5(245) NO HOLD master

bus.write_byte(0x40, 0xF5)

time.sleep(0.5)

# SHT25 address, 0x40(64)

# Read data back, 2 bytes

# Humidity MSB, Humidity LSB

data0 = bus.read_byte(0x40)

data1 = bus.read_byte(0x40)

# Convert the data

humidity = data0 * 256 + data1

humidity = -6 + ((humidity * 125.0) / 65536.0)

# Output data to screen

print "Relative Humidity is : %.2f %%" %humidity

print "Temperature in Celsius is : %.2f C" %cTemp

print "Temperature in Fahrenheit is : %.2f F" %fTemp

Step 4: Applications

SHT25 temperature and relative humidity sensor has various industrial applications like temperature monitoring, computer peripheral thermal protection and so on..