API Reference

Warning

This project is under development and not ready for use.

The Arduino library provides a unified API for XENSIV™ PAS Gas sensors, supporting multiple sensor types and protocols. The API is structured around a base class and sensor-specific subclasses:

Class Hierarchy:

  • XENSIV_PAS_GASIno: Base class for all PAS Gas sensors. Provides common methods for initialization, measurement, diagnostics, and register access.

  • XENSIV_PAS_GASA2LIno: Subclass for A2L-type PAS Gas sensors. Adds A2L-specific configuration and measurement functions.

  • XENSIV_PAS_GASR290Ino: Subclass for R290-type PAS Gas sensors. Adds R290-specific configuration and measurement functions.

Use the appropriate class for your sensor type to access all supported features.

XENSIV™ PAS Gas Sensors Arduino API

class XENSIV_PAS_GASIno

Subclassed by XENSIV_PAS_GASA2LIno, XENSIV_PAS_GASR290Ino

Public Functions

XENSIV_PAS_GASIno(GasType_t gasType, TwoWire *wire = &Wire, uint8_t intPin = unusedPin)

XENSIV™ PAS GAS I2C Arduino Constructor.

Parameters:
  • wire[in] TwoWire interface instance. Default is the Arduino primary Wire instance.

  • intPin[in] Interrupt pin. Default is UnusedPin

Pre:

None

XENSIV_PAS_GASIno(GasType_t gasType, HardwareSerial *serial, uint8_t intPin = unusedPin)

XENSIV™ PAS GAS UART Arduino Constructor.

Parameters:
  • serial[in] Serial interface instance

  • intPin[in] Interrupt pin. Default is UnusedPin

Pre:

None

~XENSIV_PAS_GASIno()

XENSIV™ PAS GAS Arduino Destructor.

It disables the sensor and deletes all the dynamically created PAL instances in the constructor

Pre:

None

Error_t begin()

Begins the sensor.

Initializes the serial interface if the initialization is delegated to the XENSIV_PAS_GASR290 class. Sets the I2C freq or UART baudrate to the default values prior the serial interface initialization. Initializes the interrupt pin if used.

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

None

Error_t end()

Ends the sensor.

Deinitializes the serial interface if the deinitialization is delegated to the XENSIV_PAS_GASIno class. Deinitializes the interrupt pin if used.

Return values:

XENSIV_PAS_GAS_OK – always

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t startMeasure(int16_t periodInSec = 0, int16_t alarmTh = 0, void (*cback)(void*) = nullptr, bool earlyNotification = false)

Triggers the internal measuring of the sensor.

The function start the measurement controlling the different sensor modes and features depending on the configured arguments.

Error_t stopMeasure()

Stops the internal measuring of the sensor.

Sets operation mode to idle

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t getDiagnosis(Diag_t &diagnosis)

Gets diagnosis information.

The sensor status registers includes the following flags:

  • Sensor ready

  • PWM pin enabled

  • Temperature out of range error

  • IR emitter voltage out of range error

  • Communication error which will be stored in the Diag_t struct variable passed by argument. After reading the flags, these are cleared in the device writing in the corresponding clear flag bitfields.

Parameters:

diagnosis[out] Struct to store the diagnosis flags values

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

None

Error_t setABOC(ABOC_t aboc, int16_t abocRef)

Configures the sensor automatic baseline compensation.

Parameters:
  • aboc[in] Automatic baseline compenstation mode

  • abocRef[in] Automatic baseline compensation reference

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t setPressRef(uint16_t pressRef)

Sets the sensor pressure reference.

Parameters:

pressRef[in] Pressure reference value. Min value is 750, and max 1150.

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t performForcedCompensation(uint16_t GASRef)

Performs force compensation.

Calculates the offset compensation when the sensor is exposed to a gas reference value.

Warning

The device is left in idle mode after the compensation value is stored in non-volatile memory.

Parameters:

GASRef[in] Gas reference value

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t reset()

Resets the sensor via serial command.

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t getProductID(uint8_t &prodID, uint8_t &revID)

Gets device product identifier.

Parameters:
  • prodID[out] Product identifier

  • revID[out] Version identifier

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t getRegister(uint8_t regAddr, uint8_t *data, uint8_t len)

Reads from the sensor device into the given data buffer.

Parameters:
  • regAddr[in] Start register address

  • data[out] Pointer to the data buffer to store the register values of the sensor

  • len[in] Number of bytes of data to be read

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t setRegister(uint8_t regAddr, const uint8_t *data, uint8_t len)

Writes the given data buffer into the sensor device.

Parameters:
  • regAddr[in] Start register address

  • data[in] Pointer to the data buffer to be written in the sensor

  • len[in] Number of bytes of data to be written

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t clearForcedCompensation()

Resets the forced calibration correction factor.

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t getGasConcentration(float &value)

Gets the GAS concentration measured.

The value read is zero when no measurement is yet available or an error has occurred.

Parameters:

gasRawValue[out] GAS concentration read

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

startMeasure()

const char *getGasConcentrationUnitStr()

Gets string description of the gas concentration unit.

Returns:

Pointer to the string description of the gas concentration unit

Pre:

None

const char *getPasGasErrorStr(Error_t err)

Gets string description of the error code.

Parameters:

err[in] XENSIV™ PAS GAS error code

Returns:

Pointer to the string description of the error code

Pre:

None

Public Static Attributes

static constexpr uint8_t unusedPin = 0xFFU

Unused pin

class XENSIV_PAS_GASA2LIno : public XENSIV_PAS_GASIno

Public Functions

inline XENSIV_PAS_GASA2LIno(TwoWire *wire = &Wire, uint8_t intPin = unusedPin)
inline XENSIV_PAS_GASA2LIno(HardwareSerial *serial, uint8_t intPin = unusedPin)
~XENSIV_PAS_GASA2LIno()

Destructor of the XENSIV_PAS_GASA2LIno class.

Error_t getDeviceID(uint8_t &devID)

Gets device product identifier.

Parameters:

devID[out] Device identifier

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t getAlarmConfig(bool &activeHigh)

Gets the alarm pin configuration.

Parameters:

activeHigh[out] true for active high, false for active low

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t getABOCCycle(uint8_t &days)

Gets the ABOC cycle in days.

Parameters:

days[out] ABOC cycle in days (7 to 70 days)

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t setABOCCycle(uint8_t days)

Sets the ABOC cycle in days.

Parameters:

days[in] ABOC cycle in days (7 to 70 days)

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t setABOCPrefill(uint8_t hours)

Sets the ABOC prefill value (in hours)

Prefills the ABOC flash table to shorten the current ABOC cycle. The value is capped at (ABOC cycle - 1) hours.

Parameters:

hours[in] Number of hours to prefill (0 to ABOC cycle - 1)

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t getDenoiseConfig(uint8_t &smoothing_factor)

Gets the denoise configuration.

Parameters:

smoothing_factor[out]

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t setDenoiseConfig(uint8_t smoothing_factor)

Sets the denoise configuration.

Parameters:

smoothing_factor[in]

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t selfTestErrorClear(bool clear)

Configures the self-test routine.

Parameters:

enable[in] true to enable, false to disable

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

String getSelfTestStatusString()

Gets a human-readable self-test status string.

Returns:

String describing self-test errors, or “Self-test passed: No errors.”

Pre:

begin()

Error_t getAlarmHysteresis(uint16_t &hysteresis)

Gets the alarm hysteresis value.

Parameters:

alarm_hys[out] Alarm hysteresis value (0–32767)

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t setAlarmHysteresis(uint16_t hysteresis)

Sets the alarm hysteresis value.

Parameters:

alarm_hys[in] Alarm hysteresis value (0–32767)

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t getAbsoluteHumidityRef(uint16_t &abs_humidity)

Gets the absolute humidity reference value.

Parameters:

abs_humidity[out] Absolute humidity reference value

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t setAbsoluteHumidityRef(uint16_t abs_humidity)

Sets the absolute humidity reference value.

Parameters:

abs_humidity[in] Absolute humidity reference value

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t enableHumidityCompensation(bool enable)

Enables or disables humidity compensation.

Parameters:

enable[in] true to enable, false to disable

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t isHumidityCompensationEnabled(bool enable)

Checks if humidity compensation is enabled.

Parameters:

enable[out] true if enabled, false otherwise

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t setGasSelection(xensiv_pas_gas_a2l_gas_selection_t gas)

Sets the gas selection (GAS_SEL field)

Parameters:

gas[in] Gas to select (enum value)

Returns:

XENSIV™ PAS GAS error code

Error_t getGasSelection(xensiv_pas_gas_a2l_gas_selection_t &gas)

Gets the current gas selection (GAS_SEL field)

Parameters:

gas[out] Gas selection (enum value)

Returns:

XENSIV™ PAS GAS error code

Error_t getAvailableGases(uint8_t &gas_avail)

Gets the available gases bitmap (GAS_AVAIL field, bits 7:4)

Parameters:

gas_avail[out] Bitmap of available gases (bits 7:4)

Returns:

XENSIV™ PAS GAS error code

class XENSIV_PAS_GASR290Ino : public XENSIV_PAS_GASIno

Public Functions

inline XENSIV_PAS_GASR290Ino(TwoWire *wire = &Wire, uint8_t intPin = unusedPin)
inline XENSIV_PAS_GASR290Ino(HardwareSerial *serial, uint8_t intPin = unusedPin)
~XENSIV_PAS_GASR290Ino()

Destructor of the XENSIV_PAS_GASR290Ino class.

Error_t getDeviceID(uint8_t &devID)

Gets device product identifier.

Parameters:

devID[out] Device identifier

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t getAlarmConfig(bool &activeHigh)

Gets the alarm pin configuration.

Parameters:

activeHigh[out] true for active high, false for active low

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t getABOCCycle(uint8_t &days)

Gets the ABOC cycle in days.

Parameters:

days[out] ABOC cycle in days (7 to 70 days)

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t setABOCCycle(uint8_t days)

Sets the ABOC cycle in days.

Parameters:

days[in] ABOC cycle in days (7 to 70 days)

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t setABOCPrefill(uint8_t hours)

Sets the ABOC prefill value (in hours)

Prefills the ABOC flash table to shorten the current ABOC cycle. The value is capped at (ABOC cycle - 1) hours.

Parameters:

hours[in] Number of hours to prefill (0 to ABOC cycle - 1)

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t getDenoiseConfig(uint8_t &smoothing_factor)

Gets the denoise configuration.

Parameters:

smoothing_factor[out]

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t setDenoiseConfig(uint8_t smoothing_factor)

Sets the denoise configuration.

Parameters:

smoothing_factor[in]

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

Error_t selfTestErrorClear(bool clear)

Configures the self-test routine.

Parameters:

enable[in] true to enable, false to disable

Return values:

XENSIV_PAS_GAS_OK – if success

Returns:

XENSIV™ PAS GAS error code

Pre:

begin()

String getSelfTestStatusString()

Gets a human-readable self-test status string.

Returns:

String describing self-test errors, or “Self-test passed: No errors.”

Pre:

begin()

Types

Return Error Codes

typedef int32_t Error_t
XENSIV_PAS_GAS_OK

Result code indicating a successful operation

XENSIV_PAS_GAS_ERR_COMM

Result code indicating a communication error

XENSIV_PAS_GAS_ERR_WRITE_TOO_LARGE

Result code indicating that an unexpectedly large I2C write was requested which is not supported

XENSIV_PAS_GAS_ERR_NOT_READY

Result code indicating that the sensor is not yet ready after reset

XENSIV_PAS_GAS_ICCERR

Result code indicating whether a non-valid command has been received by the serial communication interface

XENSIV_PAS_GAS_ORVS

Result code indicating whether a condition where VDD5V has been outside the specified valid range has been detected

XENSIV_PAS_GAS_ORTMP

Result code indicating whether a condition where the temperature has been outside the specified valid range has been detected

XENSIV_PAS_GAS_READ_NRDY

Result code indicating that a new GAS value is not yet ready

XENSIV_PAS_GAS_INVALID_SENSOR_INTERFACE

Result code indicating that an invalid sensor interface was selected Result code indicating that an invalid parameter was passed to a function

XENSIV_PAS_GAS_INVALID_PARAMETER

Diagnosis

typedef xensiv_pas_gas_status_t Diag_t
union xensiv_pas_gas_status_t
#include <xensiv_pas_gas.h>

Structure of the sensor’s status register (SENS_STS)

Public Members

uint32_t __pad0__
uint32_t iccerr

Communication error notification bit. Indicates whether an invalid command has been received by the serial communication interface

uint32_t orvs

Out-of-range VDD5V error bit

uint32_t ortmp

Out-of-range temperature error bit

uint32_t __pad1__

Reserved (usage depends on variant)

struct xensiv_pas_gas_status_t::[anonymous] b

Structure used for bit access

uint8_t u

Type used for byte access

Baseline Offset Compensation

typedef xensiv_pas_gas_boc_cfg_t ABOC_t
enum xensiv_pas_gas_boc_cfg_t

Enum defining the different device baseline offset compensation (BOC) modes

Values:

enumerator XENSIV_PAS_GAS_BOC_CFG_DISABLE

No offset compensation occurs

enumerator XENSIV_PAS_GAS_BOC_CFG_AUTOMATIC

The offset is periodically updated at each BOC computation

enumerator XENSIV_PAS_GAS_BOC_CFG_FORCED

Forced compensation

XENSIV™ PAS Gas Sensors C Reference API

The Arduino library is wrapping the platform abstracted C library from this project.