Introduction: Raspberry Pi - HIH6130 I2C Humidity & Temperature Sensor Python Tutorial
HIH6130 is a humidity and temperature sensor with digital output. These sensors provide an accuracy level of ±4% RH. With industry-leading long-term stability, true temperature-compensated digital I2C, Industry-leading reliability, Energy efficiency and Ultra-small package size and options. Here is its demonstration with raspberry pi using python code.
Step 1: What You Need..!!
1. Raspberry Pi
LINK : https://www.controleverything.com/content/Temperature?sku=HIH6130_I2CS
3. I²C Cable
4. I²C Shield for Raspberry Pi
LINK : https://www.controleverything.com/content/I2C-Master?sku=TOUTPI2
5. Ethernet Cable
Step 2: Connections:
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 HIH6130 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.
Step 3: Code:
The python code for HIH6130 can be downloaded from our github repository- ControlEverythingCommunity
Here is the link for the same :
The datasheet of HIH6130 can be found here:
We have used SMBus library for python code, the steps to install SMBus on raspberry pi is described here:
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.
# This code is designed to work with the HIH6130_I2CS I2C Mini Module available from ControlEverything.com.
# Get I2C bus
bus = smbus.SMBus(1)
# HIH6130 address, 0x27(39)
# Read data back from 0x00(00), 4 bytes
# humidity MSB, humidity LSB, temp MSB, temp LSB
data = bus.read_i2c_block_data(0x27, 0x00, 4)
# Convert the data to 14-bits
humidity = ((((data & 0x3F) * 256) + data) * 100.0) / 16383.0
temp = (((data & 0xFF) * 256) + (data & 0xFC)) / 4
cTemp = (temp / 16384.0) * 165.0 - 40.0
fTemp = cTemp * 1.8 + 32
# Output data to screen
print "Relative Humidity : %.2f %%" %humidity
print "Temperature in Celsius : %.2f C" %cTemp
print "Temperature in Fahrenheit : %.2f F" %fTemp
Step 4: Applications:
HIH6130 can be used to provide precise relative humidity and temperature measurement in air conditioners, enthalpy sensing, thermostats, humidifiers/de-humidifiers, and humidistats to maintain occupant comfort. It can also be employed in air compressors, weather stations and telecom cabinets.
We have a be nice policy.
Please be positive and constructive.