environment2 2.0.0.0
Environment 2 Click Driver

API for configuring and manipulating Environment 2 Click driver. More...

Topics

 Environment 2 Registers List
 List of registers of Environment 2 Click driver.
 
 Environment 2 Registers Settings
 Settings for registers of Environment 2 Click driver.
 
 Environment 2 MikroBUS Map
 MikroBUS pin mapping of Environment 2 Click driver.
 
 Environment2_cmd
 
 Environment2_get
 

Functions

void environment2_cfg_setup (environment2_cfg_t *cfg)
 Environment 2 configuration object setup function.
 
err_t environment2_init (environment2_t *ctx, environment2_cfg_t *cfg)
 Environment 2 initialization function.
 
err_t environment2_generic_write (environment2_t *ctx, uint8_t select_device, uint16_t cmd)
 Environment 2 I2C writing function.
 
err_t environment2_generic_read (environment2_t *ctx, uint8_t select_device, uint16_t cmd, uint8_t *rx_buf)
 Environment 2 I2C reading function.
 
err_t environment2_get_temp_hum (environment2_t *ctx, float *humidity, float *temperature)
 Environment 2 get temperature and relative humidity function.
 
err_t environment2_get_air_quality (environment2_t *ctx, uint16_t *air_quality)
 Environment 2 get air quality data function.
 
uint16_t environment2_sgp40_measure_test (environment2_t *ctx)
 Environment 2 SGP40 measurement test function.
 
err_t environment2_sgp40_heater_off (environment2_t *ctx)
 Environment 2 heater off function.
 
err_t environment2_sgp40_soft_reset (environment2_t *ctx)
 Environment 2 soft reset function.
 
err_t environment2_voc_algorithm_configuration (environment2_voc_algorithm_params *params)
 Environment 2 VOC algorithm configuration function.
 
err_t environment2_config_sensors (void)
 Environment 2 sensors configuration function.
 
err_t environment2_voc_algorithm_process (environment2_voc_algorithm_params *params, int32_t sraw, int32_t *voc_index)
 Environment 2 VOC algorithm process function.
 
err_t environment2_measure_voc_index_with_rh_t (environment2_t *ctx, int32_t *voc_index, int32_t *relative_humidity, int32_t *temperature)
 Environment 2 measure VOC index with relative humidity and temperature function.
 
err_t environment2_get_voc_index (environment2_t *ctx, int32_t *voc_index)
 Environment 2 get VOC index function.
 

Detailed Description

API for configuring and manipulating Environment 2 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ environment2_cfg_setup()

void environment2_cfg_setup ( environment2_cfg_t * cfg)

Environment 2 configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See environment2_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ environment2_config_sensors()

err_t environment2_config_sensors ( void )

Environment 2 sensors configuration function.

This function general performs sensors configuration and initialize VOC algorithm of the SGP40 Indoor Air Quality Sensor for VOC Measurements.

Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ environment2_generic_read()

err_t environment2_generic_read ( environment2_t * ctx,
uint8_t select_device,
uint16_t cmd,
uint8_t * rx_buf )

Environment 2 I2C reading function.

This function reads a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See environment2_t object definition for detailed explanation.
[in]select_device: Device selection.
[in]cmd: Command to be written.
[out]rx_buf: Output read data.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ environment2_generic_write()

err_t environment2_generic_write ( environment2_t * ctx,
uint8_t select_device,
uint16_t cmd )

Environment 2 I2C writing function.

This function writes a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See environment2_t object definition for detailed explanation.
[in]select_device: Device selection.
[in]cmd: Command to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ environment2_get_air_quality()

err_t environment2_get_air_quality ( environment2_t * ctx,
uint16_t * air_quality )

Environment 2 get air quality data function.

This function reads a air quality SRAW data from the SGP40 Indoor Air Quality Sensor for VOC Measurements by using I2C serial interface.

Parameters
[in]ctx: Click context object. See environment2_t object definition for detailed explanation.
[out]air_quality: Air quality SRAW data.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ environment2_get_temp_hum()

err_t environment2_get_temp_hum ( environment2_t * ctx,
float * humidity,
float * temperature )

Environment 2 get temperature and relative humidity function.

This function reads a temperature and relative humidity from the SHT40 4th Generation, High-Accuracy, Ultra-Low-Power, 16-bit Relative Humidity and Temperature Sensor Platform by using I2C serial interface.

Parameters
[in]ctx: Click context object. See environment2_t object definition for detailed explanation.
[out]humidity: Relative Humidity [ RH ].
[out]temperature: Temperature [ degree Celsius ].
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ environment2_get_voc_index()

err_t environment2_get_voc_index ( environment2_t * ctx,
int32_t * voc_index )

Environment 2 get VOC index function.

This function measurement triggers a humidity reading, sets the value on the SGP for humidity compensation and runs the gas signal through the VOC algorithm for the final result.

Parameters
[in]ctx: Click context object. See environment2_t object definition for detailed explanation.
[out]voc_index: Pointer to buffer for measured VOC index. Range 0..500.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ environment2_init()

err_t environment2_init ( environment2_t * ctx,
environment2_cfg_t * cfg )

Environment 2 initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See environment2_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See environment2_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ environment2_measure_voc_index_with_rh_t()

err_t environment2_measure_voc_index_with_rh_t ( environment2_t * ctx,
int32_t * voc_index,
int32_t * relative_humidity,
int32_t * temperature )

Environment 2 measure VOC index with relative humidity and temperature function.

This function measure the humidity-compensated VOC Index,
ambient temperature and relative humidity.

Parameters
[in]ctx: Click context object. See environment2_t object definition for detailed explanation.
[out]voc_index: Pointer to buffer for measured VOC index. Range 0..500.
[out]relative_humidity: Relative Humidity [ milli RH ].
[out]temperature: Temperature [ milli degree Celsius ].
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ environment2_sgp40_heater_off()

err_t environment2_sgp40_heater_off ( environment2_t * ctx)

Environment 2 heater off function.

This function turns the hotplate off and stops the measurement of the SGP40 Indoor Air Quality Sensor for VOC Measurements by using I2C serial interface.

Parameters
[in]ctx: Click context object. See environment2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ environment2_sgp40_measure_test()

uint16_t environment2_sgp40_measure_test ( environment2_t * ctx)

Environment 2 SGP40 measurement test function.

This function triggers the built-in self-test checking for integrity of both hotplate and MOX materia of the SGP40 Indoor Air Quality Sensor for VOC Measurements by using I2C serial interface.

Parameters
[in]ctx: Click context object. See environment2_t object definition for detailed explanation.
Returns
Result of this test:
  • 0xD400 ( ENVIRONMENT2_SGP40_TEST_PASSED ) - All tests passed successfully,
  • 0x4B00 ( ENVIRONMENT2_SGP40_TEST_FAILED ) - One or more tests have failed.
See #err_t definition for detailed explanation.
Note
None.

◆ environment2_sgp40_soft_reset()

err_t environment2_sgp40_soft_reset ( environment2_t * ctx)

Environment 2 soft reset function.

This function general call resetting all devices connected to the same I2C bus of the SGP40 Indoor Air Quality Sensor for VOC Measurements.

Parameters
[in]ctx: Click context object. See environment2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
The first byte refers to the general call address and the second byte refers to the reset command. After calling this command, the SGP40 will restart entering the idle mode.

◆ environment2_voc_algorithm_configuration()

err_t environment2_voc_algorithm_configuration ( environment2_voc_algorithm_params * params)

Environment 2 VOC algorithm configuration function.

This function initialize VOC algorithm.

Parameters
[in]environment2_voc_algorithm_params: Struct to hold all the states of the VOC algorithm.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None

◆ environment2_voc_algorithm_process()

err_t environment2_voc_algorithm_process ( environment2_voc_algorithm_params * params,
int32_t sraw,
int32_t * voc_index )

Environment 2 VOC algorithm process function.

This function calculate the VOC index value from the raw sensor value.

Parameters
[in]ctx: Click context object. See environment2_t object definition for detailed explanation.
[in]params: Pointer to the environment2_voc_algorithm_params struct.
[in]sraw: Air quality SRAW data.
[out]voc_index: Calculated VOC index value from the raw sensor value. Zero during initial blackout period and 1..500 afterwards.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.