Loading...
Searching...
No Matches
sgp30.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Inria
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
46#ifndef SGP30_H
47#define SGP30_H
48
49#include "periph/i2c.h"
50#include "ztimer.h"
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
59typedef struct {
60 uint16_t tvoc;
62 uint16_t eco2;
64#ifdef MODULE_SGP30_STRICT
65 uint32_t timestamp;
66#endif
68
72typedef struct {
73 uint16_t raw_h2;
74 uint16_t raw_ethanol;
76
80typedef struct {
83
87typedef struct {
89#ifdef MODULE_SGP30_STRICT
90 bool ready;
91 ztimer_t _timer;
92 sgp30_data_t _data;
93#endif
94} sgp30_t;
95
104int sgp30_init(sgp30_t *dev, const sgp30_params_t *params);
105
117
128int sgp30_read_future_set(sgp30_t *dev, uint16_t *version);
129
143
144#if defined(MODULE_SGP30_STRICT) || defined(DOXYGEN)
157#endif
158
170int sgp30_read_serial_number(sgp30_t *dev, uint8_t *buf, size_t len);
171
189
210int sgp30_set_absolute_humidity(sgp30_t *dev, uint32_t humidity);
211
222
234
249
250#ifdef __cplusplus
251}
252#endif
253
254#endif /* SGP30_H */
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
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:59
uint16_t tvoc
The last measurement of the IAQ-calculated Total Volatile Organic Compounds in ppb.
Definition sgp30.h:60
uint16_t eco2
The last measurement of the IAQ-calculated equivalent CO2 in ppm.
Definition sgp30.h:62
Device initialization parameters.
Definition sgp30.h:80
i2c_t i2c_dev
I2C dev the sensor is connected to.
Definition sgp30.h:81
Set of measured raw values.
Definition sgp30.h:72
uint16_t raw_ethanol
raw Ethanol signal, only for testing purposes
Definition sgp30.h:74
uint16_t raw_h2
raw H2 signal, only for testing purposes
Definition sgp30.h:73
Device descriptor for the driver.
Definition sgp30.h:87
sgp30_params_t params
parameters of the sensor device
Definition sgp30.h:88
ztimer structure
Definition ztimer.h:332
ztimer API