コード例 #1
0
def init ():
    global i2c
    global sensor
    global start_time
    i2c = board.I2C()
    sensor = adafruit_hts221.HTS221(i2c) 
    start_time = time.time()
    return sensor
コード例 #2
0
import time
import board
import busio
import adafruit_hts221

i2c = busio.I2C(board.SCL, board.SDA)
hts = adafruit_hts221.HTS221(i2c)
while True:
    print("Relative Humidity: %.2f %% rH" % hts.relative_humidity)
    print("Temperature: %.2f C" % hts.temperature)
    print("")
    time.sleep(1)
コード例 #3
0
# Temperature - MCP9808 (top/bottom, left/right interior array position)
temp_TL_array = Sensor(adafruit_mcp9808.MCP9808(i2c, address=0x18),
                       get_i2c_temp, None)  # pos1, left-upper rail
temp_BL_array = Sensor(adafruit_mcp9808.MCP9808(i2c, address=0x19),
                       get_i2c_temp, None)  # pos2, left-lower rail
temp_TR_array = Sensor(adafruit_mcp9808.MCP9808(i2c, address=0x1A),
                       get_i2c_temp, None)  # pos3, right-upper rail
temp_BR_array = Sensor(adafruit_mcp9808.MCP9808(i2c, address=0x1B),
                       get_i2c_temp, None)  # pos4, right-lower rail
temp_peltier = Sensor(adafruit_mcp9808.MCP9808(i2c, address=0x1C),
                      get_i2c_temp, None)  # pos5, peltier heat sink
# Humidity & Temp - SHT30-D Weatherproof
temp_humd_indoor = Sensor(adafruit_sht31d.SHT31D(i2c), get_i2c_temp,
                          get_i2c_humd)  # pos7, inside gc
# Humidity & Temp - HTS221 Outdoor
temp_humd_outdoor = Sensor(adafruit_hts221.HTS221(i2c), get_i2c_temp,
                           get_i2c_humd)  # pos8, outside gc

# --- 1W Sensor Initialize ---
#  1-wire DS18B20 digital temp sensor addresses
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
# w1 address
temp_h20 = Sensor('28-8a2017eb8dff', get_w1_temp,
                  None)  # pos6, in water reservoir

# -- I2C PWM Control Initialize ---
pca = adafruit_pca9685.PCA9685(i2c)
pca.frequency = 120  # Hz
# PWM output
fan_L_circ = Actuator(pca.channels[6], set_pwm_output)