drivers.SEN66.adafruit_sen6x.DeviceStatus¶
- class drivers.SEN66.adafruit_sen6x.DeviceStatus(status_data: int)¶
Parsed view of the SEN6x 32-bit device status register.
The Sensirion SEN6x devices expose a single 32-bit status word via command
0xD206(device_status). The lower 16 bits hold error flags (fan, PM, gas, RH+T, CO2-1, CO2-2, HCHO) and the upper 16 bits hold warnings (currently only fan-speed). All flags are sticky until cleared by0xD210(clear_device_status) or a sensor reset. This helper exposes each bit as a typed property and offers convenience aggregateserrorsandwarnings.- Variables:
_status (
int) – The raw 32-bit status register value as returned by the sensor; not part of the public API but accessed by every flag property below.
Example
>>> status = DeviceStatus(0x00000010) >>> status.fan_error True
Wrap a raw 32-bit status word in a typed accessor object.
- Parameters:
status_data (
int) – 32-bit status register value as returned by Sensirion command0xD206(device_status) — upper 16 bits are warnings, lower 16 bits are errors.- Returns:
None
- Raises:
None – The constructor only stores the value.
Example
>>> DeviceStatus(0).errors False
Note
The bit layout follows the Sensirion SEN6x datasheet; see the
_STATUS_*constants at the top of the module for the per-bit positions.- __str__() str¶
Render the active warnings and errors as a human string.
- Parameters:
None
- Returns:
"Status: OK"when no flags are set, otherwise"Status: <flag>, <flag>, ..."listing each active warning and error bit in turn (for example"Status: PM Error, Fan Error").- Return type:
- Raises:
None –
Example
>>> str(DeviceStatus(0)) 'Status: OK' >>> str(DeviceStatus(1 << 4)) 'Status: Fan Error'
Note
Reads the same
_STATUS_*bits as the boolean properties; no extra I2C traffic is performed.
- property co2_sensor_1_error: bool¶
Whether the CO2-1 error bit is set (SEN68 only).
- Parameters:
None
- Returns:
Truewhen the SEN68’s primary CO2 sensor is in an error state; CO2 readings should be considered unreliable while this is set.- Return type:
- Raises:
None –
Example
>>> DeviceStatus(1 << 12).co2_sensor_1_error True
Note
Sticky error bit
_STATUS_CO2_1_ERROR(bit 12); cleared only by command0xD210(clear_device_status) or a sensor reset.
- property co2_sensor_2_error: bool¶
Whether the CO2-2 error bit is set (SEN66 only).
- Parameters:
None
- Returns:
Truewhen the SEN66 CO2 sensor reports a fault; CO2 values, and the RH+T compensation that depends on them, should be considered unreliable.- Return type:
- Raises:
None –
Example
>>> DeviceStatus(1 << 9).co2_sensor_2_error True
Note
Sticky error bit
_STATUS_CO2_2_ERROR(bit 9); cleared only by command0xD210(clear_device_status) or a sensor reset.
- property errors: bool¶
Whether any of the SEN6x error bits are currently set.
- Parameters:
None
- Returns:
Truewhen at least one of the CO2-1, PM, HCHO, CO2-2, gas, RH+T, or fan error bits is set in the device status register.- Return type:
- Raises:
None –
Example
>>> DeviceStatus(1 << 4).errors True
Note
Aggregates the same
_STATUS_*bits exposed by the individual properties above; based on the response of Sensirion command0xD206.
- property fan_error: bool¶
Whether the fan-blocked/broken error bit is set.
- Parameters:
None
- Returns:
Truewhen the sensor has commanded the fan on but measured 0 RPM for multiple consecutive intervals; in this state all measurements should be considered unreliable.- Return type:
- Raises:
None –
Example
>>> DeviceStatus(1 << 4).fan_error True
Note
Sticky error bit
_STATUS_FAN_ERROR(bit 4) of the0xD206device_status register.
- property gas_sensor_error: bool¶
Whether the VOC/NOx gas-sensor error bit is set.
- Parameters:
None
- Returns:
Truewhen the gas-sensor block (SEN65, SEN66, SEN68) reports a fault; both the VOC index and NOx index should be treated as unreliable.- Return type:
- Raises:
None –
Example
>>> DeviceStatus(1 << 7).gas_sensor_error True
Note
Sticky error bit
_STATUS_GAS_ERROR(bit 7) from the register read via command0xD206.
- property hcho_sensor_error: bool¶
Whether the formaldehyde (HCHO) error bit is set (SEN68 only).
- Parameters:
None
- Returns:
Trueif the SEN68 formaldehyde channel is in an error state; HCHO readings should be treated as unreliable.- Return type:
- Raises:
None –
Example
>>> DeviceStatus(1 << 10).hcho_sensor_error True
Note
Sticky error bit
_STATUS_HCHO_ERROR(bit 10); the SEN66 hardware does not expose HCHO so this bit will stayFalsein normal operation on a SEN66.
- property pm_sensor_error: bool¶
Whether the particulate-matter error bit is set.
- Parameters:
None
- Returns:
Truewhen the PM sensor (SEN63C, SEN65, SEN66, SEN68) reports an internal fault; PM mass concentrations and the RH+T compensation that depends on them should be treated as unreliable.- Return type:
- Raises:
None –
Example
>>> DeviceStatus(1 << 11).pm_sensor_error True
Note
Sticky error bit
_STATUS_PM_ERROR(bit 11) in the device-status register from command0xD206.
- property rht_sensor_error: bool¶
Whether the humidity/temperature error bit is set.
- Parameters:
None
- Returns:
Truewhen the on-board SHT-style RH+T sensor (SEN63C, SEN65, SEN66, SEN68) reports a fault; humidity and temperature should be treated as unreliable, and the compensation of the other channels degrades.- Return type:
- Raises:
None –
Example
>>> DeviceStatus(1 << 6).rht_sensor_error True
Note
Sticky error bit
_STATUS_RHT_ERROR(bit 6); cleared by command0xD210(clear_device_status) or reset.
- property speed_warning: bool¶
Whether the fan-speed warning bit is currently set.
- Parameters:
None
- Returns:
Truewhen fan speed is outside the spec range and the sensor has raised the speed warning bit.- Return type:
- Raises:
None –
Example
>>> DeviceStatus(1 << 21).speed_warning True
Note
Backed by bit
_STATUS_SPEED_WARNING(bit 21) of the status word from command0xD206.
- property warnings: bool¶
Whether any warning bits are currently set in the status word.
- Parameters:
None
- Returns:
Truewhen at least one warning bit is set. Today only the fan speed warning (bit_STATUS_SPEED_WARNING= 21) exists, so this is effectively a thin alias forspeed_warning.- Return type:
- Raises:
None –
Example
>>> DeviceStatus(1 << 21).warnings True
Note
Backed by the upper 16 bits of the status word returned by command
0xD206(device_status).