A project for monitoring CO2 levels, temperature, humidity, and pressure using the SCD30 and BMP280 sensors. The data is displayed on an OLED screen and logged for debugging and monitoring purposes.
- CO2 Monitoring: Measures CO2 levels using the SCD30 sensor.
- Environmental Data: Reads temperature, humidity, and pressure from the SCD30 and BMP280 sensors.
- OLED Display: Displays sensor readings and warnings on an SSD1306 OLED screen.
- Logging: Logs sensor data and system messages using the
Loggerclass. - Calibration: Automatically calibrates the SCD30 sensor and stores the calibration flag in EEPROM.
- I2C Scanner: Scans the I2C bus for connected devices.
- PlatformIO for building and deploying the firmware.
makefor running the build and deployment tasks.- Required libraries (automatically installed via
platformio.ini):- Adafruit GFX Library
- Adafruit SSD1306
- SparkFun SCD30 Arduino Library
- Adafruit BMP280 Library
- Clone this repository to your local machine:
git clone https://github.com/your-username/CO2-Meter.git
cd CO2-Meter- Install PlatformIO if you haven’t already:
- Install the PlatformIO extension in Visual Studio Code.
- Alternatively, install it via the command line:
pip install platformio- Install
make:- Windows:
- Install Git for Windows to get Git Bash, which includes the
makecommand. - Alternatively, install
makevia MinGW:- Download and install MinGW.
- During installation, select the
mingw32-makepackage. - Add the MinGW
bindirectory (e.g.,C:\MinGW\bin) to your system's PATH environment variable.
- Install Git for Windows to get Git Bash, which includes the
- Linux/Mac:
- Use your package manager:
- Windows:
sudo apt install make # For Debian/Ubuntu
brew install make # For macOS- Open the project in Visual Studio Code:
code CO2-Meter
- Hardware:
- ESP8266-based board (e.g., ESP-12E or NodeMCU).
- SCD30 CO2 sensor.
- BMP280 pressure sensor.
- SSD1306 OLED display.
- colored wires for connecting the microcontroller sensors, display and power source.
- 5V power source
- 2 tiny bread boards
The following diagram shows the connections between the ESP8266, SCD30, BMP280, and SSD1306 OLED display:
-
Open the project directory in a terminal:
- Windows: Use Git Bash or a terminal where
makeis available. - Linux/Mac: Use your default terminal.
- Windows: Use Git Bash or a terminal where
-
Build the project using the
Makefile:
make build- Connect your ESP8266 board to your computer via USB.
- Upload the firmware to the board:
make upload- Open the serial monitor to verify the output:
make monitorThe project uses a centralized configuration file (config.h) to define constants and settings. You can modify the following parameters to suit your needs:
#define EEPROM_CALIBRATION_FLAG_ADDRESS 0x10
#define CALIBRATION_DONE 1#define CO2_MODERATE_THRESHOLD 1000.0 // ppm
#define CO2_CRITICAL_THRESHOLD 2000.0 // ppm#define DEFAULT_CO2 400.0f
#define DEFAULT_TEMP_SCD 20.0f
#define DEFAULT_HUMIDITY 50.0f#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C- Open the
config.hfile in theincludedirectory. - Update the constants as needed.
- Rebuild and upload the firmware to apply the changes:
make build
make uploadThe Makefile includes additional targets for specific tasks:
make i2c-scanmake display-checkmake cleanmake help- Use Git Bash or a terminal where
makeis available to run the commands. - Ensure that the
makecommand is in your system's PATH. If you installedmakevia MinGW, add theC:\MinGW\bindirectory to your PATH:- Open the Start menu and search for "Environment Variables."
- Click "Edit the system environment variables."
- In the "System Properties" window, click "Environment Variables."
- Under "System variables," find the
Pathvariable and click "Edit." - Add the path to the MinGW
bindirectory (e.g.,C:\MinGW\bin). - Click "OK" to save and close all windows.
This project is licensed under the MIT License.
Contributions are welcome! Feel free to submit issues or pull requests to improve the project.
For questions or support, please use the issue tracker.

