This repository contains scripts and notebooks for forecasting CO2 levels using data from an STM32 CO2 sensor. The project involves collecting sensor data, enhancing it, and using time series forecasting models to predict future CO2 levels.
The repository is divided into several parts:
- Data Collection: A Python script for reading UART data from the STM32 CO2 sensor, saving it to a CSV file, and plotting the collected data when stopped with CTRL+C.
- Data Enhancement: A Python script for preprocessing the data by adding lags, splitting dates, and handling occupancy.
- Forecasting: A Colab notebook that performs time series forecasting on the enhanced data using SARIMAX models.
- Introduction
- STM32 Projects
- Data Collection
- Data Processing
- Time Series Analysis
- Results
- Usage
- Warning
- Contributing
- License
- Contact
This project aims to forecast CO2 levels using data collected from an STM32-based CO2 sensor. The data is processed and analyzed using Python libraries to create predictive models.
This project leverages the following STM32 projects:
- STM32 SDC30 CO2 Sensor: Project for interfacing with the SDC30 CO2 sensor.
- STM32 16x2 LCD: Project for displaying data on a 16x2 LCD screen.
Data was collected over a period of two weeks in a single room at work. The measurements were taken using a CO2 sensor connected to an STM32 microcontroller. The collected data includes CO2 levels, temperature and humidity.
Data processing involves cleaning and preparing the dataset for analysis. The steps include:
- Handling missing values
- Removing infinite values
- Normalizing the data
- Creating lag features
Time series analysis is performed using the SARIMAX model to forecast future CO2 levels. The analysis includes:
- Checking for stationarity
- Differencing the data if necessary
- Auto ARIMA to find the best model parameters
- Fitting the SARIMAX model
The results include the forecasted CO2 levels compared to the actual data. The predictions are visualized to show the accuracy of the model.
To use this project:
- Clone the repository.
- Install the necessary Python libraries.
- Run the data processing and analysis scripts.
- Use the provided Jupyter notebooks for detailed analysis and visualization.
Key Points:
- Accuracy: The forecasted results and accuracy metrics are based on the data and methods used during the internship. These estimates may not be fully accurate or reliable for practical applications.
- Data Collection: The data was collected over a two-week period in a single room at work, which may not represent broader or different conditions.
- Model Limitations: The forecasting models used in this project are based on certain assumptions and parameters which may not generalize well beyond the specific context of the collected data.
For any critical applications, further validation and refinement of the models and methods should be performed. Use the findings from this project as a starting point for further exploration and development.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or suggestions, contact cherifjebali0301@gmail.com.