The Si7021 I2C Humidity and Temperature Sensor is a monolithic CMOS IC integrating humidity and temperature sensor elements, an analog-to-digital converter, signal processing, calibration data, and an I2C Interface. The Si7021 offers an accurate, low-power, factory-calibrated digital solution ideal for measuring humidity, dew-point, and temperature, in applications ranging from HVAC/R and asset tracking to industrial and consumer platforms.
Features
Precision Relative Humidity Sensor ± 3% RH (max), 0–80% RH
High Accuracy Temperature Sensor ±0.4 °C (max), –10 to 85 °C
0 to 100% RH operating range
Up to –40 to +125 °C operating range
Wide operating voltage – (1.9 to 3.6 V)
Low Power Consumption – 150 μA active current
Connection
Code
Save the following as SI7021.py
[codesyntax lang=”python”]
import smbus import time # Get I2C bus bus = smbus.SMBus(1) bus.write_byte(0x40, 0xF5) time.sleep(0.3) # SI7021 address, 0x40 Read 2 bytes, Humidity data0 = bus.read_byte(0x40) data1 = bus.read_byte(0x40) # Convert the data humidity = ((data0 * 256 + data1) * 125 / 65536.0) - 6 time.sleep(0.3) bus.write_byte(0x40, 0xF3) time.sleep(0.3) # SI7021 address, 0x40 Read data 2 bytes, Temperature data0 = bus.read_byte(0x40) data1 = bus.read_byte(0x40) # Convert the data and output it celsTemp = ((data0 * 256 + data1) * 175.72 / 65536.0) - 46.85 fahrTemp = celsTemp * 1.8 + 32 print "Relative Humidity is : %.2f %%" %humidity print "Temperature in Celsius is : %.2f C" %celsTemp print "Temperature in Fahrenheit is : %.2f F" %fahrTemp
[/codesyntax]
Testing
Run the code by typing – sudo python SI7021.py on the command line, you will see the following
Link
GY-21 Humidity Sensor with I2C Interface Si7021 for Arduino