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
9#pragma once
10
47
48#include "periph/i2c.h"
49#include "ztimer.h"
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
58typedef struct {
59 uint16_t tvoc;
61 uint16_t eco2;
63#ifdef MODULE_SGP30_STRICT
64 uint32_t timestamp;
65#endif
67
71typedef struct {
72 uint16_t raw_h2;
73 uint16_t raw_ethanol;
75
79typedef struct {
82
86typedef struct {
88#ifdef MODULE_SGP30_STRICT
89 bool ready;
90 ztimer_t _timer;
91 sgp30_data_t _data;
92#endif
93} sgp30_t;
94
103int sgp30_init(sgp30_t *dev, const sgp30_params_t *params);
104
116
127int sgp30_read_future_set(sgp30_t *dev, uint16_t *version);
128
142
143#if defined(MODULE_SGP30_STRICT) || defined(DOXYGEN)
156#endif
157
169int sgp30_read_serial_number(sgp30_t *dev, uint8_t *buf, size_t len);
170
188
209int sgp30_set_absolute_humidity(sgp30_t *dev, uint32_t humidity);
210
221
233
248
249#ifdef __cplusplus
250}
251#endif
252
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:144
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:58
uint16_t tvoc
The last measurement of the IAQ-calculated Total Volatile Organic Compounds in ppb.
Definition sgp30.h:59
uint16_t eco2
The last measurement of the IAQ-calculated equivalent CO2 in ppm.
Definition sgp30.h:61
Device initialization parameters.
Definition sgp30.h:79
i2c_t i2c_dev
I2C dev the sensor is connected to.
Definition sgp30.h:80
Set of measured raw values.
Definition sgp30.h:71
uint16_t raw_ethanol
raw Ethanol signal, only for testing purposes
Definition sgp30.h:73
uint16_t raw_h2
raw H2 signal, only for testing purposes
Definition sgp30.h:72
Device descriptor for the driver.
Definition sgp30.h:86
sgp30_params_t params
parameters of the sensor device
Definition sgp30.h:87
ztimer structure
Definition ztimer.h:319
ztimer API