Source code for sensirion_i2c_sgp43.device

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2026 Sensirion AG, Switzerland
#
#     THIS FILE IS AUTOMATICALLY GENERATED!
#
# Generator:     sensirion-driver-generator 1.6.0
# Product:       sgp43
# Model-Version: 3.2.0
#
"""
The class Sgp43DeviceBase implements the low level interface of the sensor.
The class Sgp43Device extends the Sgp43DeviceBase. It provides additional functions to ease the use of the
sensor.
"""

from sensirion_driver_adapters.transfer import execute_transfer
from sensirion_driver_support_types.mixin_access import MixinAccess
from sensirion_i2c_sgp43.commands import (ExecuteSelfTest, GetSerialNumber, MeasureAndSetTemperatures, TurnHeaterOff)


[docs] class Sgp43DeviceBase: """Low level API implementation of SGP43"""
[docs] def __init__(self, channel): self._channel = channel
@property def channel(self): return self._channel
[docs] def measure_and_set_temperatures(self, temperature_px1, temperature_px2, temperature_px3, temperature_px4): """ This command measures raw signals of pixel 1-4, then sets the temperatures, and returns the measured raw signals of pixel 1-4. :param temperature_px1: temperature (in °C) to set on pixel 1 :param temperature_px2: temperature (in °C) to set on pixel 2 :param temperature_px3: temperature (in °C) to set on pixel 3 :param temperature_px4: temperature (in °C) to set on pixel 4 :return sraw_px1: measured raw signal of pixel 1 :return sraw_px2: measured raw signal of pixel 2 :return sraw_px3: measured raw signal of pixel 3 :return sraw_px4: measured raw signal of pixel 4 """ transfer = MeasureAndSetTemperatures(temperature_px1, temperature_px2, temperature_px3, temperature_px4) return execute_transfer(self._channel, transfer)
[docs] def execute_self_test(self): """ This command triggers the built-in self-test checking for integrity of both hotplate and MOX material and returns the result of this test as 2 bytes :return test_result: 0xXX 0xYY: ignore most significant byte 0xXX. The four least significant bits of the least significant byte 0xYY provide information if the self-test has or has not passed for each individual pixel. All zero mean all tests passed successfully. Check the datasheet for more detailed information. """ transfer = ExecuteSelfTest() return execute_transfer(self._channel, transfer)[0]
[docs] def get_serial_number(self): """ This command provides the decimal serial number of the SGP41 chip by returning 3x2 bytes. :return serial_number: 48-bit unique serial number """ transfer = GetSerialNumber() return execute_transfer(self._channel, transfer)[0]
[docs] def turn_heater_off(self): """ This command turns off all hotplates (pixels) immediately, without performing a measurement first. Subsequently, the sensor enters the idle mode. Note that this command can only be sent when the sensor is not executing any other command, it cannot be used to abort a running measurement or self-test. """ transfer = TurnHeaterOff() return execute_transfer(self._channel, transfer)
[docs] class Sgp43Device(Sgp43DeviceBase): """Driver class implementation of SGP43""" #: Access to base class sgp43 = MixinAccess()
[docs] def __init__(self, channel): super().__init__(channel)