environment4 2.1.0.0
Environment 4 Click Driver

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

Topics

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

Functions

void environment4_cfg_setup (environment4_cfg_t *cfg)
 Environment 4 configuration object setup function.
 
err_t environment4_init (environment4_t *ctx, environment4_cfg_t *cfg)
 Environment 4 initialization function.
 
err_t environment4_sgp_exe_conditioning (environment4_t *ctx, uint16_t comp_rh, uint16_t comp_t, uint16_t *sraw_voc)
 Environment 4 sgp exe conditioning function.
 
err_t environment4_sgp_meas_raw_signals (environment4_t *ctx, uint16_t comp_rh, uint16_t comp_t, uint16_t *sraw_voc, uint16_t *sraw_nox)
 Environment 4 sgp meas raw signals function.
 
err_t environment4_sgp_exe_self_test (environment4_t *ctx, uint8_t *test_result)
 Environment 4 sgp exe self test function.
 
err_t environment4_sgp_turn_heater_off (environment4_t *ctx)
 Environment 4 sgp turn heater off function.
 
err_t environment4_sgp_get_serial_num (environment4_t *ctx, uint16_t *serial_num)
 Environment 4 sgp get serial num function.
 
err_t environment4_sht_send_cmd (environment4_t *ctx, uint8_t cmd)
 Environment 4 sht send cmd function.
 
err_t environment4_sht_read_response (environment4_t *ctx, uint8_t *data_out)
 Environment 4 sht read response function.
 
err_t environment4_sht_soft_reset (environment4_t *ctx)
 Environment 4 sht soft reset function.
 
err_t environment4_sht_read_serial_num (environment4_t *ctx, uint32_t *serial_num)
 Environment 4 sht read serial num function.
 
err_t environment4_sht_read_meas_hp (environment4_t *ctx, float *temp, float *hum)
 Environment 4 sht read meas hp function.
 

Detailed Description

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

◆ environment4_cfg_setup()

void environment4_cfg_setup ( environment4_cfg_t * cfg)

Environment 4 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ environment4_init()

err_t environment4_init ( environment4_t * ctx,
environment4_cfg_t * cfg )

Environment 4 initialization function.

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

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

◆ environment4_sgp_exe_conditioning()

err_t environment4_sgp_exe_conditioning ( environment4_t * ctx,
uint16_t comp_rh,
uint16_t comp_t,
uint16_t * sraw_voc )

Environment 4 sgp exe conditioning function.

This function executes conditioning command for SGP41 device by using I2C serial interface. It starts the conditioning, i.e., the VOC pixel will be operated at the same temperature as it is by calling the environment4_sgp_meas_raw_signals function while the NOx pixel will be operated at a different temperature for conditioning. This command returns only the measured raw signal of the VOC pixel SRAW_VOC as 2 bytes.

Parameters
[in]ctx: Click context object. See environment4_t object definition for detailed explanation.
[in]comp_rh: Leaves humidity compensation disabled by sending the default value 0x8000 (50RH) or enabled humidity compensation when sending the relative humidity in ticks (ticks = RH * 65535 / 100)
[in]comp_t: Leaves humidity compensation disabled by sending the default value 0x6666 (25 degC) or enabled humidity compensation when sending the temperature in ticks (ticks = (degC + 45) * 65535 / 175)
[out]sraw_voc: u16 unsigned integer directly provides the raw signal SRAW_VOC in ticks which is proportional to the logarithm of the resistance of the sensing element.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ environment4_sgp_exe_self_test()

err_t environment4_sgp_exe_self_test ( environment4_t * ctx,
uint8_t * test_result )

Environment 4 sgp exe self test function.

This function triggers the SGP41 device built-in self-test checking for integrity of both hotplate and MOX material and returns the result of this test as 1 byte (only 2 least significant bits are valid).

Parameters
[in]ctx: Click context object. See environment4_t object definition for detailed explanation.
[out]test_result:
  • 0 - OK,
  • 1 - VOC pixel fail,
  • 2 - NOx pixel fail,
  • 3 - Both VOC and NOx pixels fail.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ environment4_sgp_get_serial_num()

err_t environment4_sgp_get_serial_num ( environment4_t * ctx,
uint16_t * serial_num )

Environment 4 sgp get serial num function.

This function provides the decimal serial number of the SGP41 chip by returning 3x2 bytes.

Parameters
[in]ctx: Click context object. See environment4_t object definition for detailed explanation.
[out]serial_num: 48-bit unique serial number.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ environment4_sgp_meas_raw_signals()

err_t environment4_sgp_meas_raw_signals ( environment4_t * ctx,
uint16_t comp_rh,
uint16_t comp_t,
uint16_t * sraw_voc,
uint16_t * sraw_nox )

Environment 4 sgp meas raw signals function.

This function measures raw signals for SGP41 device by using I2C serial interface. It starts/continues the VOC + NOx measurement mode.

Parameters
[in]ctx: Click context object. See environment4_t object definition for detailed explanation.
[in]comp_rh: Leaves humidity compensation disabled by sending the default value 0x8000 (50RH) or enabled humidity compensation when sending the relative humidity in ticks (ticks = RH * 65535 / 100)
[in]comp_t: Leaves humidity compensation disabled by sending the default value 0x6666 (25 degC) or enabled humidity compensation when sending the temperature in ticks (ticks = (degC + 45) * 65535 / 175)
[out]sraw_voc: u16 unsigned integer directly provides the raw signal SRAW_VOC in ticks which is proportional to the logarithm of the resistance of the sensing element.
[out]sraw_nox: u16 unsigned integer directly provides the raw signal SRAW_NOX in ticks which is proportional to the logarithm of the resistance of the sensing element.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ environment4_sgp_turn_heater_off()

err_t environment4_sgp_turn_heater_off ( environment4_t * ctx)

Environment 4 sgp turn heater off function.

This function turns the hotplate off and stops the measurement for the SGP41 device. Subsequently, the sensor enters the idle mode.

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

◆ environment4_sht_read_meas_hp()

err_t environment4_sht_read_meas_hp ( environment4_t * ctx,
float * temp,
float * hum )

Environment 4 sht read meas hp function.

This function reads the temperature and humidity measurements with high precision from SHT41A device.

Parameters
[in]ctx: Click context object. See environment4_t object definition for detailed explanation.
[out]temp: Temperature in degrees Celsius.
[out]hum: Relative humidity in percents.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ environment4_sht_read_response()

err_t environment4_sht_read_response ( environment4_t * ctx,
uint8_t * data_out )

Environment 4 sht read response function.

This function reads 6 response bytes from SHT41A device to the previously sent command by using I2C serial interface.

Parameters
[in]ctx: Click context object. See environment4_t object definition for detailed explanation.
[out]data_out: 6 response bytes.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ environment4_sht_read_serial_num()

err_t environment4_sht_read_serial_num ( environment4_t * ctx,
uint32_t * serial_num )

Environment 4 sht read serial num function.

This function reads the 4-bytes unique serial number from SHT41A device by using I2C serial interface.

Parameters
[in]ctx: Click context object. See environment4_t object definition for detailed explanation.
[out]serial_num: 4-bytes unique serial number.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ environment4_sht_send_cmd()

err_t environment4_sht_send_cmd ( environment4_t * ctx,
uint8_t cmd )

Environment 4 sht send cmd function.

This function sends the selected command byte to SHT41A device by using I2C serial interface.

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

◆ environment4_sht_soft_reset()

err_t environment4_sht_soft_reset ( environment4_t * ctx)

Environment 4 sht soft reset function.

This function performs the software reset by sending the soft reset command to SHT41A device.

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