• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

boards/04-Jan-2025-1513

src/04-Jan-2025-7956

CMakeLists.txtD04-Jan-2025223 96

README.rstD04-Jan-20251.3 KiB5339

prj.confD04-Jan-202587 54

sample.yamlD04-Jan-2025284 159

README.rst

1.. _mhz19b-sample:
2
3MH-Z19B: CO2 Sensor Sample
4##########################
5
6Description
7***********
8
9This sample application demonstrate the configurations of the MH-Z19B CO2
10sensor, then periodically reads CO2 data from the sensor. The driver
11currently only support uart interrupt APIs.
12
13Requirements
14************
15
16The baudrate of the UART must be configured to 9600, and must support
17interrupt driven API.
18
19Building and Running
20********************
21
22To build the application, a board with UART interface
23has to be chosen, or a custom devicetree overlay has to be provided.
24Here Nucleo G0B1RE board is used.
25Then, connect the RX and TX from your Zephyr target board to the
26MH-Z19B CO2 sensor and power the sensor according to the datasheet.
27
28.. zephyr-app-commands::
29   :zephyr-app: samples/sensor/mhz19b
30   :board: nucleo_g0b1re
31   :goals: build
32   :compact:
33
34Sample Output
35=============
36
37The application will perform runtime configuration of the sensor, then
38read back the sensor configuration data. After that it will read the CO2
39data every 2 seconds.
40
41.. code-block:: console
42
43   Winsen MH-Z19B CO2 sensor application
44   Configuring sensor - OK
45   Reading configurations from sensor:
46   Sensor range is set to 5000ppm
47   Sensor ABC is enabled
48   sensor: co2 reading: 758
49   sensor: co2 reading: 759
50   sensor: co2 reading: 762
51
52   <repeats endlessly every 2 seconds>
53