ESP32/IoT B.Tech/Diploma Beginner

Indoor Air Quality Analysis using ESP32 & Bytebeam Cloud

ESP32 Indoor Air Quality analysis using CO2 monitoring system based on Bytebeam Cloud ESP-IDF SDK to measure temperature & humidity

  • Suitable forB.Tech/Diploma ESP32/IoT students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

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.

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.

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

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

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

#include "ccs811/ccs811.h"
#include "sht31.h"
inside
app_main
initialise the
ccs811
CO2 sensor

if
(
init_ccs811
(
)
)
{
printf
(
"\nInitialized!!!\n"
)
;
}
else
{
printf
(
"\nNO Initialized\n"
)
;
}
Now initialise SHT31 sensor

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

getSHTValues
(
)
Now add Co2, temperature and humid values to the payload

carbon_json
=
cJSON_CreateNumber
(
get_ccs811
(

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

#define BLINK_GPIO 4
Now flash and upload
indoorAirQuality
example
In
configure_blinds
function, we will configure the GPIO mode as
GPIO_MODE_OUTPUT

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

bytebeam_add_action_handler
(
&
bytebeam_client
toggle_blinds
"toggle_blind"
)
;
Flash and Upload
Now flash and upload the example

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++

<
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

Technologies used

ESP32RelayI2CSPIC++

Hardware components

  • ESP32
  • Relay

Software & tools

  • Arduino IDE

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.