树莓派与SHT30

sht30性能参数

尺寸 2.5 x 2.5 x 0.9 mm
输出 I²C, 电压输出
电源电压范围 2.15 - 5.5 V
能耗 4.8µW (在2.4 V时低重复性, 1 次/秒)
湿度工作范围 0 - 100% RH
温度工作范围 -40°C - 125°C (-40°F - 257°F)
湿度响应时间 8 秒 (tau63%)
  1. 树莓派开启i2c
  2. 安装i2c-tools
  3. 输出温湿度 python实现代码
import smbus
import time
# Get I2C bus
bus = smbus.SMBus(1)
# SHT30 address, 0x44(68)
bus.write_i2c_block_data(0x44, 0x2C, [0x06])
time.sleep(0.5)
# SHT30 address, 0x44(68)
# Read data back from 0x00(00), 6 bytes
# Temp MSB, Temp LSB, Temp CRC, Humididty MSB, Humidity LSB, Humidity CRC
data = bus.read_i2c_block_data(0x44, 0x00, 6)
# Convert the data
temp = data[0] * 256 + data[1]
cTemp = -45 + (175 * temp / 65535.0)
fTemp = -49 + (315 * temp / 65535.0)
humidity = 100 * (data[3] * 256 + data[4]) / 65535.0
# Output data to screen
print "Temperature in Celsius is : %.2f C" %cTemp
print "Temperature in Fahrenheit is : %.2f F" %fTemp
print "Relative Humidity is : %.2f %%RH" %humidity

sht30温度转化公式:
sht30温度转化公式

猜你喜欢

转载自www.cnblogs.com/denglinzhe/p/12673805.html