An easy to build CO2 Monitor/Meter with Android and iOS App for real time visualization and charting of air data, data logger, a variety of communication options (BLE, WIFI, MQTT, ESP-Now) and many supported sensors.

Overview

PlatformIO Telegram Group Twitter Follow

CO2-Gadget

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).

CO2 Gadget

Features (WIP)

  • Many popular CO2 sensors supported: Sensirion SCD30, Sensirion SCD40, Sensirion SCD41, Senseair S8 LP, 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, serial port and web page
  • 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

Supported hardware and build

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.

Supporting any other ESP32 board is very easy. Also, the are a large number of displays already supported.

Supported sensors

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:

PM sensors

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

CO2 sensors

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

Environmental sensors

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

Building from repository

First you should edit some files with your own data and preferences.

Edit the credentials.h file substituting "MyWiFiSSID" with your own WiFi SSID and "some_secret_password" with your own WiFi password in:

#define  WIFI_SSID_CREDENTIALS  "MyWiFiSSID"
#define  WIFI_PW_CREDENTIALS    "some_secret_password"

If you prefer not to keep sensitive data in a file, you can define this data in environment variables so you don't need a credentials.h file with your secrets. See platformio.ini file for instructions.

If you are planning to use MQTT with authentication, substitute "MyUser" with your own MQTT user and "another_secret_password" with your own MQTT user password:

#define MQTT_USER_CREDENTIAL "MyUser"
#define MQTT_PW_CREDENTIAL "another_secret_password"

You are done with credentials. Save the file credentials.h

PlatformIO (recommended)

Edit the file platformio.ini

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

If you are planning to use MQTT, edit the IP of your MQTT broker, substituting 192.168.1.145 with your broker IP address:

-D MQTT_BROKER_SERVER="\"192.168.1.146"\"

Save the file platformio.ini

Compiling and Installing

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 --target upload

If using PlatformIO GUI, to compile and upload CO2-Gadget into your board, press the"Alien head" -> Project tasks -> Upload and Monitor (in the image the sanwitch version is selected).

Arduino

These Arduino instructions are outdated. Sou must adapt it to your situation while I write some new instructions.

Prerequisites

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.

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.

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.

For Arduino CLI: Follow the next steps:

arduino-cli config init

in the .arduino15/arduino-cli.yaml file add:

board_manager:
  additional_urls:
    - https://arduino.esp8266.com/stable/package_esp8266com_index.json
    - https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

Compiling and Installing

With Arduino IDE you just have to select Program > Upload

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

Supporting the project

If you want to contribute to the code or documentation, consider posting a bug report, feature request or a pull request.

GitHub stars GitHub forks

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

TODO

  • Test and enable WIFI feature
  • Test and enable MQTT feature
  • Test and enable ESP-Now feature
  • Test and enable OLED Display support
  • Implement full support for PM
  • Enable enable and disable BLE, WiFi and MQTT without recompiling by activating/deactivating on the buit in menu

Credits

Thanks to all collaborators, contributors and eMariete community for testing and reports.


License

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/>.
Issues
  • WIFI password length limit

    WIFI password length limit

    HI, I have build a CO2 sensor using the CO2 Gadget from mariete. It works fine in its standalone configuration. Now I would like to activate the wifi. unfortunately, it seems that the length of the password is limited to 28 characters whereas my wifi password uses 37 cars. Do you confirm this limit ? If yes is it possible to increase this length ?

    Regards

    bug enhancement 
    opened by zorg2015 4
  • smartphone styles

    smartphone styles

    A media query is added to adapt the CO2 meter website to the smartphones screen, making the graphics to be put in columns when the screen width resolution goes below 640px.

    enhancement 
    opened by acmatl 4
  • CO2 Gadget unresponsive if trouble connecting to MQTT broker

    CO2 Gadget unresponsive if trouble connecting to MQTT broker

    As conversation started at the Telegram group (https://t.me/emariete_chat/31250):

    Under some circumstances (not always), if MQTT functionality is enabled and there are issues connecting to the MQTT broker the action of trying to connect to the broker unsuccessfully blocks execution for some seconds, making CO2 Gadget unresponsive (menu not working as CO2 Gadget is working heavily to reconnect to the MQTT broker).

    bug 
    opened by melkati 4
  • Add and test CO2 sensors others than SCD30 and SCD4x

    Add and test CO2 sensors others than SCD30 and SCD4x

    TODO

    • [x] Include in menu the selection for CO2 sensors others than SCD30 and SCD4x
    • [x] Save sensor selection to preferences (NVR)
    • [x] Include the necessary logic lo support sensor selection (including serial connected sensors)
    • [X] Test SCD30 Sensor
    • [X] Test SCD41 Sensor
    • [x] Test MHZ19 Sensor
    • [X] Test CM1106 Sensor
    • [X] Test SENSEAIRS8 Sensor
    • [x] Document sensor selection on blog page
    enhancement 
    opened by melkati 3
  • Web page from internal web server won't load if BLE is enabled (or initialized)

    Web page from internal web server won't load if BLE is enabled (or initialized)

    CO2 Gadget displays a very basic (for now) web page with the latest CO2 readings at "https://your-co2-gadget-ip-address"

    If works fine if BLE is not active but if BLE is active you get a "connection rejected" error.

    If activeBLE = false or initBLE() is commented out this doesn't happens.

    bug help wanted 
    opened by melkati 3
  • 'Test functionality double click' notification pops up when clicking fast on navigate down button in menu

    'Test functionality double click' notification pops up when clicking fast on navigate down button in menu

    When I navigate the menu and click twice a bit fast on the bottom button, a notification windows appears with text "Test functionality double click" and doesn't disappear.

    This is likely left over code from some test, but it interferes with menu navigation.

    opened by hapklaar 2
  • Choose to Hide/Show specific measurements on the display

    Choose to Hide/Show specific measurements on the display

    In some cases, we do not have a temperature / humidity sensor or we do not want to see these values on the screen. It would be nice to be able to hide this information.

    enhancement 
    opened by juanluis8686 2
  • Store encrypted passwords

    Store encrypted passwords

    First at all, hide passwords in menu.

    If you want to change any password you must to type it again completely.

    Maybe is possible to store passwords with MD5 encrypt / decrypt code?

    enhancement 
    opened by Coscolin 2
  • Trying to add a BME280 to my CO2 gadget with MH-Z19B

    Trying to add a BME280 to my CO2 gadget with MH-Z19B

    First of all thank for your work on this. I love the project!

    I'm not sure if this should be a feature request or if this should already work. I've built the CO2 gadget and really love it. I'm using it with a MH-Z19B sensor together with an 18650 in a case I found somewhere and it works fantastic.

    I would like to add a BME280 sensor for temp/humidity/air pressure measurement, but haven't been able to get it working yet. From the documentation it wasn't clear to me if this should be possible with the precompiled firmware, so I just tried.

    I've connected it to the i2c bus at pins 21/22 and to the 3.3v output of the T-Display, but it doesn't seem to get detected when checking the console output. (also tried swapping 21 and 22 as I wasn't sure which one was SDA and SCL)

    Can you enlighten me on how to proceed?

    opened by hapklaar 1
  • Add option to select if outputs should work in «relay mode» or «LED mode»

    Add option to select if outputs should work in «relay mode» or «LED mode»

    From conversation in blog

    As the outputs double as relay and regular RGB LED there is an related effect:

    The orange output is not turned off when red goes on (to keep ventilation or air cleaning equipment working when CO2 rises). This means when a RGB LED is connected when the LED lights red, yellow will be still on so there is not a "only red" light.

    To fix it when working with LED I’ll include a new option in menu to select if these outputs should work in «relay mode» (keeping orange on when red goes on) or «LED mode» (turning orange off when red goes on).

    enhancement 
    opened by melkati 1
  • Add WS2812B LEDS (NeoPixels) to show CO2 level

    Add WS2812B LEDS (NeoPixels) to show CO2 level

    Based on Adafruit Library to save on memory (FastLED needs more memory).

    To start with it will support 10 LEDs (pixels), all with the same color. Color will be same as display with same definitions for Green, Yellow and Red. In the future I can add independent options if there is a need.

    • [x] Create define for GPIO to connect LEDs
    • [x] Add functionality to code
    • [x] Add menu selector for RGB, GBR, NEO_RGBW, etc
    • [ ] Add power-saving (auto OFF) with battery
    • [x] Test functionality
    • [x] Take configuration menu screenshot
    • [x] Create documentation on how to use
    enhancement 
    opened by melkati 1
  • Add support for ESP32-C3

    Add support for ESP32-C3

    Is your feature request related to a problem? Please describe. Please add support for esp32-c3 cpu.

    Describe the solution you'd like To be able to compile for the esp32-c3

    Describe alternatives you've considered I have tried to modify the code, but the code, and libs that are used, assume that all esp32 cpus have serial2, which the esp32-c3 doesn't. Even though I am able to compile the code, I can't get it running. Don't know what is wrong.

    enhancement 
    opened by errolt 0
  • Fix esp32dev environent

    Fix esp32dev environent

    The esp32dev environment doesn't build. It lacks display functions that are expected by the rest of the code. Also added the ability to define custom I2C pins from platform.ini Some other fixes to get menu working over serial, even if no display is connected.

    opened by errolt 0
  • Cannot configure

    Cannot configure "longer" mqtt topic than previously configured

    Describe the bug When I want to configure a longer mqtt topic name than previously configured, I cannot add the additional characters. So if my topic was co2 I cannot change it to co2-sensor for example.

    To Reproduce Steps to reproduce the behavior:

    1. Go to 'Configuration/MQTT Config'
    2. Scroll down to 'Topic'
    3. Change 'Topic' to 'co2'
    4. Save configuration
    5. Go back to 'Configuration/MQTT Config'
    6. Scroll down to 'Topic'
    7. Change 'Topic' to 'co2-sensor'
    8. It is not possible to add the - character.

    Expected behavior It should be possible to add characters after the last character of the previous setting.

    Additional context Looking at the code, the problem might be related with truncating the tempstring before copying it to the used value here: https://github.com/melkati/CO2-Gadget/blob/master/CO2_Gadget_Menu.h#L383

    Note that this pattern is used for most settings.

    bug 
    opened by cakoolen 1
  • wifi and mqtt broker reconnect attempts in case connection is lost

    wifi and mqtt broker reconnect attempts in case connection is lost

    Would be great also if in an instable wifi environment, the gadget would try the reconnect to the AP in case the link is lost (including the MQTT broker). At this moment both are going to off.

    enhancement 
    opened by freddujour 2
  • Time scheduler for relay outputs

    Time scheduler for relay outputs

    I want to make a Co2 meter using sensirion scd30 + lilygo ttgo t-display for a greenhouse. I want the device to control an electromagnetic gas valve that opens at 1000ppm and closes at 1500ppm. If there is a solution I would like to thank you very much.

    enhancement 
    opened by RolandGy 0
  • Add support for ESP-NOW (inexpensive and easy LoRa alternative)

    Add support for ESP-NOW (inexpensive and easy LoRa alternative)

    ESP-NOW is already working in my "Ultra Low Power Consumption CO2 Meter" and in the "ESP-NOW to MQTT Gateway" (both still unpublished) so must adapt and include source code.

    • [x] Add functionality to code and include options in preferences to save to NVR
    • [x] Add configuration to menu
    • [ ] Add ESP-NOW icon to display to show status
    • [x] Test functionality
    • [x] Take configuration menu screenshot
    • [x] Create documentation on how to use
    enhancement 
    opened by melkati 1
Releases(v0.5.069)
Get air quality & CO2 data from SM300D2 & Senseair S8 with ESP32, and export as OpenMetrics (Prometheus exporter) via WiFi.

ESP Air Sensor Get air quality & CO2 data from SM300D2 & Senseair S8 with ESP32, and export as OpenMetrics (Prometheus exporter) via WiFi. I used to h

Shell Chen 4 Feb 6, 2022
ON AIR or OFF AIR Monitor with WFH

wfh_monitor_m5 M5 Stack ON AIR or OFF AIR Monitor with WFH Dependency Arduino IDE==1.8.13 Blynk==1.0.0 Setup Hardware M5 Stack Smartphone(Android or i

karaage 4 Feb 26, 2022
Real-time 2D fluid simulator with lots of visualization options.

Fluid Simulator Building Start by cloning the program and all submodules using the following command: git clone --recursive https://github.com/linusmo

Linus Mossberg 26 Jun 20, 2022
ESP Insights is a remote diagnostics solution that allows users to remotely monitor the health of ESP devices in the field.

ESP Insights is a remote diagnostics solution that allows users to remotely monitor the health of ESP devices in the field.

Espressif Systems 28 Jun 21, 2022
Serial Data Monitor is a multiplatform (Windows, Linux, Mac, ...) tool to interactively receive/edit/monitor data and send commands to an embedded system via the serial bus

See wiki for full documentation Serial Data Monitor Description Serial Data Monitor is a multiplatform (Windows, Linux, Mac, ...) tool to interactivel

monnoliv 4 Oct 29, 2021
Controlling Servos with a Esp-wroom-32 via MQTT with an Android Client

esp32_servos_mqtt Controlling Servos with a Esp-wroom-32 via MQTT with an Android Client Added two files, first is the schematic for the connection wi

Xamanek Martínez Marín 2 Jan 1, 2022
Fatality song composed by Maevings with charting and psych engine

Fatality song composed by Maevings with charting and psych engine

null 2 Nov 27, 2021
Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2

Filament Filament is a real-time physically based rendering engine for Android, iOS, Linux, macOS, Windows, and WebGL. It is designed to be as small a

Google 14.3k Jul 1, 2022
Analytics In Real-time (AIR) is a light-weight system profiling tool

Analytics In Real-time Analytics In Real-time (AIR) is a light-weight system profiling tool that provides a set of APIs for profiling performance, lat

null 2 Mar 3, 2022
If the button pressed esp will reset and App mode will on. App mode will on then led will on, network is connected led will off.

DHT22-to-Google-sheet-Reset-Using-ESP8266-LED-Switch If button pressed esp will reset and App mode will on. App mode will on then led will on, network

Md. Harun-Or-Rashid 4 Oct 5, 2021
Emergency alert and tracer for realtime high-performance computing app (work in progress, currently supported env is only Linux x86-64).

HPC Emerg Emergency alert and tracer for realtime high-performance computing app (work in progress, currently supported env is only Linux x86-64). Exa

Ammar Faizi 7 Jan 19, 2022
🗺️ OMAPS.APP — Offline OpenStreetMap maps for iOS and Android. A community-driven fork of MAPS.ME.

OMaps is an open source cross-platform offline maps application, built on top of crowd-sourced OpenStreetMap data. It was publicly released for iOS and Android.

OMaps 3.5k Jun 26, 2022
Fix some extrinsic parameter importing problems. 6-axis IMU works now. Lidar without ring works now.

LVI-SAM-MODIFIED This repository is a modified version of LVI-SAM. Modification Add function to get extrinsic parameters.The original code assumes the

null 64 Jun 22, 2022
Allows you to easily control via MQTT any Micronova equiped pellet stove. (MCZ, Extraflame, Laminox, and many others brands!)

micronova_controller Kits are available on Tindie! Currently out of stock. V2 will be in stock soon! Here is an overview of the additions: possibility

Philibert Cheminot 27 Apr 13, 2022
multispectral monitoring of a sourdough starter; esp32 eink module, scd30 co2 sensor, vl6180 distance sensor

EINK STARTER MONITOR See full blogpost here Tracks height of starter with a VL6180 i2c distance sensor, and CO2/temperature/humidity with an SCD30. A

AKA 15 Feb 16, 2022
Pocket-sized CO2 sensor

CO2 Tin. Measure local CO2 (and temp, humidity) in a device you can easily toss in a pocket. Major components: CO2 Sensor : https://www.adafruit.com/p

Rusty Nicovich 3 Jan 2, 2022
A customized LGL Android mod menu, containing ESP only for PUBG Mobile 1.3.0 for Android

PUBG Mobile ESP Mod Menu A customized LGL mod menu, containing ESP only for PUBG Mobile 1.3.0 for Android. Everything are fixed so it works with both

null 42 Mar 19, 2022
Vaccine Monitor app implemented in C with system Programming techniques.Projects implemented as part of the course Syspro K24

System_Programming_Projects Vaccine Monitor app implemented in C with system Programming techniques.Projects implemented as part of the course Syspro

Aristi_Papastavrou 10 Dec 30, 2021