diff --git a/README.md b/README.md index a7b31d8..2f86795 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ support it are listed in the API description. | ------------- | -------------- | |[SCD40](https://sensirion.com/products/catalog/SCD40)| **0x62**| |[SCD41](https://sensirion.com/products/catalog/SCD41)| **0x62**| +|[SCD43](https://sensirion.com/products/catalog/SCD43)| **0x62**| The following instructions and examples use a *SCD41*. diff --git a/sensirion_i2c_scd4x/commands.py b/sensirion_i2c_scd4x/commands.py index ebda7dd..be9cc50 100644 --- a/sensirion_i2c_scd4x/commands.py +++ b/sensirion_i2c_scd4x/commands.py @@ -502,9 +502,11 @@ def pack(self): class SensorVariant(Enum): - UNKNOWN = 0 - SCD40 = 1 - SCD41 = 2 + MASK = 61440 + SCD40 = 0 + SCD41 = 4096 + SCD42 = 8192 + SCD43 = 20480 def __int__(self): return self.value diff --git a/sensirion_i2c_scd4x/device.py b/sensirion_i2c_scd4x/device.py index 20704d2..e48c416 100644 --- a/sensirion_i2c_scd4x/device.py +++ b/sensirion_i2c_scd4x/device.py @@ -388,6 +388,7 @@ def get_sensor_variant_raw(self): :return sensor_variant: Bits[15…12] = 0000 → SCD40 Bits[15…12] = 0001 → SCD41 + Bits[15…12] = 0101 → SCD43 .. note:: This command is only available in idle mode. @@ -628,13 +629,19 @@ def get_sensor_variant(self): .. note:: This command is only available in idle mode. """ + ret_val = SensorVariant.MASK + mask = int(ret_val) raw_sensor_variant = self.scd4x.get_sensor_variant_raw() - variant = raw_sensor_variant & 4 - if variant == 0: - return SensorVariant.SCD40 - elif variant == 1: - return SensorVariant.SCD41 - return SensorVariant.UNKNOWN + my_sensor_variant = int(raw_sensor_variant & mask) + if my_sensor_variant == int(SensorVariant.SCD40): + ret_val = SensorVariant.SCD40 + elif my_sensor_variant == int(SensorVariant.SCD41): + ret_val = SensorVariant.SCD41 + elif my_sensor_variant == int(SensorVariant.SCD42): + ret_val = SensorVariant.SCD42 + elif my_sensor_variant == int(SensorVariant.SCD43): + ret_val = SensorVariant.SCD43 + return ret_val def measure_and_read_single_shot(self): """