Raspberry Pi - SHT30 Humidity & Temperature Sensor Python Tutorial

by Dcube Tech Ventures in Circuits > Electronics

73 Views, 0 Favorites, 0 Comments

Raspberry Pi - SHT30 Humidity & Temperature Sensor Python Tutorial

Raspberry Pi - SHT30 Humidity & Temperature Python Sensor Tutorial

SHT30 Digital Humidity and Temperature Sensor offers superior performance and a space saving footprint. It provides calibrated, linearized signals in digital, I2C format. Fabrication of this sensor is based on CMOSens technology, which attributes to the superior performance and reliability of SHT30. The resolution of SHT30 can be changed by command, low battery can be detected and a checksum helps to improve communication reliability. Here is its demonstration of interfacing it with Raspberry Pi using Python code.

What You Need...!!

SHT30.jpg
pi_1.jpg

Connections:

SHT30.jpg
pi_1.jpg
sensor.jpg
complete_connection.jpg

Take an 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 SHT30 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 above.

Code:

complete_connection.jpg

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

Here is the link for the same :

https://github.com/ControlEverythingCommunity/SHT3...

We have used SMBus librar 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.

# SHT30

# This code is designed to work with the SHT30_I2CS I2C Mini Module available in Dcube Store.

import smbus

import time

# Get I2C bus

bus = smbus.SMBus(1)

# SHT30 address, 0x44(68)

# Send measurement command, 0x2C(44)

# 0x06(06) High repeatability measurement

bus.write_i2c_block_data(0x44, 0x2C, [0x06])

time.sleep(0.5)

# SHT30 address, 0x44(68)

# Read data back from 0x00(00), 6 bytes

# cTemp MSB, cTemp LSB, cTemp CRC, Humididty MSB, Humidity LSB, Humidity CRC

data = bus.read_i2c_block_data(0x44, 0x00, 6)

# Convert the data

cTemp = ((((data[0] * 256.0) + data[1]) * 175) / 65535.0) - 45

fTemp = cTemp * 1.8 + 32humidity = 100 * (data[3] * 256 + data[4]) / 65535.0

# Output data to screen

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

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

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

Applications:

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