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

Last modified 1 year

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 and the App of this CO2 meter have been prepared by Sensirion, one of the largest manufacturers of quality CO2 sensors in the world and, therefore, who knows more about its 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

Be sure to try my own extended version of firmware with cool new features:

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

You have it in the following article:

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 decided to separate the version with color screen in its own article. You'll find it here (I recommend you finish reading this article first, because it is the basis of the other one):

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.

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.


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:

  • Real-time broadcasting of values without the need for a bluetooth connection.
  • 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 will probably not be 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 get reliable measurements (more in the next point of this tutorial) or, if you have little patience, you can force a manual calibration.

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.

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

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

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

  1. Bonjour Mariete,
    Je vous remercie beaucoup pour votre réponse.
    As you suggested, I have gone a little further in my research and indeed I have found all the answers to my questions.
    C'est vraiment un projet extraordinaire, très utile (surtout en ce moment) pour un prix raisonnable de plus vos explications sont très détaillées et d'une très grande précision pour un novice comme moi.
    Je vais consulter votre site car il y a des applications qui m'intéressent beaucoup.
    Merci encore


  2. Bonjour Mariete,
    J'ai réalisé votre excellent projet, merci beaucoup pour vos indications très claires.
    Before putting this beautiful realization in a box worthy of the name I would just like to tell you that in my case the temperature and humidity readings are not quite close to reality. There is an offset of 3.3 degrees and about 5% for the hygrometry.
    My question is the following. Can one modify the offset for these two measurements in order to obtain a result close to reality?
    En attendant de vous lire, par avance je vous remercie beaucoup et bravo encore pour votre travail.
    P.S. I am not a computer specialist.

  3. I have mounted it in ESP32WROOM-32, and it gives me the error that I attach:
    rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    13:26:23.144 -> flash read err, 1000
    13:26:23.144 -> ets_main.c 371
    13:26:23.472 -> ets Jun 8 2016 00:22:57

    • Hi Ernesto.

      This is before The problem with CO2 Gadget loading is usually related to a hardware error (something wrongly connected, power supply problems, USB cable, etc).

      Anyway, I recommend you to load the "advanced" firmware, here:

      Load the advanced firmware and thoroughly check connections, power supply, cables, etc. If you can't solve the problem, visit the Telegram group and we will surely solve it...

  4. 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.


Leave a Comment