scd30.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Puhang Ding
3  * 2020 Jan Schlichter
4  * 2020 Nishchay Agrawal
5  *
6  * This file is subject to the terms and conditions of the GNU Lesser
7  * General Public License v2.1. See the file LICENSE in the top level
8  * directory for more details.
9  */
10 
24 #ifndef SCD30_H
25 #define SCD30_H
26 
27 #include "periph/i2c.h"
28 #include "saul.h"
29 #include "xtimer.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
38 #define SCD30_VERSION 0xD100
39 #define SCD30_STATUS 0x0202
42 #define SCD30_DATA 0x0300
44 #define SCD30_START 0x0010
45 #define SCD30_STOP 0x0104
46 #define SCD30_SOFT_RESET 0xD304
48 #define SCD30_INTERVAL 0x4600
50 #define SCD30_ASC 0x5306
51 #define SCD30_FRC 0x5204
52 #define SCD30_T_OFFSET 0x5403
53 #define SCD30_A_OFFSET 0x5102
59 enum {
60  SCD30_OK = 0,
65 };
66 
70 typedef struct {
72  float temperature;
75 
79 typedef struct {
81  uint8_t i2c_addr;
83 
87 typedef struct {
89 } scd30_t;
90 
99 int8_t scd30_init(scd30_t *dev, const scd30_params_t *params);
100 
111 int8_t scd30_set_param(const scd30_t *dev, uint16_t param, uint16_t val);
112 
123 int8_t scd30_get_param(scd30_t *dev, uint16_t param, uint16_t *val);
124 
133 int8_t scd30_read_triggered(scd30_t *dev, scd30_measurement_t *result);
134 
144 uint8_t scd30_read_periodic(scd30_t *dev, scd30_measurement_t *result);
145 
158 int scd30_start_periodic_measurement(scd30_t *dev, uint16_t *interval,
159  uint16_t *apc);
160 
168 int8_t scd30_stop_measurements(const scd30_t *dev);
169 
177 int8_t scd30_reset(scd30_t *dev);
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif /* SCD30_H */
scd30_init
int8_t scd30_init(scd30_t *dev, const scd30_params_t *params)
Initialize SCD30.
scd30_t
Device descriptor for the SCD30 sensor.
Definition: scd30.h:87
scd30_measurement_t::relative_humidity
float relative_humidity
Relative humidity measured in %.
Definition: scd30.h:73
scd30_reset
int8_t scd30_reset(scd30_t *dev)
Soft reset sensor.
scd30_stop_measurements
int8_t scd30_stop_measurements(const scd30_t *dev)
Stop Continuous measurements.
scd30_measurement_t::co2_concentration
float co2_concentration
CO2 concentration in ppm.
Definition: scd30.h:71
scd30_get_param
int8_t scd30_get_param(scd30_t *dev, uint16_t param, uint16_t *val)
Get value set for a configuration parameter on the device.
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
scd30_params_t::i2c_dev
i2c_t i2c_dev
I2C device which is used.
Definition: scd30.h:80
scd30_params_t::i2c_addr
uint8_t i2c_addr
I2C address.
Definition: scd30.h:81
scd30_start_periodic_measurement
int scd30_start_periodic_measurement(scd30_t *dev, uint16_t *interval, uint16_t *apc)
Initializes Continuous Measurements.
scd30_set_param
int8_t scd30_set_param(const scd30_t *dev, uint16_t param, uint16_t val)
Set a configuration parameter of device.
scd30_measurement_t
Measurement from SCD30 sensor.
Definition: scd30.h:70
scd30_t::params
scd30_params_t params
Device initialization parameters.
Definition: scd30.h:88
SCD30_CRC_ERROR
@ SCD30_CRC_ERROR
Invalid value or length.
Definition: scd30.h:63
scd30_read_triggered
int8_t scd30_read_triggered(scd30_t *dev, scd30_measurement_t *result)
read CO2 concentration, temperature and relative humidity once
SCD30_NO_NEW_DATA
@ SCD30_NO_NEW_DATA
No new data.
Definition: scd30.h:64
SCD30_COM_FAILED
@ SCD30_COM_FAILED
Communication with device failed.
Definition: scd30.h:61
scd30_params_t
Device initialization parameters.
Definition: scd30.h:79
scd30_read_periodic
uint8_t scd30_read_periodic(scd30_t *dev, scd30_measurement_t *result)
read co2 concentration, temperature and relative humidity when continuous measurements are being take...
saul.h
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
i2c.h
Low-level I2C peripheral driver interface definition.
scd30_measurement_t::temperature
float temperature
Temperature measured in °C.
Definition: scd30.h:72
xtimer.h
xtimer interface definitions
SCD30_INVALID_VALUE
@ SCD30_INVALID_VALUE
Device doesn't exist.
Definition: scd30.h:62