Class XENSIV_PAS_GASIno

Inheritance Relationships

Derived Types

Class Documentation

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

Protected Attributes

TwoWire *i2c

I2C interface

HardwareSerial *uart

UART interface

uint8_t intPin

Interrupt pin

xensiv_pas_gas_t dev

XENSIV™ PAS GAS corelib object

GasType_t gasType

Sensor type (CO2 or R290)

Protected Static Attributes

static constexpr uint16_t baudrateBps = 9600

UART baud rate in bps

static constexpr uint32_t freqHz = 100000

I2C frequency in Hz