environment2 2.0.0.0
environment2.h File Reference

This file contains API for Environment 2 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  environment2_t
 Environment 2 Click context object. More...
 
struct  environment2_cfg_t
 Environment 2 Click configuration object. More...
 
struct  environment2_voc_algorithm_params
 Environment 2 Click VOC algorithm object. More...
 

Macros

#define ENVIRONMENT2_SGP40_CMD_MEASURE_RAW   0x260F
 Environment 2 SGP40 description commands.
 
#define ENVIRONMENT2_SGP40_CMD_MEASURE_TEST   0x280E
 
#define ENVIRONMENT2_SGP40_CMD_HEATER_OFF   0x3615
 
#define ENVIRONMENT2_SGP40_CMD_SOFT_RESET   0x0006
 
#define ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_HIGH_PRECISION   0xFD
 Environment 2 SHT40 description commands.
 
#define ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_MEDIUM_PRECISION   0xF6
 
#define ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_LOWEST_PRECISION   0xE0
 
#define ENVIRONMENT2_SHT40_CMD_READ_SERIAL   0x89
 
#define ENVIRONMENT2_SHT40_CMD_SOFT_RESET   0x94
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_HIGHEST_HEATER_1SEC   0x39
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_HIGHEST_HEATER_0_1SEC   0x32
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_MEDIUM_HEATER_1SEC   0x2F
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_MEDIUM_HEATER_0_1SEC   0x24
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_LOWEST_HEATER_1SEC   0x1E
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_LOWEST_HEATER_0_1SEC   0x15
 
#define ENVIRONMENT2_SGP40_SET_DEV_ADDR   0x59
 Environment 2 device address setting.
 
#define ENVIRONMENT2_SHT40_SET_DEV_ADDR   0x44
 
#define ENVIRONMENT2_SEL_SGP40   0x00
 Environment 2 device selection.
 
#define ENVIRONMENT2_SEL_SHT40   0x01
 
#define F16(x)    ((fix16_t)(((x) >= 0) ? ((x)*65536.0 + 0.5) : ((x)*65536.0 - 0.5)))
 Environment 2 fixed point arithmetic parts.
 
#define VocAlgorithm_SAMPLING_INTERVAL   (1.)
 
#define VocAlgorithm_INITIAL_BLACKOUT   (45.)
 
#define VocAlgorithm_VOC_INDEX_GAIN   (230.)
 
#define VocAlgorithm_SRAW_STD_INITIAL   (50.)
 
#define VocAlgorithm_SRAW_STD_BONUS   (220.)
 
#define VocAlgorithm_TAU_MEAN_VARIANCE_HOURS   (12.)
 
#define VocAlgorithm_TAU_INITIAL_MEAN   (20.)
 
#define VocAlgorithm_INIT_DURATION_MEAN   ((3600. * 0.75))
 
#define VocAlgorithm_INIT_TRANSITION_MEAN   (0.01)
 
#define VocAlgorithm_TAU_INITIAL_VARIANCE   (2500.)
 
#define VocAlgorithm_INIT_DURATION_VARIANCE   ((3600. * 1.45))
 
#define VocAlgorithm_INIT_TRANSITION_VARIANCE   (0.01)
 
#define VocAlgorithm_GATING_THRESHOLD   (340.)
 
#define VocAlgorithm_GATING_THRESHOLD_INITIAL   (510.)
 
#define VocAlgorithm_GATING_THRESHOLD_TRANSITION   (0.09)
 
#define VocAlgorithm_GATING_MAX_DURATION_MINUTES   ((60. * 3.))
 
#define VocAlgorithm_GATING_MAX_RATIO   (0.3)
 
#define VocAlgorithm_SIGMOID_L   (500.)
 
#define VocAlgorithm_SIGMOID_K   (-0.0065)
 
#define VocAlgorithm_SIGMOID_X0   (213.)
 
#define VocAlgorithm_VOC_INDEX_OFFSET_DEFAULT   (100.)
 
#define VocAlgorithm_LP_TAU_FAST   (20.0)
 
#define VocAlgorithm_LP_TAU_SLOW   (500.0)
 
#define VocAlgorithm_LP_ALPHA   (-0.2)
 
#define VocAlgorithm_PERSISTENCE_UPTIME_GAMMA   ((3. * 3600.))
 
#define VocAlgorithm_MEAN_VARIANCE_ESTIMATOR__GAMMA_SCALING   (64.)
 
#define VocAlgorithm_MEAN_VARIANCE_ESTIMATOR__FIX16_MAX   (32767.)
 
#define ENVIRONMENT2_SGP40_TEST_PASSED   0xD400
 Environment 2 SGP40 description setting.
 
#define ENVIRONMENT2_SGP40_TEST_FAILED   0x4B00
 
#define ENVIRONMENT2_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Typedefs

typedef int32_t fix16_t
 

Enumerations

enum  environment2_return_value_t { ENVIRONMENT2_OK = 0 , ENVIRONMENT2_ERROR = -1 }
 Environment 2 Click return value data. More...
 

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

This file contains API for Environment 2 Click Driver.

Typedef Documentation

◆ fix16_t

typedef int32_t fix16_t

Enumeration Type Documentation

◆ environment2_return_value_t

Environment 2 Click return value data.

Predefined enum values for driver return values.

Enumerator
ENVIRONMENT2_OK 
ENVIRONMENT2_ERROR