CO2 meter on your mobile phone with ESP32 and Sensirion SCD30 sensor [BASIC VERSION] [BASIC VERSION].

Welcome to this tutorial in which you will learn how to build the basic version of the CO2 meter 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 hourby following the steps in the tutorial.

Both the firmware as well as the App of this CO2 meter have been prepared by Sensirion, one of the world's largest manufacturers of quality CO2 sensors and, therefore, who knows the most about its measurement.

The meter works very wellwe could expect no less coming from one of the world's leading CO2 sensor manufacturerssuch as Sensirion.

By the way, the mobile App is very professional and of high quality. I'm sure you'll love it.

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

The most important facts about the Sensirion SCD30 are as follows:

CO sensor specifications2
Measuring range CO20 - 40'000 ppm
Accuracy±30 ppm + 3% of the 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))
Electrical specifications
Supply voltage3.3 - 5.5 V
Average current measurement rate @ 2s19 mA
Max. current75 mA
Sensirion SCD30 Key Specifications

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

Sensirion SCD30 CO2 Sensor

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

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:

  1. Preparing the Hardware: Learning how to make the sensor wiring to the development board
  2. Save the firmware on the development board
  3. Display CO2 levels in your computer and on mobile or tablet with the Sensirion MyAmbience App
  4. Extras: Some tips, tricks and additional information

I recommend that you use my own extended version of the firmware.

It is a major leap forward over what you can see in this article. It has been built by hundreds of users and is probably the most advanced CO2 meter of its kind in the world (including commercial and non-commercial meters).

You have it in the following article:

In this tutorial you will find two versions of the meter. A very simple version, without display, so you can build a compact meter and see the CO2 concentration on your mobile phone or tablet and a meter with colour display and prepared for battery operation like this one:

This screen will allow you to display 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 colour display 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):

Step-by-step video tutorial

To get you started, here 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 will motivate me to keep making more videos like these.

Material required

To complete this tutorial, you will need:

  • A ESP32 DevKitC-32D board or a plaque LILYGO® TTGO T-Display ESP32 for the version with display
  • A CO2 sensor Sensirion SCD30
  • A few wires to make the connections
  • USB cable to connect the ESP32 DevKitC module to your PC or computer.

Below, in the "Shopping basket" section, I will give you some examples of what you can buy. advice on equipment to buyas well as some useful links to places where you can buy them. at a good price and with guarantees.

Preparing the Hardware

The preparation of the hardware is extremely simple.

Carefully connect the SCD30 sensor to the ESP32 DevKitC as shown 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 cables of different colours to make it easier for you.

ESP32 DEVKITC + SENSIRION SCD30

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

You have to connect:

  • VIN pin from SCD30 to pin marked 3.3V on ESP32
  • GND pin of SCD30 to GND of ESP32
  • SCL from SCD30 to ESP32 pin IO22
  • Pin marked SDA from SCD30 to pin IO21 of the ESP32

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

In the case of the display version, the wiring is the same, although the position of the pins changes (*you will soon find detailed images of the display version on this page, I am preparing it).

Record the ESP32 DEVKIT

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

The recording of the Sensirion CO2 meter firmware in the ESP32 DevKitC-32D board could not be quicker and simpler. You don't even have to download or install anything on your PC..

Using this option "extra-super-fast and simple". you will record the programme as I have prepared it, without any preparation or modification.

Click the "Install" button, select the port where your board is connected and click "Connect". It's as simple as that, the recording of the ESP32 will be done in a moment without any further complication.

Your browser is not supported! You need to be using Windows with Microsoft Edge or Google Chrome to see the button.

Traditional option, using the Arduino IDE

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

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

Use of the meter

Simply connect it to 5V (via a charger and USB cable, for example), open the Sensirion MyAmbience App on your mobile phone and view the values.

To make sure that the values provided by the sensor are stable, you will have to wait for some time after switching it on. In my tests I have found that after approximately for a moment The values are now completely stable.

In addition to bluetooth, the meter can also be operated via connected to a computerIt outputs through the serial/USB port the sensor readings every 2 seconds, so you can view them with a serial monitor (the Arduino IDE one, for example), plot them (with the Arduino IDE Serial plotter, for example) or process them from any software.

Some additional features of the meter are as follows:

  • Broadcasting of values in real time 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, graph received values and share and export data.
  • Local storage of sensor data for later downloading (sensor history 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 is equipped with an automatic calibration system, called by Sensirion Automatic Self-Calibration (ASC), and it works quite well.

It works as follows:

Since the natural CO2 concentration in the atmosphere is about 400 ppm (actually just under 420 ppm on average in 2021), when the ASC is enabled, the sensor assumes that, over a period of approximately 7 days, the minimum CO2 concentration it encounters will be equivalent to 400 ppm..

This means that, in a well-ventilated room, which at some point during the seven-day period has clean air, 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 it implies that:

  • You cannot use the automatic calibration if you are going to use the sensor in a greenhouse, for example, as the greenhouse air will never go 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'm showing you in this tutorial has the automatic calibration activated and working. Note that, when you build it, you will have to keep the sensor connected and running for seven days in a row (without switching off) to calibrate (or do a manual calibration, as described below).

Manual calibration

The Sensirion SCD30 CO2 sensor allows manual calibration so you don't have to wait seven days for it to calibrate automatically, but Sensirion has not implemented this 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 only suitable for calibration of the SCD30 sensor at 415 pp.m, does the following:

  • When you turn it on, it will wait five minutes for the sensor to stabilise, during which time 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, will leave the LED on permanently.

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

Click the "Install" button, select the port where your board is connected and click "Connect". It's as simple as that, the recording of the ESP32 will be done in a moment without any further complication.

Your browser is not supported! You need to be using Windows with Microsoft Edge or Google Chrome to see the button.

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

A word of advice: The SCD30 is very sensitive to air currents. (like all NDIR sensors, to a greater or lesser extent) so it is important that when taking it outside to calibrate it don't give it too much air. If it is windy where you are going to calibrate, you can even put the meter in a clear, non-airtight plastic bag and push the button through it). If it is already in its box you should have no problem.

The shopping basket

If you are an advanced user, buy the materials you want wherever you want. You won't need a lot of advice because they are all easy to buy components without much mystery and if you do encounter any differences you will be able to adapt the tutorial to these differences yourself..

If you're not that experienced, here are some tips and links to websites where you can find I have bought them (with alternatives to sites where other eMariete users have bought them), and that are recommended.

Buying the components from these links will ensure that you get exactly the same components as in the tutorial and that everything matches (not all boards, for example, even if they look almost the same and have the same name, have all the pins in the same place or are labelled in the same way).

Buy the Sensirion SCD30 sensor

Sensirion SCD30 Sensor

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

Almost all eMariete users have purchased the sensor from 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 slightly more modern version) it has the same connection distribution and comes with the pins already soldered.

I have bought other things from this AliExpress shop and it is completely trustworthy.

You also have the option of buying the plate on Amazon. It is a bit more expensive (not too expensive) but you will have it at home quickly.

Sales
AZDelivery ESP32 ESP-WROOM-32 NodeMCU Module WiFi + Bluetooth Dev Kit C Development Board 2.4 GHz Dual Core with CP2102 Chip (successor of ESP8266) Arduino Compatible with E-Book Included!
  • New on the market: AZ-Delivery ESP32 Development Board NodeMcu WiFi CP2102 has the powerful ESP32 Microcontroller installed.
  • Rapid Prototyping: This ESP32 development board enables dynamic prototyping with simple programming via Lua scripting or on the Arduino-IDE and Breadboard compatible build. It integrates Wi-Fi and Bluetooth functions.
  • Ultra-low power consumption: It features 2.4 GHz dual-mode Bluetooth Wi-Fi and TSMC dual-mode Wi-Fi chipsets, as well as 40 nm 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 useful information on how to start your project, helps with quick setup and saves time in the configuration process. We provide a number of application examples, comprehensive installation guides and libraries.

Version with TFT colour display

For the sake of clarity, I have separated the version with colour display in its own article.

Having problems? Meter Frequently Asked Questions

Although the project is very straightforward, there is always the possibility that you may have a question or a problem.

In the list below, you will find answers to the most common questions and doubts.

8 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
  2. I have mounted it on 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

    Reply
    • Hello Ernesto.

      This is formerly 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:
      https://emariete.com/medidor-co2-gadget/

      Load the advanced firmware and check connections, power, cables, etc. thoroughly. If you can't solve the problem, go to the Telegram group and I'm sure we'll sort it out...

      Reply
  3. Bonjour Mariete,
    J'ai réalisé votre excellent projet, merci beaucoup pour vos indications très claires.
    Avant de mettre cette belle réalisation dans un boîtier digne de ce nom je voudrais vous simplement vous vous dire que dans mon cas l'affichage de la température et de l'hygrométrie ne sont pas assez proches de la réalité. Il y a un écart de 3,3 degrés et environ 5% pour l'hygrométrie.
    My question is the following. Peut-on modifier l'offset pour ces deux mesures afin d'obtenir un résultat proche de la réalité ?
    En attendant de vous lire, par avance je vous remercie beaucoup et bravo encore pour votre travail.
    P.S. je ne suis pas un spécialiste en informatique

    Reply
  4. Bonjour Mariete,
    Je vous remercie beaucoup pour votre réponse.
    Comme vous me l'avez l'avez suggéré, je suis allé un peu plus loin dans mes recherches et effectivement j'ai trouvé toutes les réponses à mes 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
    Cordialement

    Jimmy

    Reply

Leave a comment