All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Sensirion Embedded I2C SEN5x Driver

Driver for I2C communication to SEN5x devices. More...

Detailed Description

Driver for I2C communication to SEN5x devices.

Files

file  sen5x.h
 
file  sen5x_constants.h
 Internal addresses, registers and constants.
 
file  sen5x_params.h
 Default configuration for SEN50/54/55.
 

Data Structures

struct  sen5x_measurement_t
 Wrapper for measured values. More...
 
struct  sen5x_params_t
 Device initialization parameters. More...
 
struct  sen5x_t
 Device descriptor for the driver. More...
 

Functions

int sen5x_init (sen5x_t *dev, const sen5x_params_t *params)
 Initialize the given device.
 
int sen5x_reset (const sen5x_t *dev)
 Execute a reset on the given device.
 
void sen5x_wake (const sen5x_t *dev)
 Starts a continuous measurement.
 
void sen5x_wake_no_pm (const sen5x_t *dev)
 Starts a continuous measurement without PM.
 
void sen5x_sleep (const sen5x_t *dev)
 Stops the measurement and returns to idle mode.
 
void sen5x_clean_fan (const sen5x_t *dev)
 Sets the fan to maximum speed, to clean it within 10 seconds.
 
bool sen5x_data_ready_flag (const sen5x_t *dev)
 Sets the fan to maximum speed, to clean it within 10 seconds.
 
void sen5x_read_values (const sen5x_t *dev, sen5x_measurement_t *values)
 Read measured mass concentration, humidity and temperature values.
 
void sen5x_read_pm_values (const sen5x_t *dev, sen5x_measurement_t *values)
 Read measured particle matter values.
 
void sen5x_set_temperature_offset (const sen5x_t *dev, int16_t temp_offset, int16_t slope, uint16_t time_constant)
 Set a custom temperature offset to the ambient temperature.
 
void sen5x_get_temperature_offset (const sen5x_t *dev, int16_t *temp_offset, int16_t *slope, uint16_t *time_constant)
 Set a custom temperature offset to the ambient temperature.
 
void sen5x_set_warm_start (const sen5x_t *dev, uint16_t warm_start)
 Set the parameter for a warm start on the device, to improve initial accuracy of the ambient temperature output.
 
void sen5x_get_warm_start (const sen5x_t *dev, uint16_t *warm_start)
 Get the warm start parameter.
 
void sen5x_set_voc_algorithm_tuning (const sen5x_t *dev, int16_t index_offset, int16_t learning_time_offset_hours, int16_t learning_time_gain_hours, int16_t gating_max_duration_minutes, int16_t std_initial, int16_t gain_factor)
 Set the parameters for the VOC Algorithm tuning.
 
void sen5x_get_voc_algorithm_tuning (const sen5x_t *dev, int16_t *index_offset, int16_t *learning_time_offset_hours, int16_t *learning_time_gain_hours, int16_t *gating_max_duration_minutes, int16_t *std_initial, int16_t *gain_factor)
 Get the VOC Algorithm tuning parameters.
 
void sen5x_set_nox_algorithm_tuning (const sen5x_t *dev, int16_t index_offset, int16_t learning_time_offset_hours, int16_t learning_time_gain_hours, int16_t gating_max_duration_minutes, int16_t std_initial, int16_t gain_factor)
 Set the parameters for the NOx Algorithm tuning.
 
void sen5x_get_nox_algorithm_tuning (const sen5x_t *dev, int16_t *index_offset, int16_t *learning_time_offset_hours, int16_t *learning_time_gain_hours, int16_t *gating_max_duration_minutes, int16_t *std_initial, int16_t *gain_factor)
 Get the NOx Algorithm tuning parameters.
 
void sen5x_set_rht_acceleration (const sen5x_t *dev, uint16_t mode)
 Set the mode for the RH/T acceleration algorithm.
 
void sen5x_get_rht_acceleration (const sen5x_t *dev, uint16_t *mode)
 Get the mode for the RH/T acceleration algorithm.
 
void sen5x_set_voc_state (const sen5x_t *dev, const uint8_t *state, uint8_t state_size)
 Get the VOC Algorithm state.
 
void sen5x_get_voc_state (const sen5x_t *dev, uint8_t *state, uint8_t state_size)
 Set the VOC Algorithm state.
 

Function Documentation

◆ sen5x_clean_fan()

void sen5x_clean_fan ( const sen5x_t * dev)

Sets the fan to maximum speed, to clean it within 10 seconds.

Parameters
[in,out]devDevice descriptor of the driver

◆ sen5x_data_ready_flag()

bool sen5x_data_ready_flag ( const sen5x_t * dev)

Sets the fan to maximum speed, to clean it within 10 seconds.

Parameters
[in,out]devDevice descriptor of the driver
Returns
0 if no new measurements are available
1 if new measuremtns are ready to be read

◆ sen5x_get_nox_algorithm_tuning()

void sen5x_get_nox_algorithm_tuning ( const sen5x_t * dev,
int16_t * index_offset,
int16_t * learning_time_offset_hours,
int16_t * learning_time_gain_hours,
int16_t * gating_max_duration_minutes,
int16_t * std_initial,
int16_t * gain_factor )

Get the NOx Algorithm tuning parameters.

Parameters
[in,out]devDevice descriptor of the driver
[out]index_offsetNOx index representing typical(average) conditions
[out]learning_time_offset_hoursTime constant to estimate the NOx algorithm offset from the history in hours
[out]learning_time_gain_hoursThe time constant to estimate the NOx algorithm gain from the history has no impact for NOx. This parameter is still in place for consistency reasons with the VOC tuning parameters command. This parameter must always be set to 12 hours
[out]gating_max_duration_minutesMaximum duration of gating in minutes
[out]std_initialInitial estimate for standard deviation
[out]gain_factorGain factor to amplify or to attenuate the NOx index output

◆ sen5x_get_rht_acceleration()

void sen5x_get_rht_acceleration ( const sen5x_t * dev,
uint16_t * mode )

Get the mode for the RH/T acceleration algorithm.

Parameters
[in,out]devDevice descriptor of the driver
[out]modeRH/T acceleration mode: = 0: Low Acceleration = 1: High Acceleration = 2: Medium Acceleration

◆ sen5x_get_temperature_offset()

void sen5x_get_temperature_offset ( const sen5x_t * dev,
int16_t * temp_offset,
int16_t * slope,
uint16_t * time_constant )

Set a custom temperature offset to the ambient temperature.

Parameters
[in,out]devDevice descriptor of the driver
[out]temp_offsetTemperature offset in °C
[out]slopeNormalized temperature offset slope
[out]time_constantTime constant in seconds

◆ sen5x_get_voc_algorithm_tuning()

void sen5x_get_voc_algorithm_tuning ( const sen5x_t * dev,
int16_t * index_offset,
int16_t * learning_time_offset_hours,
int16_t * learning_time_gain_hours,
int16_t * gating_max_duration_minutes,
int16_t * std_initial,
int16_t * gain_factor )

Get the VOC Algorithm tuning parameters.

Parameters
[in,out]devDevice descriptor of the driver
[out]index_offsetVOC index representing typical (average) conditions
[out]learning_time_offset_hoursTime constant to estimate the VOC algorithm offset from the history in hours
[out]learning_time_gain_hoursTime constant to estimate the VOC algorithm gain from the history in hours
[out]gating_max_duration_minutesMaximum duration of gating in minutes
[out]std_initialInitial estimate for standard deviation
[out]gain_factorGain factor to amplify or to attenuate the VOC index output

◆ sen5x_get_voc_state()

void sen5x_get_voc_state ( const sen5x_t * dev,
uint8_t * state,
uint8_t state_size )

Set the VOC Algorithm state.

Parameters
[in,out]devDevice descriptor of the driver
[out]stateVOC Algorithm state
[in]state_sizeSize of the VOC Algorithm state

◆ sen5x_get_warm_start()

void sen5x_get_warm_start ( const sen5x_t * dev,
uint16_t * warm_start )

Get the warm start parameter.

Parameters
[in,out]devDevice descriptor of the driver
[out]warm_startWarm start behavior as a value in the range from 0 (cold start, default) to 65535 (warm start).

◆ sen5x_init()

int sen5x_init ( sen5x_t * dev,
const sen5x_params_t * params )

Initialize the given device.

Parameters
[in,out]devDevice descriptor of the driver
[in]paramsInitialization parameters
Returns
0 on success
> 0 on error

◆ sen5x_read_pm_values()

void sen5x_read_pm_values ( const sen5x_t * dev,
sen5x_measurement_t * values )

Read measured particle matter values.

Parameters
[in,out]devDevice descriptor of the driver
[out]valuesPointer to wrapper containing all measured values

◆ sen5x_read_values()

void sen5x_read_values ( const sen5x_t * dev,
sen5x_measurement_t * values )

Read measured mass concentration, humidity and temperature values.

Parameters
[in,out]devDevice descriptor of the driver
[out]valuesPointer to wrapper containing all measured values

◆ sen5x_reset()

int sen5x_reset ( const sen5x_t * dev)

Execute a reset on the given device.

Parameters
[in,out]devDevice descriptor of the driver
Returns
0 on success
> 0 on error

◆ sen5x_set_nox_algorithm_tuning()

void sen5x_set_nox_algorithm_tuning ( const sen5x_t * dev,
int16_t index_offset,
int16_t learning_time_offset_hours,
int16_t learning_time_gain_hours,
int16_t gating_max_duration_minutes,
int16_t std_initial,
int16_t gain_factor )

Set the parameters for the NOx Algorithm tuning.

Parameters
[in,out]devDevice descriptor of the driver
[in]index_offsetNOx index representing typical (average) conditions
[in]learning_time_offset_hoursTime constant to estimate the NOx algorithm offset from the history in hours
[in]learning_time_gain_hoursThe time constant to estimate the NOx algorithm gain from the history has no impact for NOx. This parameter is still in place for consistency reasons with the VOC tuning parameters command. This parameter must always be set to 12 hours
[in]gating_max_duration_minutesMaximum duration of gating in minutes
[in]std_initialInitial estimate for standard deviation
[in]gain_factorGain factor to amplify or to attenuate the NOx index output

◆ sen5x_set_rht_acceleration()

void sen5x_set_rht_acceleration ( const sen5x_t * dev,
uint16_t mode )

Set the mode for the RH/T acceleration algorithm.

Parameters
[in,out]devDevice descriptor of the driver
[in]modeRH/T acceleration mode: = 0: Low Acceleration = 1: High Acceleration = 2: Medium Acceleration

◆ sen5x_set_temperature_offset()

void sen5x_set_temperature_offset ( const sen5x_t * dev,
int16_t temp_offset,
int16_t slope,
uint16_t time_constant )

Set a custom temperature offset to the ambient temperature.

Parameters
[in,out]devDevice descriptor of the driver
[in]temp_offsetTemperature offset in °C
[in]slopeNormalized temperature offset slope
[in]time_constantTime constant in seconds

◆ sen5x_set_voc_algorithm_tuning()

void sen5x_set_voc_algorithm_tuning ( const sen5x_t * dev,
int16_t index_offset,
int16_t learning_time_offset_hours,
int16_t learning_time_gain_hours,
int16_t gating_max_duration_minutes,
int16_t std_initial,
int16_t gain_factor )

Set the parameters for the VOC Algorithm tuning.

Parameters
[in,out]devDevice descriptor of the driver
[in]index_offsetVOC index representing typical (average) conditions
[in]learning_time_offset_hoursTime constant to estimate the VOC algorithm offset from the history in hours
[in]learning_time_gain_hoursTime constant to estimate the VOC algorithm gain from the history in hours
[in]gating_max_duration_minutesMaximum duration of gating in minutes
[in]std_initialInitial estimate for standard deviation
[in]gain_factorGain factor to amplify or to attenuate the VOC index output

◆ sen5x_set_voc_state()

void sen5x_set_voc_state ( const sen5x_t * dev,
const uint8_t * state,
uint8_t state_size )

Get the VOC Algorithm state.

Parameters
[in,out]devDevice descriptor of the driver
[in]stateVOC Algorithm state
[in]state_sizeSize of the VOC Algorithm state

◆ sen5x_set_warm_start()

void sen5x_set_warm_start ( const sen5x_t * dev,
uint16_t warm_start )

Set the parameter for a warm start on the device, to improve initial accuracy of the ambient temperature output.

Parameters
[in,out]devDevice descriptor of the driver
[in]warm_startWarm start behavior as a value in the range from 0 (cold start, default) to 65535 (warm start).

◆ sen5x_sleep()

void sen5x_sleep ( const sen5x_t * dev)

Stops the measurement and returns to idle mode.

Parameters
[in,out]devDevice descriptor of the driver

◆ sen5x_wake()

void sen5x_wake ( const sen5x_t * dev)

Starts a continuous measurement.

Parameters
[in,out]devDevice descriptor of the driver

◆ sen5x_wake_no_pm()

void sen5x_wake_no_pm ( const sen5x_t * dev)

Starts a continuous measurement without PM.

Only humidity, temperature, VOC and NOx are measured.

Parameters
[in,out]devDevice descriptor of the driver