environment3 2.0.0.0
Environment 3 Click Driver

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

Topics

 Environment 3 Registers List
 List of registers of Environment 3 Click driver.
 
 Environment 3 Registers Settings
 Settings for registers of Environment 3 Click driver.
 
 Environment 3 MikroBUS Map
 MikroBUS pin mapping of Environment 3 Click driver.
 

Functions

void environment3_cfg_setup (environment3_cfg_t *cfg)
 Environment 3 configuration object setup function.
 
void environment3_drv_interface_selection (environment3_cfg_t *cfg, environment3_drv_t drv_sel)
 Environment 3 driver interface setup function.
 
err_t environment3_init (environment3_t *ctx, environment3_cfg_t *cfg)
 Environment 3 initialization function.
 
err_t environment3_default_cfg (environment3_t *ctx)
 Environment 3 default configuration function.
 
err_t environment3_generic_write (environment3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Environment 3 data writing function.
 
err_t environment3_generic_read (environment3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Environment 3 data reading function.
 
err_t environment3_write_byte (environment3_t *ctx, uint8_t reg, uint8_t data_in)
 Environment 3 single data writing function.
 
uint8_t environment3_read_byte (environment3_t *ctx, uint8_t reg)
 Environment 3 single data reading function.
 
int8_t environment3_check_id (environment3_t *ctx)
 Environment 3 check device ID function.
 
uint8_t environment3_get_device_id (environment3_t *ctx)
 Environment 3 get device ID function.
 
int8_t environment3_soft_reset (environment3_t *ctx)
 Environment 3 soft reset function.
 
int8_t environment3_get_all_data (environment3_t *ctx, float *temp, float *hum, float *pres, uint32_t *gas)
 Environment 3 get all data function.
 
float environment3_get_temperature (environment3_t *ctx)
 Environment 3 get temperature data function.
 
float environment3_get_humidity (environment3_t *ctx)
 Environment 3 get humidity data function.
 
float environment3_get_pressure (environment3_t *ctx)
 Environment 3 get pressure data function.
 
float environment3_get_gas_resistance (environment3_t *ctx)
 Environment 3 get gas resistance data function.
 
int8_t environment3_get_regs (environment3_t *ctx, uint8_t reg, uint8_t *data_out, uint16_t len)
 Environment 3 read data from register address function.
 
int8_t environment3_set_regs (environment3_t *ctx, uint8_t *reg, uint8_t *data_in, uint8_t len)
 Environment 3 write data to registers function.
 
int8_t environment3_enable_heater (environment3_t *ctx, uint8_t state)
 Environment 3 enable heater function.
 
int8_t environment3_set_heater_conf (environment3_t *ctx, environment3_gas_settings_t *conf)
 Environment 3 set heater configuration function.
 
int8_t environment3_set_sensor_conf (environment3_t *ctx, environment3_tph_settings_t *conf)
 Environment 3 set sensor configuration function.
 
int8_t environment3_set_operating_mode (environment3_t *ctx, uint8_t op_mode)
 Environment 3 set operating mode function.
 
int8_t environment3_get_operating_mode (environment3_t *ctx)
 Environment 3 get operating mode function.
 

Detailed Description

API for configuring and manipulating Environment 3 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

◆ environment3_cfg_setup()

void environment3_cfg_setup ( environment3_cfg_t * cfg)

Environment 3 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ environment3_check_id()

int8_t environment3_check_id ( environment3_t * ctx)

Environment 3 check device ID function.

This function checks the device ID.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
Returns
  • 0 - ID correct,
  • -1 - Wrong ID read.
Note
None.

◆ environment3_default_cfg()

err_t environment3_default_cfg ( environment3_t * ctx)

Environment 3 default configuration function.

This function executes a default configuration of Environment 3 click board.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ environment3_drv_interface_selection()

void environment3_drv_interface_selection ( environment3_cfg_t * cfg,
environment3_drv_t drv_sel )

Environment 3 driver interface setup function.

This function sets a serial driver interface which will be used further in the click driver.

Parameters
[out]cfg: Click configuration structure. See environment3_cfg_t object definition for detailed explanation.
[in]drv_sel: Driver interface selection. See environment3_drv_t object definition for detailed explanation.
Returns
Nothing.
Note
This driver selection should be call before init function to configure the driver to work with the serial interface which is consistent with the real state of the hardware. If this function is not called, the default driver interface will be set.

◆ environment3_enable_heater()

int8_t environment3_enable_heater ( environment3_t * ctx,
uint8_t state )

Environment 3 enable heater function.

This function enables or disables the gas sensor heater.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[in]state: 1 - Enable, 0 - Disable.
Returns
  • 0 - Success,
  • -1 - Error.
  • -2 - Communication fail.
Note
None.

◆ environment3_generic_read()

err_t environment3_generic_read ( environment3_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

Environment 3 data reading function.

This function reads a desired number of data bytes starting from the selected register.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ environment3_generic_write()

err_t environment3_generic_write ( environment3_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

Environment 3 data writing function.

This function writes a desired number of data bytes starting from the selected register.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Data to be written.
[in]len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ environment3_get_all_data()

int8_t environment3_get_all_data ( environment3_t * ctx,
float * temp,
float * hum,
float * pres,
uint32_t * gas )

Environment 3 get all data function.

This function reads the temperature, humidity, pressure, and gas resistance data from the sensor.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[out]temp: Temperature value in Celsius.
[out]hum: Temperature value in Percents.
[out]pres: Pressure value in mBar.
[out]gas: Gas resistance value in Ohms.
Returns
  • 2 - No new data.
  • 0 - Success,
  • -1 - Error.
Note
None.

◆ environment3_get_device_id()

uint8_t environment3_get_device_id ( environment3_t * ctx)

Environment 3 get device ID function.

This function gets the device ID.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
Returns
Device ID.
Note
None.

◆ environment3_get_gas_resistance()

float environment3_get_gas_resistance ( environment3_t * ctx)

Environment 3 get gas resistance data function.

This function reads the gas resistance from the sensor.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
Returns
  • 2.0 - No new data.
  • -1.0 - Error.
  • - Gas resistance value in Ohms.
Note
None.

◆ environment3_get_humidity()

float environment3_get_humidity ( environment3_t * ctx)

Environment 3 get humidity data function.

This function reads the humidity from the sensor.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
Returns
  • 2.0 - No new data.
  • -1.0 - Error.
  • - Humidity value in Percents.
Note
None.

◆ environment3_get_operating_mode()

int8_t environment3_get_operating_mode ( environment3_t * ctx)

Environment 3 get operating mode function.

This function gets the operating mode of the sensor.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[in]op_mode: 0 - SLEEP, 1 - FORCED.
Returns
  • -1 - Error.
  • - Operating mode.
Note
None.

◆ environment3_get_pressure()

float environment3_get_pressure ( environment3_t * ctx)

Environment 3 get pressure data function.

This function reads the pressure from the sensor.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
Returns
  • 2.0 - No new data.
  • -1.0 - Error.
  • - Pressure value in mBar.
Note
None.

◆ environment3_get_regs()

int8_t environment3_get_regs ( environment3_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint16_t len )

Environment 3 read data from register address function.

This function reads the desired number of data bytes starting from the given register address of sensor.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
  • -2 - Communication fail.
Note
None.

◆ environment3_get_temperature()

float environment3_get_temperature ( environment3_t * ctx)

Environment 3 get temperature data function.

This function reads the temperature from the sensor.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
Returns
  • 2.0 - No new data.
  • -1.0 - Error.
  • - Temperature value in Celsius.
Note
None.

◆ environment3_init()

err_t environment3_init ( environment3_t * ctx,
environment3_cfg_t * cfg )

Environment 3 initialization function.

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

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

◆ environment3_read_byte()

uint8_t environment3_read_byte ( environment3_t * ctx,
uint8_t reg )

Environment 3 single data reading function.

This function reads a single data byte from the selected register.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[in]reg: Start register address.
Returns
Read data byte.
Note
None.

◆ environment3_set_heater_conf()

int8_t environment3_set_heater_conf ( environment3_t * ctx,
environment3_gas_settings_t * conf )

Environment 3 set heater configuration function.

This function sets the gas configuration of the sensor.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[in]conf: Gas setting object. See environment3_gas_settings_t gas setting object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
  • -2 - Communication fail.
Note
None.

◆ environment3_set_operating_mode()

int8_t environment3_set_operating_mode ( environment3_t * ctx,
uint8_t op_mode )

Environment 3 set operating mode function.

This function sets the operating mode of the sensor ( FORCED or SLEEP ).

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[in]op_mode: 0 - SLEEP, 1 - FORCED.
Returns
  • 0 - Success,
  • -1 - Error.
  • -2 - Communication fail.
Note
None.

◆ environment3_set_regs()

int8_t environment3_set_regs ( environment3_t * ctx,
uint8_t * reg,
uint8_t * data_in,
uint8_t len )

Environment 3 write data to registers function.

This function writes the desired number of data bytes to registers starting from the given register address of sensor.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[in]reg: Array of registers addresses.
[in]data_in: Array of data to be written.
[in]len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error.
  • -2 - Communication fail.
  • -3 - Invalid length.
Note
The length of reg and data_in arrays must be the same.

◆ environment3_set_sensor_conf()

int8_t environment3_set_sensor_conf ( environment3_t * ctx,
environment3_tph_settings_t * conf )

Environment 3 set sensor configuration function.

This function sets the oversampling, filter and odr configuration of the sensor.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[in]conf: THP setting object. See environment3_tph_settings_t TPH setting object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
  • -2 - Communication fail.
Note
None.

◆ environment3_soft_reset()

int8_t environment3_soft_reset ( environment3_t * ctx)

Environment 3 soft reset function.

This function soft-resets the sensor.

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

◆ environment3_write_byte()

err_t environment3_write_byte ( environment3_t * ctx,
uint8_t reg,
uint8_t data_in )

Environment 3 single data writing function.

This function writes a single data byte to the desired register.

Parameters
[in]ctx: Click context object. See environment3_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.