CO2 Monitor on your cell phone with ESP32 and Sensirion SCD30 sensor [BASIC VERSION]

Last modified October 13, 2021

Welcome to this tutorial in which you will learn how to build the basic version of the CO2 monitor with App for Android and iOS, using Bluetooth, following the official project of the sensor manufacturer Sensirion.

I estimate that you can complete the project in less than an hour, following the steps of the tutorial.

Both, the firmware like like App of this CO2 monitor have been prepared by Sensirion, one of the world's largest manufacturers of high quality CO2 sensors and, therefore, what else do you know about your measurement?

The CO2 monitor works very well, we couldn't expect less coming from one of the world's leading CO2 sensor manufacturers, as is the case with Sensirion.

By the way, the mobile app is very professional and of high quality. I'm sure you are going to love it.

The sensor used is the SCD30. A high quality dual channel NDIR sensor , with integrated temperature and humidity sensor. One of the best options available on the market at a reasonable price.

As the most important data of the Sensirion SCD30, we could name the following:

CO Sensor Specifications2
CO measurement range20 - 40'000 ppm
Precision± 30 ppm + 3% of measurement
Humidity Sensor Specifications
Relative humidity measuring range0 - 100 % HR
Typical accuracy± 3% HR (0-100% HR)
Temperature sensor specifications
Temperature measuring range-40 ° C - 70 ° C
Typical accuracy (° C)± (0.4 ° C + 0.023 x (T [° C] - 25 ° C))
Electric specifications
Supply voltage3.3 - 5.5 V
Average current measurement rate @ 2s19 mA
Current max.75 mA
Sensirion SCD30 Key Specifications

If you want to know more, you can download here the SCD30 datasheet.

Sensirion SCD30 CO2 Sensor

The main objective of having prepared this detailed tutorial is to make it easier to build for everyone, especially for people who do not know much about electronics and / or programming with Arduino.

It is a project suitable for all levels and the result is very good. Completely professional!

This tutorial is accompanied by a video, which you can find below, with everything explained step by step and in detail.

In this tutorial you will see, step by step, how to:

  1. Prepare the Hardware: Learn how wire the sensor to the ESP32 development board
  2. Flash the firmware on the development board
  3. Monitor CO2 levels in you computer and on cell phone or tablet by using the Sensirion MyAmbience App
  4. Extras: Some tips, advice and additional information

Also shortly you will find something that I am sure you will love: My own improved version of the firmware with cool new features:

  • More operating modes: Bluetooth, WIFI, and maybe ESP-Now
  • More sensors supported, both CO2 and temperature, humidity and pressure
  • Consumption optimizations for battery use
  • Support for more displays
  • Sending data by MQTT
  • Configuration via web page
  • Updates through a built in web page

Build it now and upgrade later!

In this tutorial you will find two versions of the meter. A very simple version, without display, for you to build a compact monitor to visualize the CO2 concentration on your cell phone or tablet and a monitor with color display, ready for battery operation, like this one:

This color display will allow you to view the current CO2 concentration and its level in green, yellow or red, depending on whether the CO2 level is good, bad or very bad.

I have decided to separate the version with color screen in your own article. You will find it here (I recommend that you finish reading this article first, because it is base of the other):

Step-by-step video-tutorial

To begin, there is the step-by-step video tutorial, which accompanies this article. I recommend you watch it, if you haven't already.

Maybe you are also interested in:  What does CO₂ have to do with Covid?

Making these videos takes a lot of work. If you like the video, please, Don't forget to "Like" and subscribe to the channel. That It will motivate me to keep making more videos like these.

Needed parts

To complete this tutorial, you will need:

  • A ESP32 DevKitC-32D Board or a LILYGO® TTGO T-Display ESP32 board for the display version
  • A CO2 sensor Sensirion SCD30
  • Some cables to make the connections
  • USB Cable to connect the ESP32 DevKitC module to your computer

Later, in section "The shopping list" I give you some advice on the material to buy, as well as some useful links to sites where you can buy them at a good price and with guarantees.

Hardware Preparation

Hardware setup is extremely easy.

Carefully connect the SCD30 sensor to the ESP32 DevKitC as you can see in this diagram. Pay attention to each wire so that it goes from the correct pin on the sensor to the correct pin on the board with the ESP32. I recommend that you use wires with different colors to make it easier for you.

ESP32 DEVKITC + SENSIRION SCD30

Please note that your board may have a different layout and pin design. If you are using other pins or have a differently designed board, you may need to adjust the code accordingly.

You have to connect:

  • The VIN pin of the SCD30 to the pin labeled 3.3V of the ESP32
  • The GND pin of the SCD30 to the GND of the ESP32
  • The SCL of the SCD30 to the IO22 pin of the ESP32
  • The pin labeled SDA of the SCD30 to the IO21 pin of the ESP32

I recommend that you use cables with the same colors that I have used to make it easier for you to follow the examples. If you use other colors, pay special attention.

In the case of the version with display, the connection are the same, although the position of the pins changes (* you will soon find detailed images of the version with display on this page, I am in the process of preparing them).

Flashing the ESP32 DEVKIT

"Extra-super-fast and easy" way (recommended)

Flashing the firmware of the Sensirion CO2 monitor to the ESP32 DevKitC-32D Board couldn't be faster and easier. You won't even have to download or install anything on your PC.

Using this option "Extra-super-fast and easy" you will flash the firmware as I have prepared it, without the need for any preparation or to modify anything.

Press the "Install" button, select the port where you have your board connected and press "Connect". That simple, the flashing of the ESP32 will be done in a moment without further complication.

Your browser is not supported! You have to use Windows with Microsoft Edge or Google Chrome to see the button

Traditional option, using the Arduino IDE

With the Arduino IDE you can make the changes you want before flashing the firmware in the ESP32 and adapt it to your tastes, needs and preferences.

You can find the original source code in the repository of Sensirion on GitHub.

Using the meter

You just have to connect it to 5V (using a charger and USB cable, for example), open the Sensirion MyAmbience App on your mobile and visualize the values.

To ensure that the values provided by the sensor are stable, you will have to wait for some time after turning it on. In my tests I have seen that after approximately one minute, values are already completely stable.

This meter, in addition to bluetooth, can work connected to a computer, since it outputs the sensor readings through the serial / USB port every 2 seconds, so that you can see it with a Serial Monitor (the Arduino IDE, for example), graph it (with the Arduino IDE Serial plotter, for example) or process it with any software.

Some additional features of the meter are as follows:

  • Sending by broadcasting of values in real time without the need for a bluetooth pairing.
  • Simultaneous monitoring of sensor data from several bluetooth devices simultaneously (several mobiles and tablets at the same time).
  • Compatibility with Sensirion MyAmbience CO2 App - allows you to monitor your sensors, create charts with the received values and share and export data.
  • Local storage of sensor data for later download (sensor historical download)

When you receive the SCD30 sensor it's probably not calibrated so the CO2 measurements will not be correct. You will have to keep the sensor running for a week (without turning it off) for the automatic calibration to do its job and obtain reliable measurements (more in the next point of this tutorial) or, if you have little patience, you can force a manual calibration.

Maybe you are also interested in:  Sensirion SCD30 NDIR dual-channel CO2 sensor

Sensirion SCD30 Sensor Calibration

Automatic calibration

The Sensirion SCD30 CO2 sensor features an automatic calibration system, called by Sensirion Automatic Self-Calibration (ASC), and it works quite well.

Its operation is as follows:

Since the natural CO2 concentration in the atmosphere is approximately 400 ppm (actually slightly less than 420 ppm on average in 2021), when ASC is enabled, the sensor assumes that, over a period of approximately 7 days, the lowest CO2 concentration it finds will be equivalent to 400 ppm.

This means that in a well-ventilated room with clean air at some point in the seven-day period, the lowest measurement will be around 400 ppm and the sensor will assume that concentration (whatever it is) as the zero point, or 400 ppm.

In other words, the sensor will assume that the lowest measurement in each 7-day period will be 400 ppm.

Yes, I have explained the same thing in three different ways but it is necessary to understand it well because that means that:

  • You cannot use automatic calibration if you are going to use the sensor in a greenhouse, for example, since the greenhouse air will never drop below 400 ppm.

This is a very convenient way to keep the sensor calibrated, using clean air as a reference value and automating the process.

The CO2 meter that I am showing you in this tutorial has the auto calibration enabled and working. Please note that when you build it, you will need to keep the sensor connected and working for seven days in a row (without turning it off) to calibrate (or do a manual calibration, as I indicate below).

Manual calibration

The Sensirion SCD30 CO2 sensor allows manual calibration so you do not have to wait those seven days for it to calibrate automatically but Sensirion has not implemented that possibility in its firmware.

I have prepared a special firmware that is easy to use and install in case you want to calibrate the sensor manually.

This firmware, which it is only used to calibrate the SCD30 sensor at 415 ppm, does the following:

  • When you turn it on, it will wait five minutes for the sensor to stabilize, during which the LED on the board (by default an LED connected to GPIO2) will be flashing every second.
  • After five minutes it will calibrate the sensor and, once calibrated, it will leave the LED on permanently.

All you have to do to calibrate the sensor is to save this firmware, put the meter in a place with clean air (outside a window, for example), turn it on, wait five minutes for the LED to stay on and that's it. is. The sensor will be calibrated at 415 ppm.

Press the "Install" button, select the port where you have your board connected and press "Connect". That simple, the flashing of the ESP32 will be done in a moment without further complication.

Your browser is not supported! You have to use Windows with Microsoft Edge or Google Chrome to see the button

This program is extremely simple. If you want to modify it, or see how it works, you have the source code in the eMariete's GitHub.

An advice: The SCD30 is very sensitive to winds and breezes (like all NDIR sensors, to a greater or lesser extent) so it is important that when taking it outside to calibrate it do not give much air. If there is a certain wind where you are going to calibrate it, you can even put the meter in a transparent plastic bag, not airtight, and press the button through it). If it's already in its box, you shouldn't have a problem.

The shopping list

If you are an advanced user, buy the materials you want wherever you want. You will not need many tips because they are all easy components to buy and without much mystery and if you find any difference you will know how to adapt the tutorial to these differences yourself.

If you don't have that much experience, here are some tips and links to internet sites where I have bought them (with alternatives to sites where other eMariete users have bought them) so they are recommended.

Maybe you are also interested in:  Experiments with ESP Easy (ESP8266) and low consumption - v1.0

By buying the components in these links you will make sure you have exactly the same components of the tutorial and that everything matches (not all boards, for example, even though they look almost the same and are called the same, have all the pins in the same place or are labeled in the same way).

Buy the Sensirion SCD30 sensor

Sensirion SCD30 Sensor

This is the same AliExpress store where I bought it and it arrived at my home in just 7 days.

Almost all eMariete users have purchased the sensor at this link and received it quickly.

Buy the board with the ESP32

ESP32-DevKitC-32D

ESP32 DevKitC-32D Board

Although it is not exactly the same board that I used in the tutorial (it is a somewhat more modern version) it has the same distribution of connections and comes with pins already soldered.

I have bought other things from this AliExpress store and it is completely legit.

You also have the option to buy the board on amazon. It's a bit more expensive (not too much) but you will have it at home quickly.

AZDelivery ESP32 ESP-WROOM-32 NodeMCU WiFi Module + Bluetooth Dev Kit C 2.4 GHz Dual Core Development Board with CP2102 Chip (successor to ESP8266) Compatible with Arduino with E-Book Included!
  • ✅ New on the market: AZ-Delivery ESP32 NodeMcu WiFi CP2102 Development Board Module has the powerful ESP32 Microcontroller installed.
  • ✅ Rapid Prototyping: This ESP32 development board enables dynamic prototyping with simple programming via a Lua script or in the Arduino-IDE and Breadboard compatible build. It integrates Wi-Fi and Bluetooth functions.
  • ✅ Ultra-low power consumption: It features 2.4GHz dual-mode Wi-Fi Bluetooth chips and TSMC, as well as 40nm low-power technology.
  • ✅ More Functions + More Convenient: The module has 38 pins and offers more functions than a 30-pin module. It is smaller and more convenient to use.
  • ✅ This product includes an E-Book that provides helpful information on how to get started on your project, helps with quick setup, and saves time in the setup process. We provide a series of application examples, comprehensive installation guides, and libraries.

Version with color TFT screen

For clarity, I have separated the version with color screen in its own article.

Any problems? Monitor's FAQ

Although the project is very simple, there is always the possibility that you may have a doubt or that some kind of problem may appear.

In the list that you will see below, you have answers to the most common questions and doubts.

2 thoughts on “Medidor de CO2 en tu móvil con ESP32 y sensor Sensirion SCD30 [VERSIÓN BÁSICA]”

  1. Great article! A really useful project would be to get the sensor data of the SDC-30 sent remotely to a Raspberry pi which has MQTT, Node-RED, an Influxdb and Grafana.

    Reply

Leave a Comment