Loading...
Searching...
No Matches
sps30.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 HAW Hamburg
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
59
60#include <stdbool.h>
61#include "periph/gpio.h"
62#include "periph/i2c.h"
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
71typedef struct {
74
78typedef struct {
80} sps30_t;
81
89typedef struct {
90 float mc_pm1;
91 float mc_pm2_5;
92 float mc_pm4;
93 float mc_pm10;
94 float nc_pm0_5;
95 float nc_pm1;
96 float nc_pm2_5;
97 float nc_pm4;
98 float nc_pm10;
99 float ps;
101
110
114#define SPS30_FAN_CLEAN_S (10U)
115
119#define SPS30_SER_ART_LEN (32U)
120
124#define SPS30_DEFAULT_ACI_S (604800UL)
125
143#ifndef CONFIG_SPS30_ERROR_RETRY
144#define CONFIG_SPS30_ERROR_RETRY (500U)
145#endif
147
157int sps30_init(sps30_t *dev, const sps30_params_t *params);
158
175
186
197bool sps30_data_ready(const sps30_t *dev, int *error);
198
208
221int sps30_read_ac_interval(const sps30_t *dev, uint32_t *seconds);
222
240int sps30_write_ac_interval(const sps30_t *dev, uint32_t seconds);
241
254
264int sps30_read_article_code(const sps30_t *dev, char *str, size_t len);
265
275int sps30_read_serial_number(const sps30_t *dev, char *str, size_t len);
276
284int sps30_reset(const sps30_t *dev);
285
293int sps30_sleep(const sps30_t *dev);
294
302int sps30_wakeup(const sps30_t *dev);
303
304#ifdef __cplusplus
305}
306#endif
Low-level GPIO peripheral driver interface definitions.
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
int sps30_read_ac_interval(const sps30_t *dev, uint32_t *seconds)
Read the fan auto-clean interval.
int sps30_start_measurement(const sps30_t *dev)
Enable the measurement action.
int sps30_start_fan_clean(const sps30_t *dev)
Run a fan cleaning cycle manually.
bool sps30_data_ready(const sps30_t *dev, int *error)
Ask the device if a measurement is ready for reading.
int sps30_read_article_code(const sps30_t *dev, char *str, size_t len)
Read the article code from the sensor as string.
sps30_error_code_t
SPS30 error codes (returned as negative values)
Definition sps30.h:105
int sps30_reset(const sps30_t *dev)
Reset the sensor.
int sps30_sleep(const sps30_t *dev)
Put the sensor in sleep mode.
int sps30_read_serial_number(const sps30_t *dev, char *str, size_t len)
Read the serial number from the sensor as string.
int sps30_write_ac_interval(const sps30_t *dev, uint32_t seconds)
Write the fan auto-clean interval.
int sps30_wakeup(const sps30_t *dev)
Wake up sensor from sleep mode (returns sensor to Idle mode)
int sps30_read_measurement(const sps30_t *dev, sps30_data_t *data)
Read a set of particulate matter measurements.
int sps30_stop_measurement(const sps30_t *dev)
Stops the measurement action.
int sps30_init(sps30_t *dev, const sps30_params_t *params)
Initialize SPS30 sensor driver.
@ SPS30_I2C_ERROR
Some I2C operation failed.
Definition sps30.h:108
@ SPS30_CRC_ERROR
The CRC check of received data failed.
Definition sps30.h:107
@ SPS30_OK
Everything went fine.
Definition sps30.h:106
Low-level I2C peripheral driver interface definition.
Set of measured particulate matter values.
Definition sps30.h:89
float nc_pm10
Number concentration of all particles <= 10µm [#/cm^3].
Definition sps30.h:98
float mc_pm10
Mass concentration of all particles <= 10µm [µg/m^3].
Definition sps30.h:93
float nc_pm0_5
Number concentration of all particles <= 0.5µm [#/cm^3].
Definition sps30.h:94
float nc_pm4
Number concentration of all particles <= 4µm [#/cm^3].
Definition sps30.h:97
float mc_pm1
Mass concentration of all particles <= 1µm [µg/m^3].
Definition sps30.h:90
float mc_pm4
Mass concentration of all particles <= 4µm [µg/m^3].
Definition sps30.h:92
float ps
Typical particle size [µm].
Definition sps30.h:99
float nc_pm2_5
Number concentration of all particles <= 2.5µm [#/cm^3].
Definition sps30.h:96
float mc_pm2_5
Mass concentration of all particles <= 2.5µm [µg/m^3].
Definition sps30.h:91
float nc_pm1
Number concentration of all particles <= 1µm [#/cm^3].
Definition sps30.h:95
SPS30 device parameters.
Definition sps30.h:71
i2c_t i2c_dev
I2C dev the sensor is connected to.
Definition sps30.h:72
SPS30 device instance.
Definition sps30.h:78
sps30_params_t p
parameters of the sensor device
Definition sps30.h:79