Loading...
Searching...
No Matches
mhz19.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Koen Zandberg <koen@bergzand.net>
3 * Copyright (C) 2018 Beduino Master Projekt - University of Bremen
4 * Copyright (C) 2020 Bas Stottelaar <basstottelaar@gmail.com>
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
38#ifndef MHZ19_H
39#define MHZ19_H
40
41#include <stdbool.h>
42
43#include "saul.h"
44
45#ifdef MODULE_MHZ19_UART
46#include "periph/uart.h"
47#include "mhz19_internals.h"
48#include "mutex.h"
49#endif /* MODULE_MHZ19_UART */
50
51#ifdef MODULE_MHZ19_PWM
52#include "periph/gpio.h"
53#endif /* MODULE_MHZ19_PWM */
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
62enum {
67};
68
69#ifdef MODULE_MHZ19_UART
73typedef struct {
74 uart_t uart;
75 bool auto_calibration;
76} mhz19_params_t;
77
81typedef struct {
82 const mhz19_params_t *params;
83 mutex_t mutex;
84 mutex_t sync;
85 uint8_t idx;
86 uint8_t rxmem[MHZ19_BUF_SIZE];
87} mhz19_t;
88#endif /* MODULE_MHZ19_UART */
89
90#ifdef MODULE_MHZ19_PWM
94typedef struct {
95 gpio_t pin;
96} mhz19_params_t;
97
101typedef struct {
102 gpio_t pin;
103} mhz19_t;
104#endif /* MODULE_MHZ19_PWM */
105
110
120int mhz19_init(mhz19_t *dev, const mhz19_params_t *params);
121
133int mhz19_get_ppm(mhz19_t *dev, int16_t *ppm);
134
135#ifdef MODULE_MHZ19_UART
142void mhz19_set_auto_calibration(mhz19_t *dev, bool enable);
143
149void mhz19_calibrate_zero_point(mhz19_t *dev);
150#endif
151
152#ifdef __cplusplus
153}
154#endif
155
156#endif /* MHZ19_H */
Low-level GPIO peripheral driver interface definitions.
Low-level UART peripheral driver interface definition.
int mhz19_init(mhz19_t *dev, const mhz19_params_t *params)
Initialize a MH-Z19 device.
int mhz19_get_ppm(mhz19_t *dev, int16_t *ppm)
Get measured CO2 ppm value.
const saul_driver_t mhz19_ppm_saul_driver
Export SAUL endpoint.
@ MHZ19_ERR_CHECKSUM
checksum failure on received data
Definition mhz19.h:66
@ MHZ19_ERR_INIT
error initializing the device
Definition mhz19.h:64
@ MHZ19_OK
everything was fine
Definition mhz19.h:63
@ MHZ19_ERR_TIMEOUT
timeout on retrieving sensor data
Definition mhz19.h:65
uint_fast8_t uart_t
Define default UART type identifier.
Definition uart.h:85
Internal addresses, registers, constants for the MH-Z19 CO2 sensor.
Mutex for thread synchronization.
Mutex structure.
Definition mutex.h:146
Definition of the RIOT actuator/sensor interface.
Definition saul.h:284
Functionality for reading [S]ensor [A]ctuator [U]ber [L]ayer sensors as SenML.