-
Notifications
You must be signed in to change notification settings - Fork 2
Adafruit Temperature Humidity Sensor
Beau edited this page Feb 27, 2023
·
2 revisions
- Si7021 (adafruit-circuitpython-si7021)
- AHT20 (adafruit-circuitpython-ahtx0)
- SHT40 (adafruit-circuitpython-sht4x)
- HTU31-D (?)
import board
import adafruit_si7021
sensor = adafruit_si7021.SI7021(board.I2C())
import board
import adafruit_sht4x
sensor = adafruit_sht4x.SHT4x(board.I2C())
import board
import adafruit_ahtx0
sensor = adafruit_ahtx0.AHTx0(board.I2C())
print('Temperature: %.2f\xb0F, Humidity: %.2f%%'\
%(sensor.temperature * 1.8 + 32, sensor.relative_humidity))
Temperature: 72.98°F, Humidity: 40.12%
import board
import adafruit_si7021
import adafruit_ahtx0
import adafruit_sht4x
print("Loading sensors...")
sensors = []
sensors.append(adafruit_si7021.SI7021(board.I2C()))
sensors.append(adafruit_ahtx0.AHTx0(board.I2C()))
sensors.append(adafruit_sht4x.SHT4x(board.I2C()))
def temp(s):
print('Temperature: %.2f F, Humidity: %.2f%%'%(s.temperature * 1.8 + 32, s.relative_humidity))
def readTemps():
for i in range(3): temp(sensors[i])
print("Reading sensors...")
readTemps()
Temperature: 72.57 F, Humidity: 37.67%
Temperature: 74.56 F, Humidity: 38.74%
Temperature: 73.58 F, Humidity: 39.41%