Skip to content

Latest commit

 

History

History
221 lines (161 loc) · 7.94 KB

README.md

File metadata and controls

221 lines (161 loc) · 7.94 KB

Contributors Forks Stargazers Issues MIT License

TTGO ESP32 CO2 Monitor

CO2 Monitor based on the MH-Z19B Infrared CO2 sensor running on a ESP32 TTGO Display V1.1
Explore the docs »

centered image
View Demo · Report Bug · Request Feature

Table of Contents

  1. Getting Started
  2. Usage
  3. Roadmap
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgements

About The Project

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

Built With

  • ESP-IDF v4.4-dev-3042-g220590d599

Getting Started

Set-up

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

Installation

Prerequisites

  • Install ESP-IDF Framework, follow the walk-through here.

Steps

  1. Clone the repo

    git clone https://github.com/raulgotor/co2monitor.git
  2. 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
    
  3. Flash the firmware into the hardware:

    idf.py flash

Usage

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.

Configuring WiFi credentials

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.

Configuring Thingsboard server and token

Turning the display on and off

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.

Calibrating CO2 sensor

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.

Further documentation

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Raúl Gotor

Project Link: https://github.com/raulgotor/co2monitor

Acknowledgements