Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*.

Expand Down
8 changes: 5 additions & 3 deletions sensirion_i2c_scd4x/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 13 additions & 6 deletions sensirion_i2c_scd4x/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
"""
Expand Down
Loading