Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qwst sensor modules, including BME688 and SCD41 #226

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Name I2C address constants, and check for error initializing the SCD41
MichaelBell committed May 10, 2024
commit f67f9a6f489f5e933169566b28ba148f354ddf86
14 changes: 9 additions & 5 deletions enviro/__init__.py
Original file line number Diff line number Diff line change
@@ -10,9 +10,9 @@
i2c = PimoroniI2C(I2C_SDA_PIN, I2C_SCL_PIN, 100000)
i2c_devices = i2c.scan()
model = None
if 56 in i2c_devices: # 56 = colour / light sensor and only present on Indoor
if I2C_ADDR_BH1745 in i2c_devices: # colour / light sensor and only present on Indoor
model = "indoor"
elif 35 in i2c_devices: # 35 = ltr-599 on grow & weather
elif I2C_ADDR_LTR559 in i2c_devices: # ltr-599 on grow & weather
pump3_pin = Pin(12, Pin.IN, Pin.PULL_UP)
model = "grow" if pump3_pin.value() == False else "weather"
pump3_pin.init(pull=None)
@@ -33,9 +33,13 @@ def get_board():

# return any additional sensors connected with Qw/ST
def get_additional_sensors():
if 98 in i2c_devices:
import enviro.sensors.scd41 as scd41
yield scd41
if I2C_ADDR_SCD41 in i2c_devices:
try:
import enviro.sensors.scd41 as scd41
yield scd41
except RuntimeError:
# Likely another device present on the SCD41 address
pass

# set up the activity led
# ===========================================================================
5 changes: 5 additions & 0 deletions enviro/constants.py
Original file line number Diff line number Diff line change
@@ -47,3 +47,8 @@
WATER_VAPOR_SPECIFIC_GAS_CONSTANT = 461.5
CRITICAL_WATER_TEMPERATURE = 647.096
CRITICAL_WATER_PRESSURE = 22064000

# I2C addresses
I2C_ADDR_BH1745 = 0x38
I2C_ADDR_LTR559 = 0x23
I2C_ADDR_SCD41 = 0x62