CO2 Monitor based on the MH-Z19B Infrared CO2 sensor running on a ESP32 TTGO Display V1.1
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Here you get a wireless battery powered CO2 monitor device with color display and internet connectivity. It is based on the very well known MH-Z19B sensor, and on a ESP32 TTGO Display board, which integrates a display and two control push buttons, therefore facilitating build from readily available components. As the device is battery powered, it is very handy to perform on-field measurements. The information is sent to a specified Thingsboard.io server for further plotting.
Basic features are:
- WiFi enabled CO2 monitor
- MH-Z19B CO2 Sensor: 400 - 10000 ppm CO2 range
- Display (IPS ST7789V 1.14 Inch) controlled by LVGL library v6.0
- Battery operated
- Display shows actual CO2 concentration as well as wifi and backend status and battery level
- Automatic display power-off
- Thingsboard.io integration
- WiFi manager handling reconnection and AP configuration
- ESP-IDF v4.4-dev-3042-g220590d599
This repository is meant to be run in a ESP32 TTGO Display V1.1, but can be ran on any compatible ESP32 module connected to an external display according to TTGO module schematics. The default connection of the sensor with the TTGO board is as follows:
MH-Z19 | TTGO GPIO |
---|---|
Vin | 5V |
GND | GND |
Rx | 25 |
Tx | 33 |
- Install ESP-IDF Framework, follow the walk-through here.
-
Clone the repo
git clone https://github.com/raulgotor/co2monitor.git
-
cd into the repo folder and update submodules:
cd co2monitor && git submodule update --init --recursive
NOTE: LVGL library and drivers dependencies comes with some issues that cannot be fixed from these repository, therefore are addressed as patches. Please apply the following patches:
cd components/lvgl git apply ../../patch/lvgl.patch cd ../lvgl_esp32_drivers git apply ../../patch/st7789.patch
-
Flash the firmware into the hardware:
idf.py flash
After booting, the device will start sampling CO2 concentration and showing the result at the display. Additionally, it will connect to the configured WiFi network and each measurement will be sent to the specified Thingsboard.io server.
If a configured network is not available, the device will launch an access point named CO2_Monitor. Connect to that network and a captive portal will pop-up (if it doesn't, manually navigate to address ...... in your browser).
Configure it with your network credentials and press Join. If everything went well, you'll see your network SSID on the device display, together with the signal strength.
A small pilot next to the signal strength indicator shows the backend connectivity status: green or red depending if it was able to post messages to the backend.
The display can be turned on and off by pressing the bottom-right button at the TTGO board. Additionally, the display will turn off automatically after a specific amount of time which can be configured at the firmware configuration menu.
Launch the configuration menu with idf.py menuconfig
and navigate to Component config -> Application configuration -> Backlight automatic turn off
and select the desired
timeout (in seconds). To disable automatic turn off, configure it to 0 seconds.
Place the device outdoors (the CO2 concentration outdoors is around 410ppm at the atmosphere), and after 15 minutes, press the bottom-left button on the TTGO board. The device will calibrate itself and take the current measured concentration as 400 ppm.
NOTE: don't press the calibration button indoors as it will wrongly calibrate the device.
See the open issues for a list of proposed features (and known issues).
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Raúl Gotor
Project Link: https://github.com/raulgotor/co2monitor