mhz19_internals.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Koen Zandberg <koen@bergzand.net>
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 
19 #ifndef MHZ19_INTERNALS_H
20 #define MHZ19_INTERNALS_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
31 #define MHZ19_UART_BAUDRATE 9600
32 
46 #define MHZ19_BUF_SIZE 8
47 
57 #define MHZ19_TIMEOUT_READ 20
58 
59 /***
60  * @name MH-Z19 Command timeout in milliseconds
61  *
62  * While undocumented, it seems that some commands take some time. Without
63  * an additional delay, the first sensor read will fail with a timeout value,
64  * or return an arbitrary value.
65  */
66 #define MHZ19_TIMEOUT_CMD (MHZ19_TIMEOUT_READ * 5)
67 
72 #define MHZ19_READ_START 0xff
73 #define MHZ19_READ_SENSOR_NUM 0x01
80 #define MHZ19_CMD_AUTO_CALIBRATION 0x79
81 #define MHZ19_CMD_GAS_CONCENTRATION 0x86
82 #define MHZ19_CMD_CALIBRATE_ZERO 0x87
83 #define MHZ19_CMD_CALIBRATE_SPAN 0x88
90 #define MHZ19_RX_POS_PPM_HIGH 1
91 #define MHZ19_RX_POS_PPM_LOW 2
92 #define MHZ19_RX_POS_CHECKSUM 7
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* MHZ19_INTERNALS_H */
100