CO2 Meter TFT Colour Display with TTGO T-Display Sensirion SCD30 - The CO2 Gadget

A high quality CO2 meter with colour screen and connection with your mobile phone via Bluetooth that you can take it everywhere with you thanks to its rechargeable battery (optional) and know, discreetly and at all timesthe quality of the air you breathe.

Here I bring you the meter CO2 GADGET.

CO2 Gadget and App Sensirion MyAmbience

This tutorial is accompanied by a video, which you can find below, with everything explained step by step and in detail for the construction of the CO2 Gadget.

In this tutorial you will see, in a very easy way, how to:

  1. Preparing the Hardware: Learn how to connect the SCD30 sensor to the TTGO T-Display Board
  2. Save the firmware in the TTGO T-Display Board
  3. Display CO2 levels on the TFT colour screen, your computer and on mobile or tablet with the Sensirion MyAmbience App
  4. Extras: Some tips, tricks and additional information

Below you'll find something I'm sure you'll love: My own extended and improved version of the CO2 Gadget firmware with new interesting features:

  • More modes of operation: Bluetooth, WIFI, and maybe ESP-Now
  • More sensors supported, including CO2, temperature, humidity and pressure sensors.
  • Consumption optimisations for battery use
  • Support for more screens
  • Sending data via MQTT
  • Configuration via website
  • Updates via your website

This tutorial is a improved version, with colour display and rechargeable batteryfrom another previously published project: Mobile CO2 meter with ESP32 and Sensirion SCD30 sensor. If you haven't seen it yet, I suggest you watch it now, because it contains basic information:

The built-in display will allow you to display the current CO2 concentration and its level in green, yellow/orange or red colourdepending on whether the CO2 level is good, bad or very bad.

Material required

To complete this tutorial, and build your CO2 Gadgetyou will need:

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 CO2 Gadget hardware is very simple.

I give you two options for mounting: a version in which the sensor and the board are connected by means of small cables and a version in which the sensor and the board are connected by means of small cables and a version in which the sensor and the board are connected by means of small cables. super compact in which sensor and board are bonded together as a single compact block.

Wired version

For the first version, carefully plug in the TTGO T-Display Board at Sensirion SCD30 Sensor as explained below. Pay attention to each wire so that it goes from the correct pin on the sensor to the correct pin on the board..

You have to connect by means of some wires:

  • The VIN pin of the SCD30 to the pin marked 3V on the TTGO board.
  • The GND pin of the SCD30 to the pin marked G on the TTGO board.
  • SCL pin from SCD30 to pin marked 22 on the TTGO board
  • The SDA pin of the SCD30 to the pin marked 21 on the TTGO board.
Image for illustrative purposes taken from Sensirion's Github tutorial.

Sandwich version

The aim of this set-up is to achieve a meter as compact as possible.

The sandwich version of the meter is connected by means of a pins or hard wires. In this way the TTGO T-Display Board and the Sensirion SCD30 Sensor form a single block.

If you are mounting this version, be sure to save the specific firmware for the "sandwich" model.The pins are different and this firmware version is prepared for this change. You have more information about this below.

Engraving the LILYGO® TTGO T-Display board

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

It is very easy to save the firmware on the LILYGO® TTGO T-Display board. You don't have to download or install anything on your PC..

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 of the board will be done in a moment without any further complication.

Sandwich version (SDA to pin IO22 and SCL to pin IO21)

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.

Please note, if you are going to burn your own firmware, that in the compact version of the meter (in which the SCD30 sensor and the TTGO T-Display board are mounted together, like a sandwich, connected by a strip of pins), the SDA and SCL pins are reversed compared to how they are defined in Arduino by default.

Normally on the ESP32 the SDA of the I2C bus should be connected to the IO21 pin and the SCL to the IO22 pin. In the sandwich, it is the other way around: SDA to pin IO22 and SCL to IO21.

For it to work you will need to do two modifications:

1. You have to add, right at the beginning of the sketch, the following two lines:

2. You have to modify the initialisation of the I2C bus, which is normally Wire.begin() by Wire.begin(I2C_SDA, I2C_SCL)as here:

Remember, if you use cables and connect SDA to pin IO21 and SCL to IO22 you do not have to make these modifications..

Use of the Gadget CO2 meter

The use of this meter is exactly the same as described in the original tutorial. This tutorial is a improved version, with colour display and rechargeable batteryfrom another previously published project (Mobile CO2 meter with ESP32 and Sensirion SCD30 sensor), with the difference that you can see the CO2 concentration on the colour display.

The CO2 concentration is shown in different colours depending on their concentration:

  • Green up to 1000 ppm
  • Orange from 1000 to 1600 ppm
  • Red from 1600 ppm

These values, for my taste, are more or less correct (a bit "generous"). in normal times, but now, in times of pandemics, they should be lower.

In the advanced version of the meter you can change these ranges to suit your needs and preferences..

Sensirion SCD30 Sensor Calibration

The Sensirion SCD30 Sensor used in this tutorial must be calibrated, like all sensors.

You can wait seven days, taking it out into the fresh air each day, for the sensor to self-calibrate or you can do a manual calibration (recommended) if you don't want to wait that long.

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 running by default. Note that, when you build it, you will need to keep the sensor connected and running during 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 serves to calibrate the SCD30 sensor to 415 ppm.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.

Note: The TTGO T-Display does not have LEDs, although you do not need it for calibration. In addition, in the advanced firmware I am preparing, calibration is done by means of its on-screen menu so you don't need any LEDs.

To install it, 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 draughts. (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 plastic bag, not airtight, and push the button through it. If it is already in its box you should have no problem.

The shopping basket

Here are a few tips and links to websites where you can find buy the materials.

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) and you will avoid possible fraud or counterfeiting.

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.

I recommend you buy it here: Sensirion SCD30 Sensor

You also have the option to buy the sensor on Amazon. It is more expensive, but you will have it at home quickly.

Buy the LILYGO® TTGO T-Display

TTGO T-Display Board

This is the official shop of LILYGO®, the manufacturer of the board, so you have the guarantee of seriousness and that the board is original.

I recommend you buy it here: TTGO T-Display Board

You will see that there are several versions. I recommend that you buy the one that says "4MB CH340K Chip".

You also have the option of buying the plate on Amazon. It is slightly more expensive, but you will have it at home quickly.

ICQUANZX T-Display ESP32 WiFi and Bluetooth Module Development Board for 1.14 Inch Arduino LCD
  • Chipset: ESPRESSIF-ESP32 (Wi-Fi and Bluetooth) LX6 32-bit Xtensa 240MHz single core/dual core microprocessor
  • FLASH: QSPI flash 4MB / PSRAM 8MB
  • Display: IPS ST7789V 1.14 inch, USB: C-Type
  • Working current: approx. 67MA, quiescent current: approx. 350uA
  • Modular interface: UART 、 SPI 、 SDIO 、 I2C 、 LED PWM 、 TV PWM 、 I2S 、 IRGPIO 、 ADC capacitor touch sensor pre-amplifier DACLNA preamplifier

Step-by-step video tutorial

In the following video you have step by step instructions for the construction of this CO2 meter to make it very easy for you to assemble it.

Update from the video

If you want to to achieve an even cleaner assemblyThe power supply cable of the sensor can be positioned in this way:

Note that you will have to remove the plastic from the last pin of the strip in order to solder the positive from the inside (I recommend you do this formerly welding the sandwich, it will be much easier for you).

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

3D printed box

With the idea of the CO2 Gadget being a small and compact meter, which you can take anywhere, ideally you should use a 3D printed box.

Here you have a collection of boxes, specifically designed for CO2 gadgets, to give your project an almost professional result:

Cellular Polypropylene (PP) Boxes

If you don't have access to a 3D printer, you can make a cellular polypropylene (PP) box very easily.

Here is the complete step-by-step tutorial:

Use with battery

The first thing you have to bear in mind, in order to have the right expectations, is that this is not a low power meter, although it can be powered by batteries. so you can easily take it with you wherever you go.

The TTGO T-Display board features built-in battery charger and charge the battery connected to about 300mA (default, but can be changed by replacing a resistor) when connected via USB.

The primary use of this meter is connected to a power supply or charger and the battery is an extra to use it autonomously for a few hours from time to time. Of course, there's nothing to stop you from adding as big a battery as you like and getting much longer battery life.

In the following picture you can see one of the 3D printed case prototypes with an 800mAh battery (or 1000mAh, actually it's an old battery and I don't know exactly how big it is).

If you want to improve autonomy, I suggest that you load the extended and improved version of the firmwarein which I have included several consumption optimisations to improve the autonomy.

In the following image you can see the consumption profile of the meter for 10 seconds:

Meter consumption profile without optimisations

As you can see, the meter consumes approximately 97mAwhich can be rounded up to 100mA.

This means that we would theoretically have an autonomy of approximately 10 hours of continuous operation with a 1000mAh batteryThe battery life is about 20 hours with a 2000mAh battery and about 35 hours with a 3500mAh 18650 battery. In practice, the battery life will be shorter because the hardware is not particularly optimised and will not be able to squeeze all the power out of the battery.

Please note that, as with any battery-powered device, you must use a battery that has the appropriate protections. At a minimum the battery should have short circuit, overcharge, over-discharge, and over-current protection.

Many batteries include these protections, but if yours does not, you will need to fit a protection plate like this one:

Battery protection

👉 Battery protection plate on AliExpress

Advanced version of CO2 Gadget firmware

The improved and extended version of the firmware is now available. Be sure to visit the following post, where I introduce it and explain everything about it:

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 this list you will find answers to the most common questions and doubts.

Share this article

Thank you very much for collaborating with the most difficult thing: SHARING IT AND MAKING IT KNOWN. It's no use how hard I can work on these tutorials if people don't get to know them. THANK YOU TO EVERYONE WHO SHARES!

Just below you have buttons that make it easy to share it on Facebook, Twitter, WhatsApp and Telegram.


20 thoughts on “Medidor de CO2 Display TFT Color con TTGO T-Display Sensirion SCD30 – El CO2 Gadget”

  1. Good.
    I am a first timer and I have made this setup. With the sandwich firmware the screen kept showing the Sensirion logo. In the app it always shows -45 degrees Celsius, 0 RH and 0 ppm C02.
    I have tried the advanced version. Now the emariete logo is displayed and then the screen shows 0ppm in green. The app also shows the same as before.
    I don't know if there's something I might have done wrong... Ah, I struggled to find the right drivers, I think the ones that worked fine were the ones from the link on the Chinese page.
    Thank you and congratulations on your work.

    • Hello P.

      It is very likely to be due to a wiring error. It would be a good idea to see detailed photos of the assembly, where the connections are clearly visible, to make sure. It is also very important to load the correct version of the firmware (normal or sandwich version), depending on the installation you have done.

      Otherwise, the best thing to do is to connect the meter to the computer via the USB port and use a serial monitor to view the messages that the meter outputs via the USB port, which are numerous and indicate step by step what is happening.

      I recommend you to go to the Telegram chat group where it will be much easier to see it:

      I'm sure we'll find the problem in no time!

      Best regards.

        • I just dropped by again to say that everything is working perfectly and to thank you for your help and your work to make it possible for any handyman like me to be able to assemble and make this work.
          Best regards.

          • Great! I'm so glad it worked out perfectly for you! 😀

            Visit the Telegram group from time to time so you don't miss CO2 Gadget firmware updates - there will be interesting news soon!

      • In the end it was a problem with the wiring (the soldering).

        I recommend that you check your connections and if you continue to have problems, please go to the Telegram group so that we can take a closer look.

  2. Hi, I like this idea, I did read your other articles. Great work. It is possible to use MH-Z19B or Senseair S8 LP sensor, with this TTGO as they are cheaper?

  3. Great work! Thank you very much for your effort.
    I have a question about the battery. You said in the article that we must use battery with build in protection (overcharging etc.).
    But the ttgo t-display esp32 has a build in battery circuit. Doesn't that take care of the charging? So would it be possible to use a simple cell like the panasonic ncr18650b?
    And alternatively, would it be possible to connect 3 x AA NiMh to the board?

  4. Hi Patrick.

    The built-in circuit in the TTGO T-Display board is just a charger, that's why you need additional protections.

    I don't have any experience with the Panasonic NCR18650B battery, best that you check in the datasheet with the exact reference if it has built-in protection or not.

    The charger on board is only good for Li-Ion and Li-po batteries. It can't charge NiMh batteries.

    Best regards! 😀

    • Hi Mariete,
      Thank you for your answer.
      After some research I found that the the charging circuit in the TTGO protects against overcharging but NOT against over-discharging, which can also ruin the battery. The NCR18650B does not have protection.
      I also found this readit- thread where someone tried NIMH, with success, but it was only experimental, but it might work:
      For this project I will order a LiPo-pack (with protection), but when I have time I will also try some NiMh AA's, because they are cheap and readily available.
      Kind Regards

  5. Great work, thank you for sharing the results of your time and efforts !
    I'll take a look to your code, trying to understand how you deal with clockstretching on esp32...
    And a question, the sensirion App do not fetch the data, and I do not see any part of your code that could possibly be related to this aspect. Do I miss something or this ability was left alone ?

    • Hi Mathieu.

      The code in this tutorial is not mine. It's from Sensirion. I only wrote the tutorial.
      When I tested it, few months ago, fetching the data from the meter to the phone via BLE was working fine. If the problem is with the Sensirion's code you should open an issue at their GitHub repository (link in the post).

      My code is at the post "CO2 Gadget: Advanced CO2 Meter". If the problem is with my code and you think it's a bug you should, please, open the issue at CO2 Gadget's GitHub repository.

  6. Good morning. First of all, I'm completely useless when it comes to electronics. I've been reading you guys for a while and I'm sorry I don't understand it as easy as you do. I tried to make the co2 meter and it just stopped trying. It keeps looping giving a 0x10 and 0x13 fault. I have changed the soldering from sandwich to wire and nothing. I don't know if it has a solution or leave it as impossible. I could send you the sensors and you can keep them if I've loaded them or if there is a solution you can tell me. I would be happy to pay for shipping. Thank you for your time.

    • Hello Arkaitz.

      The error you are getting is probably nothing to do with anything having gone wrong, but something else (maybe something silly).
      The best way to see it is through the Telegram group. because a bit of research and testing will have to be done to find the problem...
      I'm sure we'll have it sorted out in no time.

      Best regards.

      • Good morning. As I am a novice in everything related to electronics, the soldering also leaves much to be desired. Thanks for your time and soon I'll show you the problem and we'll see if it can be solved. Thank you very much for your time.

  7. Hello,
    Thank you for the information and your blog.
    The reference of the TTGO I have is 19-6-28 V1.1 XY-CP / 16MB CH9102F Chip
    [ ]

    The pins are different from the TTGO in the tutorial
    G - 36
    21 – 37
    22 – 38
    17 – 39
    2 – 32
    15 – 33
    13 – 25
    12 – 26
    G - 27
    G - G
    3V - 5V
    (connect for USB)
    How can I connect it to the SCD 30 captor to make the system work in wired version ?
    Is your firmware compatible ?
    Thank you for your answer.

  8. As I am not sure you have received my message I am sending it again...
    Thank you in advance for your help.

    Thank you for the information and your blog.
    The reference of the TTGO I have is 19-6-28 V1.1 XY-CP / 16MB CH9102F Chip
    [ ]

    The pins are different from the TTGO in the tutorial
    G - 36
    21 – 37
    22 – 38
    17 – 39
    2 – 32
    15 – 33
    13 – 25
    12 – 26
    G - 27
    G - G
    3V - 5V
    (connect for USB)
    How can I connect it to the SCD 30 captor to make the system work in wired version ?
    Is your firmware compatible ?
    Thank you for your answer.


Leave a comment