An easy to build CO2 Monitor/Meter with cell phone App for real time visualization and charting of air data, datalogger, a variety of communication options (BLE, WIFI, MQTT, ESP-Now) and many supported sensors.
This repository is mainly addressed at developers. If you are an end user willing to build the CO2 Gadget you will find complete instructions at my blog including instructions in how to build the hardware and to load the firmware very easily, with one click in your browser (without having edit files, compile or install anything on your computer).
- Many popular CO2 sensors supported: Sensirion SCD30, Sensirion SCD40, Sensirion SCD41, Senseair S8 LP, Winsen MH-Z19, Cubic CM1106
- Supports the Air Quality App Sensirion MyAmbiance for iOS and Android with real time visualization, charting and access to historycal data
- Real time visualization on display, serial port and web page
- Management and configuration via on screen menu and console (serial port)
- Local data logger with upload to phone by BLE
- WIFI connection
- Sending of data via MQTT
- Receiving remote commands via MQTT
- Over the air updates OTA*
- GPIO outputs to, for example, activation of air circulation on threshold with hysteresis. Check GPIO to use at my blog CO2 Gadget firmware page
This project support a large selection of boards, displays and sensors.
As an example you can find a very detailed tutorial with step-by-step video on how to build a very compact CO2 Gadget with a TTGO T-Display board and a high quality Sensirion SCD30 dual channel NDIR CO2 sensor and support for battery here.
For latest information on other hardware use (boards, sensors, displays, etc), please check GPIO to use at my blog CO2 Gadget firmware page
CO2 Gadget right now has support for many different OLED displays (by using the U8g2 library) so it's very easy to include support for them. Right now there is built in support for OLED I2C 1.3" 128x64 pixels display with a very basic layout for real time measurements (soon to be improved).
Supporting any other ESP32 board is very easy. Yoy just have to setup the pines accordly.
These are the GPIOs used by each predefined board:
Flavour | Display | RX/TX | I2C | UP/DWN | GPIO EN | GPIO Green | GPIO Orange | GPIO Red |
---|---|---|---|---|---|---|---|---|
TTGO_TDISPLAY TFT | 240×135 | 13/12 | 21/22 | 35/0 | 27 | 25 | 32 | 32 |
TTGO_TDISPLAY_SANDWICH | TFT 240×135 | 13/12 | 22/21 | 35/0 | 27 | 25 | 32 | 32 |
esp32dev_OLED SSH1106 | 128×64 | 17/16 | 21/22 | 35/34 | 27 | 25 | 32 | 32 |
esp32dev_OLED_OTA | SSH1106-128×64 | 17/16 | 21/22 | 35/34 | 27 | 25 | 32 | 32 |
- Variant: Name of the firmware variant, or flavor.
- Display: Display supported by each flavor.
- RX / TX: Pins (GPIO) used for connection of sensors connected by Serial port.
- I2C: Pins (GPIO) corresponding to the I2C bus for connection of I2C sensors and displays.
- UP / DWN: Pins (GPIO) to which to connect the "Up" and "Down" buttons. They are optional as CO2 Gadget is fully functional with no buttons attached.
- EN: Pin (GPIO) that supplies an ENABLE signal for switching the sensors on and off (reserved for future use).
- Green GPIO: Pin (GPIO) corresponding to the output before reaching the orange level (for relays, alarms, and RGB LED).
- GPIO Orange: Pin (GPIO) corresponding to the output when the orange level is reached (for relays, alarms, and RGB LED).
- GPIO Red: Pin (GPIO) corresponding to the output when the orange level is reached (for relays, alarms, and RGB LED).
This project uses the CanAirIO sensorlib library to support as many sensors as possible out of the box. Thanks to @hpsaturn and CanAirIO team.
CanAirIO sensorlib right now supports:
Sensor model | UART | I2C | Detection mode | Status |
---|---|---|---|---|
Honeywell HPMA115S0 | Yes | --- | Auto | DEPRECATED |
Panasonic SN-GCJA5L | Yes | Yes | Auto | STABLE |
Plantower models | Yes | --- | Auto | STABLE |
Nova SDS011 | Yes | --- | Auto | STABLE |
Sensirion SPS30 | Yes | Yes | Select / Auto | STABLE |
NOTE: Panasonic via UART in ESP8266 maybe needs select in detection
Sensor model | UART | i2c | Detection mode | Status |
---|---|---|---|---|
Sensirion SCD30 | --- | Yes | Auto | STABLE |
Sensirion SCD4x | --- | Yes | Auto | TESTING |
MHZ19 | Yes | --- | Select | STABLE |
CM1106 | Yes | --- | Select | STABLE |
SenseAir S8 | Yes | --- | Select | STABLE |
Sensor model | Protocol | Detection mode | Status |
---|---|---|---|
AM2320 | i2c | Auto | STABLE |
SHT31 | i2c | Auto | STABLE |
AHT10 | i2c | Auto | STABLE |
BME280 | i2c | Auto | STABLE |
BME680 | i2c | Auto | STABLE |
DHTxx | TwoWire | Auto | DEPRECATED |
NOTE: DHT22 is supported but is not recommended
Full details on CanAirIO sensorlib here
Note: If all you want is to flash CO2 Gadget into your board go here:. You don't need to compile the firmware.
First you must edit the file platformio.ini to setup your preferences.
If necessary adjust the upload and minitoring port configuration to match your situation.
upload_speed = 921600
monitor_speed = 115200
upload_port = COM13
monitor_port = COM13
Save the file platformio.ini
We recommend PlatformIO because it is more easy than Arduino IDE. For this, please install first PlatformIO and its command line tools (Windows, MacOs and Linux), pio command, then connect your compatible board to the USB and run the next command:
pio run pio run -e TTGO_TDISPLAY_SANDWICH --target upload
You must replace "TTGO_TDISPLAY_SANDWICH" with the flavour of CO2 Gadget you want copiled and uploaded (the are defined in platformio.ini or you can define your own).
If using PlatformIO GUI, to compile and upload CO2-Gadget into your board, press the"Alien head" -> Project tasks -> Choose flavour -> Upload and Monitor .
These Arduino instructions are outdated. You must adapt it to your situation while I write some new instructions.
To compile this project with Arduino IDE (the integrated development enviroment), you have to install Arduino IDE, and add the libraries referenced in lib_deps in the file platformio.ini, as Arduino won't install it automatically like PlatformIO does.
Also, you need to add the alternative links for supporting the ESP32 boards:
For Arduino IDE: Adding the line https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json in: File > Preferences > Additional Boards Manager URLs.
In Arduino IDE seleect your board, COM port, etc. in the Tools menu and to upload to your board select Program -> Upload or click on the "upload" icon.
To compile this project with Arduino CLI (the command line version of Arduino), you first need to install arduino-cli or the Arduino IDE with the libraries referenced in lib_deps in the file platformio.ini, because Arduino won't install it automatically like PlatformIO does.
You must add the alternative links for supporting the ESP32 boards in Arduino CLI: Follow the next steps:
arduino-cli config init
in the .arduino15/arduino-cli.yaml
file add:
board_manager:
additional_urls:
- https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
From arduino-cli
you can load CO2 Gadget in an ESP32 board following these steps:
arduino-cli core update-index
arduino-cli core install esp32:esp32:esp32
arduino-cli compile --fqbn esp32:esp32:esp32 CO2_Gadget.ino
arduino-cli upload --fqbn esp32:esp32:esp32:UploadSpeed=115200 -p /dev/ttyUSB0 basic
If you want to contribute to the code or documentation, consider posting a bug report, feature request or a pull request.
When creating a pull request, we recommend that you do the following:
- Clone the repository
- Create a new branch for your fix or feature. For example, git checkout -b fix/my-fix or git checkout -b feat/my-feature.
- Run to any clang formatter if it is a code, for example using the
vscode
formatter. We are using Google style. More info here - Document the PR description or code will be great
- Target your pull request to be merged with
development
branch
- Implement full support for PM
- Test and enable ESP-Now feature
- Full configuration vía web page
Thanks to all collaborators, contributors and eMariete community for testing and reports.
Copyright (C) 2021 CO2 Gadget Contributors
Contact: https://emariete.com
This file is part of the CO2 Gadget firmware.
The CO2 Gadget firmware is free software: you can
redistribute it and/or modify it under the terms of the GNU Lesser General
Public License as published by the Free Software Foundation, either version
3 of the License, or (at your option) any later version.
The emariete.com Website and Documentation is distributed in the hope
that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the emariete.com Website and Documentation. If not, see
<http://www.gnu.org/licenses/>.