Loading...
Searching...
No Matches
sgp30.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021 Inria
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
44
45#include "periph/i2c.h"
46#include "ztimer.h"
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
55typedef struct {
56 uint16_t tvoc;
58 uint16_t eco2;
60#ifdef MODULE_SGP30_STRICT
61 uint32_t timestamp;
62#endif
64
68typedef struct {
69 uint16_t raw_h2;
70 uint16_t raw_ethanol;
72
76typedef struct {
79
83typedef struct {
85#ifdef MODULE_SGP30_STRICT
86 bool ready;
87 ztimer_t _timer;
88 sgp30_data_t _data;
89#endif
90} sgp30_t;
91
100int sgp30_init(sgp30_t *dev, const sgp30_params_t *params);
101
113
124int sgp30_read_future_set(sgp30_t *dev, uint16_t *version);
125
139
140#if defined(MODULE_SGP30_STRICT) || defined(DOXYGEN)
153#endif
154
166int sgp30_read_serial_number(sgp30_t *dev, uint8_t *buf, size_t len);
167
185
206int sgp30_set_absolute_humidity(sgp30_t *dev, uint32_t humidity);
207
218
230
245
246#ifdef __cplusplus
247}
248#endif
249
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
int sgp30_get_baseline(sgp30_t *dev, sgp30_data_t *data)
Returns baseline values.
bool sgp30_ready(sgp30_t *dev)
If device is ready to start reading measurements.
int sgp30_read_raw_measurements(sgp30_t *dev, sgp30_raw_data_t *data)
Read raw signals H2 (sout_H2) and Ethanol(sout_EthOH)
int sgp30_read_serial_number(sgp30_t *dev, uint8_t *buf, size_t len)
Read the serial number from the sensor.
int sgp30_set_baseline(sgp30_t *dev, sgp30_data_t *data)
Set new baseline values.
int sgp30_read_measurements(sgp30_t *dev, sgp30_data_t *data)
Read air quality signals.
int sgp30_start_air_quality(sgp30_t *dev)
Start air quality measurements, called on sgp30_init.
int sgp30_set_absolute_humidity(sgp30_t *dev, uint32_t humidity)
Set absolute humidity value for on-chop humidity compensation.
int sgp30_reset(sgp30_t *dev)
Performs a soft reset on the device.
int sgp30_read_future_set(sgp30_t *dev, uint16_t *version)
Initialize the given device.
int sgp30_init(sgp30_t *dev, const sgp30_params_t *params)
Initialize the given device.
Low-level I2C peripheral driver interface definition.
Set of measured values.
Definition sgp30.h:55
uint16_t tvoc
The last measurement of the IAQ-calculated Total Volatile Organic Compounds in ppb.
Definition sgp30.h:56
uint16_t eco2
The last measurement of the IAQ-calculated equivalent CO2 in ppm.
Definition sgp30.h:58
Device initialization parameters.
Definition sgp30.h:76
i2c_t i2c_dev
I2C dev the sensor is connected to.
Definition sgp30.h:77
Set of measured raw values.
Definition sgp30.h:68
uint16_t raw_ethanol
raw Ethanol signal, only for testing purposes
Definition sgp30.h:70
uint16_t raw_h2
raw H2 signal, only for testing purposes
Definition sgp30.h:69
Device descriptor for the driver.
Definition sgp30.h:83
sgp30_params_t params
parameters of the sensor device
Definition sgp30.h:84
ztimer structure
Definition ztimer.h:319
ztimer API