In this article we look at another Humidity and Temperature Sensor – this time its the Si7021 and we will connect it to our Beaglebone and we will have a python example
First lets take a look at the sensor in question
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
This was my sensor of choice
Parts Required
Schematic/Connection
Code Example
[codesyntax lang=”python”]
import smbus import time bus = smbus.SMBus(2) # SI7021 address, 0x40(64) # Read data, 2 bytes, Humidity MSB first rh = bus.read_i2c_block_data(0x40, 0xE5, 2) #what really happens here is that master sends a 0xE5 command (measure RH, hold master mode) and read 2 bytes back #if you read 3 bytes the last one is the CRC! time.sleep(0.1) # Convert the data humidity = ((rh[0] * 256 + rh[1]) * 125 / 65536.0) - 6 # SI7021 address, 0x40(64) # Read data , 2 bytes, Temperature MSB first temp = bus.read_i2c_block_data(0x40, 0xE3,2) #what really happens here is that master sends a 0xE3 command (measure temperature, hold master mode) and read 2 bytes back #if you read 3 bytes the last one is the CRC! time.sleep(0.1) # Convert the data cTemp = ((temp[0] * 256 + temp[1]) * 175.72 / 65536.0) - 46.85 fTemp = cTemp * 1.8 + 32 # Output data to screen print ("Humidity %%RH: %.2f%%" %humidity) print ("Temperature Celsius: %.2f C" %cTemp) print ("Temperature Fahrenheit: %.2f F" %fTemp)
[/codesyntax]
Output
Run this example and you should see the following –
debian@beaglebone:/var/lib/cloud9/$ python si7021.py
Humidity %RH: 39.00%
Temperature Celsius: 14.38 C
Temperature Fahrenheit: 57.88 F
debian@beaglebone:/var/lib/cloud9/$ python si7021.py
Humidity %RH: 39.00%
Temperature Celsius: 14.24 C
Temperature Fahrenheit: 57.63 F
debian@beaglebone:/var/lib/cloud9/$
Links