Firmware SDK
|
Driver for SGP30 VOC gas sensor. More...
Typedefs | |
typedef struct twr_sgp30_t | twr_sgp30_t |
SGP30 instance. | |
Enumerations | |
enum | twr_sgp30_event_t { TWR_SGP30_EVENT_ERROR = 0 , TWR_SGP30_EVENT_UPDATE = 1 } |
Callback events. More... | |
Functions | |
void | twr_sgp30_init (twr_sgp30_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address) |
Initialize SGP30. More... | |
void | twr_sgp30_deinit (twr_sgp30_t *self) |
Deinitialize SGP30. More... | |
void | twr_sgp30_set_event_handler (twr_sgp30_t *self, void(*event_handler)(twr_sgp30_t *, twr_sgp30_event_t, void *), void *event_param) |
Set callback function. More... | |
void | twr_sgp30_set_update_interval (twr_sgp30_t *self, twr_tick_t interval) |
Set measurement interval. More... | |
bool | twr_sgp30_measure (twr_sgp30_t *self) |
Start measurement manually. More... | |
bool | twr_sgp30_get_co2eq_ppm (twr_sgp30_t *self, uint16_t *ppm) |
Get measured CO2eq in ppm (parts per million) More... | |
bool | twr_sgp30_get_tvoc_ppb (twr_sgp30_t *self, uint16_t *ppb) |
Get measured TVOC in ppb (parts per billion) More... | |
float | twr_sgp30_set_compensation (twr_sgp30_t *self, float *t_celsius, float *rh_percentage) |
Set sensor compensation (absolute humidity is calculated from temperature and relative humidity) More... | |
Driver for SGP30 VOC gas sensor.
enum twr_sgp30_event_t |
Callback events.
Enumerator | |
---|---|
TWR_SGP30_EVENT_ERROR | Error event. |
TWR_SGP30_EVENT_UPDATE | Update event. |
Definition at line 13 of file twr_sgp30.h.
void twr_sgp30_deinit | ( | twr_sgp30_t * | self | ) |
Deinitialize SGP30.
[in] | self | Instance |
Definition at line 32 of file twr_sgp30.c.
bool twr_sgp30_get_co2eq_ppm | ( | twr_sgp30_t * | self, |
uint16_t * | ppm | ||
) |
Get measured CO2eq in ppm (parts per million)
[in] | self | Instance |
[out] | ppm | Pointer to variable where result will be stored |
Definition at line 80 of file twr_sgp30.c.
Referenced by twr_tag_voc_get_co2eq_ppm().
bool twr_sgp30_get_tvoc_ppb | ( | twr_sgp30_t * | self, |
uint16_t * | ppb | ||
) |
Get measured TVOC in ppb (parts per billion)
[in] | self | Instance |
[out] | ppb | Pointer to variable where result will be stored |
Definition at line 92 of file twr_sgp30.c.
Referenced by twr_tag_voc_get_tvoc_ppb().
void twr_sgp30_init | ( | twr_sgp30_t * | self, |
twr_i2c_channel_t | i2c_channel, | ||
uint8_t | i2c_address | ||
) |
Initialize SGP30.
[in] | self | Instance |
[in] | i2c_channel | I2C channel |
[in] | i2c_address | I2C device address |
Definition at line 17 of file twr_sgp30.c.
Referenced by twr_tag_voc_init().
bool twr_sgp30_measure | ( | twr_sgp30_t * | self | ) |
Start measurement manually.
[in] | self | Instance |
Definition at line 61 of file twr_sgp30.c.
Referenced by twr_sgp30_set_update_interval(), and twr_tag_voc_measure().
float twr_sgp30_set_compensation | ( | twr_sgp30_t * | self, |
float * | t_celsius, | ||
float * | rh_percentage | ||
) |
Set sensor compensation (absolute humidity is calculated from temperature and relative humidity)
[in] | self | Instance |
[in] | t_celsius | Pointer to variable holding temperature in degrees of celsius (must be NULL if not available) |
[in] | rh_percentage | Pointer to variable holding relative humidity in percentage (must be NULL if not available) |
Definition at line 104 of file twr_sgp30.c.
Referenced by twr_tag_voc_set_compensation().
void twr_sgp30_set_event_handler | ( | twr_sgp30_t * | self, |
void(*)(twr_sgp30_t *, twr_sgp30_event_t, void *) | event_handler, | ||
void * | event_param | ||
) |
Set callback function.
[in] | self | Instance |
[in] | event_handler | Function address |
[in] | event_param | Optional event parameter (can be NULL) |
Definition at line 39 of file twr_sgp30.c.
Referenced by twr_tag_voc_set_event_handler().
void twr_sgp30_set_update_interval | ( | twr_sgp30_t * | self, |
twr_tick_t | interval | ||
) |
Set measurement interval.
[in] | self | Instance |
[in] | interval | Measurement interval |
Definition at line 45 of file twr_sgp30.c.
Referenced by twr_tag_voc_set_update_interval().