sen5x.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 TU Braunschweig Institut für Betriebssysteme und Rechnerverbund
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
23 #include <stdbool.h>
24 #include <stdint.h>
25 
26 #include "periph/i2c.h"
27 #include "saul.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
36 typedef struct {
57  int16_t ambient_humidity;
61  int16_t voc_index;
63  int16_t nox_index;
66 
70 typedef struct {
72  uint8_t i2c_addr;
74 
78 typedef struct {
80 } sen5x_t;
81 
91 int sen5x_init(sen5x_t *dev, const sen5x_params_t *params);
92 
101 int sen5x_reset(const sen5x_t *dev);
102 
108 void sen5x_wake(const sen5x_t *dev);
109 
116 void sen5x_wake_no_pm(const sen5x_t *dev);
117 
123 void sen5x_sleep(const sen5x_t *dev);
124 
130 void sen5x_clean_fan(const sen5x_t *dev);
131 
141 
149 
157 
166 void sen5x_set_temperature_offset(const sen5x_t *dev, int16_t temp_offset,
167  int16_t slope, uint16_t time_constant);
168 
177 void sen5x_get_temperature_offset(const sen5x_t *dev, int16_t *temp_offset,
178  int16_t *slope, uint16_t *time_constant);
179 
188 void sen5x_set_warm_start(const sen5x_t *dev, uint16_t warm_start);
189 
197 void sen5x_get_warm_start(const sen5x_t *dev, uint16_t *warm_start);
198 
214  const sen5x_t *dev, int16_t index_offset, int16_t learning_time_offset_hours,
215  int16_t learning_time_gain_hours, int16_t gating_max_duration_minutes,
216  int16_t std_initial, int16_t gain_factor);
217 
234  const sen5x_t *dev, int16_t *index_offset, int16_t *learning_time_offset_hours,
235  int16_t *learning_time_gain_hours, int16_t *gating_max_duration_minutes,
236  int16_t *std_initial, int16_t *gain_factor);
237 
257  const sen5x_t *dev, int16_t index_offset, int16_t learning_time_offset_hours,
258  int16_t learning_time_gain_hours, int16_t gating_max_duration_minutes,
259  int16_t std_initial, int16_t gain_factor);
260 
280  const sen5x_t *dev, int16_t *index_offset, int16_t *learning_time_offset_hours,
281  int16_t *learning_time_gain_hours, int16_t *gating_max_duration_minutes,
282  int16_t *std_initial, int16_t *gain_factor);
283 
293 void sen5x_set_rht_acceleration(const sen5x_t *dev, uint16_t mode);
294 
304 void sen5x_get_rht_acceleration(const sen5x_t *dev, uint16_t *mode);
305 
313 void sen5x_set_voc_state(const sen5x_t *dev, const uint8_t *state, uint8_t state_size);
314 
322 void sen5x_get_voc_state(const sen5x_t *dev, uint8_t *state, uint8_t state_size);
323 
324 #ifdef __cplusplus
325 }
326 #endif
327 
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition: i2c.h:145
int sen5x_init(sen5x_t *dev, const sen5x_params_t *params)
Initialize the given device.
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 temperat...
void sen5x_wake_no_pm(const sen5x_t *dev)
Starts a continuous measurement without PM.
void sen5x_clean_fan(const sen5x_t *dev)
Sets the fan to maximum speed, to clean it within 10 seconds.
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_wake(const sen5x_t *dev)
Starts a continuous measurement.
void sen5x_get_voc_state(const sen5x_t *dev, uint8_t *state, uint8_t state_size)
Set the VOC Algorithm state.
void sen5x_get_warm_start(const sen5x_t *dev, uint16_t *warm_start)
Get the warm start parameter.
void sen5x_sleep(const sen5x_t *dev)
Stops the measurement and returns to idle mode.
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_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_rht_acceleration(const sen5x_t *dev, uint16_t mode)
Set the mode for the RH/T acceleration algorithm.
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_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_set_voc_state(const sen5x_t *dev, const uint8_t *state, uint8_t state_size)
Get the VOC Algorithm state.
bool sen5x_data_ready_flag(const sen5x_t *dev)
Sets the fan to maximum speed, to clean it within 10 seconds.
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.
int sen5x_reset(const sen5x_t *dev)
Execute a reset on the given device.
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_rht_acceleration(const sen5x_t *dev, uint16_t *mode)
Get the mode for the RH/T acceleration algorithm.
Low-level I2C peripheral driver interface definition.
Wrapper for measured values.
Definition: sen5x.h:36
uint16_t mass_concentration_pm4p0
raw value is scaled with factor 10: PM4.0 [µg/m³] = value / 10
Definition: sen5x.h:41
uint16_t number_concentration_pm4p0
raw value is scaled with factor 10: PM4.0 [#/cm³] = value / 10
Definition: sen5x.h:51
uint16_t mass_concentration_pm10p0
raw value is scaled with factor 10: PM10.0 [µg/m³] = value / 10
Definition: sen5x.h:43
uint16_t number_concentration_pm0p5
raw value is scaled with factor 10: PM0.5 [#/cm³] = value / 10
Definition: sen5x.h:45
int16_t ambient_humidity
raw value is scaled with factor 100: RH [%] = value / 100
Definition: sen5x.h:57
uint16_t mass_concentration_pm1p0
raw value is scaled with factor 10: PM1.0 [µg/m³] = value / 10
Definition: sen5x.h:37
uint16_t mass_concentration_pm2p5
raw value is scaled with factor 10: PM2.5 [µg/m³] = value / 10
Definition: sen5x.h:39
int16_t voc_index
raw value is scaled with factor 10: VOC Index = value / 10
Definition: sen5x.h:61
int16_t ambient_temperature
raw value is scaled with factor 200: T [°C] = value / 200
Definition: sen5x.h:59
uint16_t number_concentration_pm10p0
raw value is scaled with factor 10: PM10.0 [#/cm³] = value / 10
Definition: sen5x.h:53
int16_t nox_index
raw value is scaled with factor 10: NOx Index = value / 10
Definition: sen5x.h:63
uint16_t number_concentration_pm1p0
raw value is scaled with factor 10: PM1.0 [#/cm³] = value / 10
Definition: sen5x.h:47
uint16_t typical_particle_size
raw value is scaled with factor 1000: Size [µm] = value / 1000
Definition: sen5x.h:55
uint16_t number_concentration_pm2p5
raw value is scaled with factor 10: PM2.5 [#/cm³] = value / 10
Definition: sen5x.h:49
Device initialization parameters.
Definition: sen5x.h:70
uint8_t i2c_addr
I2C address.
Definition: sen5x.h:72
i2c_t i2c_dev
I2C device which is used.
Definition: sen5x.h:71
Device descriptor for the driver.
Definition: sen5x.h:78
sen5x_params_t params
Device initialization parameters.
Definition: sen5x.h:79
Functionality for reading [S]ensor [A]ctuator [U]ber [L]ayer sensors as SenML.