Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Indoor Air Quality Analysis using ESP32 & Bytebeam Cloud
ESP32 Projects IoT Projects

Indoor Air Quality Analysis using ESP32 & Bytebeam Cloud

Vaibhav SharmaBy Vaibhav SharmaUpdated:December 20, 20228 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Indoor Air Quality Analysis using ESP32 & Bytebeam Cloud
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

In this project we are going to build an ESP32 Indoor Air Quality analysis using a CO2 monitoring System based on Bytebeam ESP-IDF SDK & Bytebeam Cloud.


Overview

People typically spend more than 90% of their time in indoor environments. Monitoring of indoor air quality parameters like CO2 plays an important role in a healthy lifestyle. 

Indoor air quality (IAQ) monitoring is a very often talked about topic nowadays as it critically affects a person’s health, comfort, and safety. 

People who might be at their homes, workplace offices etc. typically spend more than 90% of their time in indoor environments. So, It is not only directly related to occupational health but also has a significant impact on the quality of life of people. 

One of the key indicators of indoor air quality is Carbon dioxide (CO2) and it has a  substantial influence on public health. Thus, regular monitoring and Analysis of indoor air quality parameters like CO2 becomes essentially important to regulate occupational health and ensure better working environments

Some of the Factors affecting indoor CO2 levels include:

  • Number of people in a room 
  • Person’s metabolic rate 
  • Amount of time a person spent in the room
  • Ventilation rate (exchanges per hour with fresh outside air)

Keeping in mind all the factors affecting indoor CO2 levels we will be going through a step-by-step guide to creating a IoT solution for CO2, temperature and Humidity monitoring using ESP32 and Bytebeam Cloud. In this blog we will be demonstrating the following:

  • Setting up ESP32 
  • Interfacing CO2 sensor and Temperature and Humidity Sensor with ESP32
  • Interfacing relay with ESP32 to control window blinds to regulate ventilation.
  • Setting Up Bytebeam ESP-IDF SDK.
  • Integrating ESP32 with Bytebeam Cloud
  • Visualising CO2 sensor data on Bytebeam Cloud Dashboard.

So Let’s get started. 




Hardware and Software Specifications


HardwareSpecifications

  • ESP32 
  • CCS811 eCO2 sensor
  • SHT31 Temperature and Humidity Sensor
  • 5V SSD Relay

Software Specification

  • Bytebeam cloud platform account
  • ESP-IoT Development Framework
  • Bytebeam ESP-IDF SDK
  • SHT31 ESP-IDF Library
  • CCS811 ESP-IDF Library
  • Indoor Air Quality ESP-IDF application

Setting Up Bytebeam Cloud

Bytebeam is a fully managed cloud platform. Which serves all cloud needs from device management to dashboard, Handling actions and notification to OTA updates. It provides the following features

  •  Device Registry
  • Over The Air Updates
  • Configuration Management
  • Device to the mobile communication
  • Web Dashboard
  • Role-based Access controls

If you are new to the Bytebeam IoT cloud platform. Go through the getting started with bytebeam tutorial to dive deep into the concepts of Bytebeam.

I hope you found the getting started guide useful and are aware of the concepts of Bytebeam cloud. 

  • Next as we are using temperature, humidity and CO2 parameters. We need to configure stream according to our project in Bytebeam cloud console. For that go to Admin -> Streams and add temperature, humidity and carbon in the column name with their respective data type. 

  • Now we need to download a device provisioning file from the console. We will need this file later for device provisioning. For that go to Device Management and click on Download config.

  • Rename this file as device_config.json



Setting Up ESP32


Hardware connection

ESP32 uses GPIO 21 and GPIO 22 pins for I2C. SDA pin is connected to GPIO 21 and SCL pin is connected to GPIO 22.

  • CCS811 CO2 sensor comes with I2C connection. Connect SDA Pin of CCS811 with GPIO21 of ESP32 and SCL Pin with GPIO 22 of ESP32.
  • SHT31 Temperature and Humidity Sensor comes with I2C connection. Connect SDA Pin of ESP32 with GPIO21 of ESP32 and SCL Pin with GPIO 22 of ESP32.
  • Connect 5V SSD Relay with GPIO 4

Project Setup

  • Clone esp-bytebeam-sdk using the git clone command.

1
git clone https://github.com/bytebeamio/esp-bytebeam-sdk.git

  • The Repository contains the following directories
    • components: This directory contains bytebeam_esp_sdk as a component that you can add to your ESP application
    • Provisioning: example to push device JSON got from bytebeam cloud to SPIFFS.
    • example: examples directory contains a list of examples, some of the important ones are
  • Now clone the indoorAirQuality example.

1
git clone https://github.com/vbshightime/indoorAirQuality

  • Paste it inside esp-bytebeam-sdk directory.

Provision ESP32 with device config data

Earlier in this guide, we had provisioned a new device in bytebeam cloud console and downloaded a JSON file. We need to flash this file to SPIFFS to connect our device to the cloud.

    • Now navigate to the provisioning example and create a new folder config_data inside it.
    • Put the device_config.json inside config_data.
    • Now open ESP-IDF terminal and navigate to the provisioning project.
    • Clear entire flash

1
idf.py erase-flash

  • Once the flash is erased, upload the provisioning example. This will flash the device_config.json file to the device

1
idf.py -p PORT flash monitor


Getting CO2 Sensor and Temperature & Humidity Values

  • Navigate to indoorAirQuality-> main -> app_main.c.
  • include ccs811 driver and sht31 driver

1
2
#include "ccs811/ccs811.h"
#include "sht31.h"

  • inside app_main initialise the ccs811 CO2 sensor

1
2
3
4
5
6
if (init_ccs811()){
        printf("\nInitialized!!!\n");
    }
    else{
        printf("\nNO Initialized\n");
    }

  • Now initialise SHT31 sensor

1
2
3
4
5
if (sht31_init()) {
        printf("Initialised SHT31");
    } else {
        printf("Could not initialize SHT3x sensor\n");
    }

  • We will get the Co2 values using get_ccs811() function.
  • We will get temperature and humidity values using getSHTValues().

1
getSHTValues()

  • Now add Co2, temperature and humid values to the payload

1
2
3
4
5
6
carbon_json = cJSON_CreateNumber(get_ccs811(0));
cJSON_AddItemToObject(device_shadow_json, "carbon", carbon_json);
humid_json = cJSON_CreateNumber(humidity);
cJSON_AddItemToObject(device_shadow_json, "humidity", humid_json);
temperature_json = cJSON_CreateNumber(temperature);
  cJSON_AddItemToObject(device_shadow_json, "temperature", temperature_json);



Creating an action handler to control blinds

Increasing levels of CO2 in the workspace can cause laziness and sleepiness. So to regulate the flow of fresh air. We are using a relay to open and close window blinds to improve airflow. We will trigger this action whenever the CO2 levels cross a particular threshold(1000PPM)

We can create an action handler using these simple steps.

  • We have connected the 5V SSD relay to GPIO 4

1
#define BLINK_GPIO 4

  • Now flash and upload indoorAirQuality example
  • In configure_blinds function, we will configure the GPIO mode as GPIO_MODE_OUTPUT

1
2
3
4
5
static void configure_blinds(void)
{
   gpio_reset_pin(BLINK_GPIO);
   gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
}

  • Add an action handler using the bytebeam_add_action_handler function. It contains the following arguments
  • bytebeam_client: structure containing host, port, certificates and device id information
  • toggle_blinds: handler function to toggle relay
  • toggle_blind: action name

1
bytebeam_add_action_handler(&bytebeam_client, toggle_blinds, "toggle_blind");

 


Flash and Upload

  • Now flash and upload the example

1
Idf.py -p PORT flash monitor

In the next section, we will add “toggle_blind” action on the bytebeam cloud.


Adding action on Bytebeam cloud

C++
1
2
<code>&lt;li style="list-style-type: none"&gt;
</code>

  • Login to your bytebeam cloud account and go to the Device Management tab
  • Here you can see preconfigured actions like Update Firmware, Update Configuration, and Push File.
  • To create a new action Click on the Admin tab and then navigate to Actions. Then click on Create Action to configure a new action.

  • On the next screen, you can see a Type edit text and a drop-down to select Icon.
  • In Type edit text we need to write down the action name i.e. toggle_board_led in our case. Earlier in Configuring actions in the ESP32 section we created an action handler with toggle_blind as the action name.
  • Then select an icon from the drop-down. We have selected the power off icon for this example. You can choose any from the list. Then hit submit
  • Now you can find newly created actions on the action list

 


Triggering an Action

We need to follow these easy steps to trigger an action:

  • Navigate to the Devices tab under Device Management
  • Click on the checkboxes to select the list of devices you want to trigger the Action 

    • Click on the Action button you want to trigger. In our case, we have selected a device with #id 1 and triggered ‘Toggle Blind‘ Action.
    • In the Last Action column, you can see the Action status as Queued and you can monitor the progress of the action from the progress bar 
    • The Action will be sent to the selected Devices now. If the device is offline when the Action is triggered, the system will retry sending Actions to the device every 5s.
    • After successful execution of the action, the Action status will be charged to Completed.
    • Here action we need to perform is to automate our windows blinds when the CO2 level crosses a threshold.
    • Earlier before triggering the action. The status was “Blinds are closed”.

  • After triggering Toggle Blind action. The status changed to Blinds are open. And action status changed to Completed.




Data Visualization in Bytebeam cloud

  • After the Successful connection of ESP32 with Bytebeam cloud. We can see the recent device shadow and heartbeat on the cloud console.

ESP32 Indoor Air Quality Monitoring

 

  • Next, create a Dashboard of your choice We have made use of line charts and gauges to create our dashboard. You can use it as per your choice.

ESP32 Indoor Air Quality Monitoring

 


Guidelines to Check CO2 levels in a workplace

Escalation in CO2 levels in a workplace can affect your health in different ways. The CO2 levels can differ based on occupancy, ventilation and respiration rate. Increasing level can also cause laziness, sleepiness, dizziness etc.

Carbon Dioxide concentration Description of indoor quality
350-400 PPM Fresh Air
< 600 PPM  Acceptable conditions of indoor air quality in rooms
1000 PPM The Upper limit of fresh air. But need to open windows can cause laziness
1500 PPM Not fresh Air 
2000 PPM Can cause respiratory illness and dizziness 
>1000 PPM Bad air quality and problems with breathing

 

  • As we can see in the graph variation in CO2 level as the occupancy and ventilation in the room changes

ESP32 Indoor Air Quality Monitoring


Conclusion

In this way you can build an Indoor Air Quality Analysis using ESP32 & Bytebeam Cloud to monitor the sensor data regularly on Cloud. I hope you find this guide useful. We will come up with more interesting tutorials and maker content. Stay tuned.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleInterfacing MAX30100 Pulse Oximeter Sensor with Arduino
Next Article Build a DIY Customized Mini PC using Raspberry Pi 4

Related Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

Updated:June 16, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

Updated:June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20262K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
Add A Comment

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 16, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use ADS1115 16-Bit ADC Module with Arduino
    How to use ADS1115 16-Bit ADC Module with Arduino
  • Interfacing PN532 NFC RFID Module with Arduino
    Interfacing PN532 NFC RFID Module with Arduino
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • DIY AC Energy Meter using PZEM-004T & Arduino
    DIY AC Energy Meter using PZEM-004T & Arduino
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.