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 
9 #pragma once
10 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
30 #define MHZ19_UART_BAUDRATE 9600
31 
45 #define MHZ19_BUF_SIZE 8
46 
56 #define MHZ19_TIMEOUT_READ 20
57 
58 /***
59  * @name MH-Z19 Command timeout in milliseconds
60  *
61  * While undocumented, it seems that some commands take some time. Without
62  * an additional delay, the first sensor read will fail with a timeout value,
63  * or return an arbitrary value.
64  */
65 #define MHZ19_TIMEOUT_CMD (MHZ19_TIMEOUT_READ * 5)
66 
71 #define MHZ19_READ_START 0xff
72 #define MHZ19_READ_SENSOR_NUM 0x01
79 #define MHZ19_CMD_AUTO_CALIBRATION 0x79
80 #define MHZ19_CMD_GAS_CONCENTRATION 0x86
81 #define MHZ19_CMD_CALIBRATE_ZERO 0x87
82 #define MHZ19_CMD_CALIBRATE_SPAN 0x88
89 #define MHZ19_RX_POS_PPM_HIGH 1
90 #define MHZ19_RX_POS_PPM_LOW 2
91 #define MHZ19_RX_POS_CHECKSUM 7
94 #ifdef __cplusplus
95 }
96 #endif
97