3D printed box for CO2 meter

Last modified January 17, 2021

There have been many blog readers who have asked for a 3d printed box for him CO2 meter.

Voucher, challenge accepted!

I have designed a custom box for 3D printing, simple and easy to print, no need for supports or bridges.


The main of features and benefits from the box, are as follows:

  • Easy to print (no supports or bridges).
  • Design with thermal dynamics to conduct heat away from the CO2 sensor
  • System of NodeMCU installation without welding (optional)
  • Ready to install a 0.96 ″ OLED display
  • Prepared for the installation of LEDS for color warnings
  • Ready for buzzer installation
  • Design of custom vinyl front cover


The box is very easy to print, although, as it has a certain surface, it can cause warping problems (lifting of the corners) depending on the printer and its settings when printing with ABS.

Me I have printed the prototype with PETG, even though could be made perfectly with PLA.

In a way the PLA would be better because it is more stable and the measurements are more accurate. This is especially important for the pins on the NodeMCU (I had to go over the holes with a small drill bit).

Box does not withstand any stress and is structurally robust, so we can print it with an infill of the 10% without any problem or risk of being too flimsy.

The printing time, in my case, has been about two hours. Depending on the printer, speed and quality desired, the printing time can vary quite a bit.

Print file

I have left the STL file for printing on Thingiverse. You can access it here.

The back cover is missing, which, at the moment, I have not designed. This is a first version and I will probably make another version with some improvements that I want to introduce, so I will take the opportunity to design the back cover for the new version.

If I didn't get to make the new version, I would design the back cover for this one.


The video covers the basic details required for connecting the OLED display. For more information, I recommend viewing the article Connect an SSD1306 OLED screen to ESPEasy.

Diagram with the connections of the NodeMCU to the SSD1306 screen.

Diagram with the connections of the NodeMCU to the WS2812 LEDs (Neopixel)

If I explain, in more detail, the connection of the WS2812 LEDs (also called Neopixel) and its configuration in ESPEasy, since I have not yet ready the article talking about the use of the WS2812 LEDs (Neopixel) with ESP Easy in depth (I have it already very advanced, I am editing the video and recording some missing shots).

In the example I have used three WS2812 LEDs, but one of the great advantages of this type of LED is that you can use whatever you want. Take into account the consumption, each LED can consume up to 60 mA.

Diagram with NodeMCU connections to MH-Z19 or Senseair S8LP module

Both modules, MH-Z19 or Senseair S8LP, are compatible in terms of connections, so the connection will be identical.

ESPEasy configuration

Once we have made the connections, we have to configure ESPEasy so that it recognizes the devices and include some simple rules so they behave the way we want.

Basically, we will have to do the following:

  1. Add the MH-Z19B sensor to ESPEasy
  2. Add the SSD1316 display to ESPEasy
  3. Add WS2812 LEDs to ESPEasy
  4. Activate the ESPEasy rules engine
  5. Add a rule so that when it turns on it does so with the LEDs off
  6. Add a ruler to change the color of the LEDs depending on the CO2 level

Add the MH-Z19B sensor to ESPEasy

This article, which you are reading, is about the 3D printed box. It is assumed that you already have a working homemade CO2 Meter. If not, I recommend you see the article home CO2 meter and your video. In it you will find all the necessary details and a lot of useful information.

Add the SSD1316 display to ESPEasy

The connection of this screen is very simple and is explained in detail in the video.

I will not repeat here if programming, since in the article Connect an SSD1306 OLED screen to ESPEasy You have very detailed instructions on how to connect the display and how to set it up with a very detailed video.

Add WS2812 LEDs to ESPEasy

I am preparing an article, with a detailed video, explaining in great detail how to connect the WS2812 LEDs to ESPEasy and how to use them.

However, its basic connection and its use is sufficiently explained in the video that you can find below.

Do you want to add a buzzer?

The box is prepared for the installation of a buzzer, In the article Using a buzzer with ESPEasy you have everything you need for connection and use.

Activate the ESPEasy rules engine

The first thing we must do is activate ESPEasy rules engine, since, by default, when we install it, it will be disabled.

To do this, we go to the tab "Tools”(Tools) and press the button“Advanced”(Advanced):

The window with the ESPEasy advanced configuration options will open.

There we must activate the options "Rules”(Rules) and“Old Engine”(Old Engine):

Add a rule so that when it turns on it does so with the LEDs off

Now we have to write our rules, in the "Rules" tab (Rules). This tab will not appear until we enable the rules engine, as we have seen in the previous point:

In the rule editor that appears in ESPEasy, we will write the following rules (I recommend copying and pasting, to avoid mistakes and leave comments - lines that start with // - which ESPEasy will ignore).

You shall replace Senseair#PPM with the device name and value of your choice (in the tab "Devices" - Devices). In this screenshot the name of the device is CO2, so instead of Senseair#PPM we would write CO2#PPM:

On System#Boot do NeoPixelAll, 0,0,0 // LEDS OFF EndOn

The NeoPixelAll line, 0,0,0 instructs ESPEasy to turn off all LEDs.

Really what this line tells you is to put the Red to 0, he Green to 0 and the Blue to 0.

Being the line NeoPixelAll, 0,0,0 between "a block«, Formed by the line On System#Boot do Y EndOn, We tell ESPEasy to run it when NodeMCU starts up (anything we put inside that block will be executed every time the NodeMCU turns on).

Add a ruler to change the color of the LEDs depending on the CO2 level

We add this other block:

On SenseairCO2#PPM do if [SenseairCO2#PPM]> 2000 NeoPixelAll, 32,0,0 // LEDS RED Elseif [SenseairCO2#PPM]> 1500 NeoPixelAll, 16.9.0 // LEDS ORANGE Else NeoPixelAll, 0.32.0 // LEDS GREEN Endif endon

This block instructs ESPEasy to every time I receive a new value from the SenseairCO2 sensor (On SenseairCO2#PPM do), check the following:

if the value of SenseairCO2#PPM is greater than 2000 and, in that case, turn on all the LEDs on the strip with the following values: Red at 32, he Green to 0 and the Blue to 0.

if it is not fulfilled the above (SenseairCO2#PPM value is greater than 2000), it will check if the value is higher than 1500 and, if it is true, turn on all the LEDs of the strip with the following values: Red at 16, he Green to 9 and the Blue to 0 (a yellow / orange).

if it is not fulfilled the above (SenseairCO2#PPM value is greater than 1500), and without making further checks, it will turn on all the LEDs on the strip with the following values: Red to 0, the Green to 32 and the Blue to 0.

the line endon ends the block of checks you started with On SenseairCO2#PPM do.

The final result, it should look like this:

Add a rule to make an LED traffic light

With the WS2812 LEDs it is possible to create a traffic light effect, in which, with a strip of three LEDs, placed vertically, we can light the first LED of the strip in green, the second in orange and the third in red, depending on the CO2 level.

The command to send for turn on a certain led of the strip is:

NeoPixel, LedNumber, AmountOfRed, QuantityGreen, QuantityBlue

Being NumberLed the position occupied by the LED we want to control on the strip, and the amount of red, green and blue a number between 0 (off) and 255 (on to intensity 100%).

For turn the first LED red (at the intensity 50%, for example, since the 100% is very strong for my taste) we would use the command:

NeoPixel, 1,128,0,0

For turn the second LED amber (at 50% intensity), we could do it by adding a 25% of red plus a 12% of green. To achieve this we would use the command:


For turn the third LED green (at intensity 50%), we would use the command:

NeoPixel, 3,0,64,0

Rule that we should include would be this:

On SenseairCO2#PPM do if [SenseairCO2#PPM]> 900 NeoPixelAll, 0,0,0 // WE TURN OFF THE NeoPixel LEDs, 1,128,0,0 // WE TURN THE FIRST LED ON RED Elseif [SenseairCO2#PPM]> 800 NeoPixelAll, 0,0,0 / / WE TURN OFF THE LEDs
    NeoPixel, // WE TURN ON THE SECOND LED IN ORANGE Else NeoPixelAll, 0,0,0 // WE TURN OFF THE LEDs
    NeoPixel, 3,0,64,0 // WE LIGHT THE THIRD LED IN GREEN Endif endon

I have chosen the CO2 levels so that the traffic light turns red when it exceeds 900 ppm (according to the RITE IDA 2 standard for teaching classrooms, suitable for school classrooms). Feel free to substitute the values of 900 and 700 for the ones that suit you best.

Depending on what distance you are going to see and the brightness of the room, you can adjust the intensity of the LEDs (one of these LEDs on at maximum, value of 255, you can see much).

As you will see before turning on each led first we turn off the entire strip, using the command NeoPixelAll, 0,0,0 because, if we did not do it like that, in the color changes (for example, when going from green to orange), the two LEDs would stay lit.

This type of LEDS is perfect for making traffic lights and other indicators. Better than you throw them away because can be used together or individually separated.

Much better than LED strips, which give much less flexibility.

Click on the image or here to see where I buy them.

Step-by-step video tutorial

Although the assembly is very simple, and is largely covered in the video of the assembly of the Homemade CO2 Meter, I have created a video with all the details of the boxed meter mounting, with specific instructions for connection and configuration of the OLED screen and LEDs.

In it you can find explanations, details and advice of all kinds.

Front cover

Along with the STL file of the box, in Thingiverse, I also leave you the front cover in SVG vector format.

Me I have cut the front in adhesive vinyl with a cutting plotter, but you can print it with a normal printer, cut it by hand and paste it or do it with laser in another type of material.

I also leave you the front cover, the Silhouette Studio format, which is the cutting plotter that I use.

Upcoming improvements

In the next version of the box, which I intend to do, I plan to introduce the following improvements:

  • Expand the gap of the LEDs to 10mm to be able to install led strips standard flat shape.
  • Provision of holes for the installation of 5mm round LEDs for those who prefer it (for example, to put normal RGB LEDs).
  • Change the position of the buzzer to leave the front clean and allow the installation of the buzzer modules most common.

If you want to suggest any additional improvement, you can leave it in comments.

The idea It is not create several versions for different parts (for example, one for NodeMCU and another for Wemos D1 Mini, whoever wants to put a Wemos D1 Mini can leave it wired on air) but make improvements that extend functionalities or improve usability.

If you liked this page, share it.

13 thoughts on “Caja impresa en 3D para el medidor de CO2”

  1. Let's see if you see it and I'm lucky and you answer me.

    I cannot 3d print. Around there you talk about using some boxes that you buy 10 by 10.

    Which are?

    Thanks a lot!

    • I answered you this same question in the comments of the article "A home CO2 meter with Wifi against coronavirus." I have put the link to the type of box that I use in that same article.

  2. Good afternoon

    I have followed your manual from beginning to end and I cannot be more happy and satisfied with the result, that said, instead of putting LED strips on it, I want to put a traffic light on it, since the meter I'm making goes to the nano school, and I think that your teacher will find it easier and more comfortable to distinguish if she does not have it near her, but I don't know how I would have to configure it in the espeasy, I mean, I don't know if the Neo pixel would be worth or should I put another device as a device, or If the rules you have created would be valid for it, nor do I have any idea how the connections would be, I only have clear the GND the other 3 cables, I have no idea where to connect them. Thanks for the tutorials, videos and the work you do, it makes the task much easier for those of us who have no idea and can have the meter, thanks again.

    a greeting

    a greeting

    • Hi.

      I am preparing an entry and a video explaining the handling of the WS2812 LEDs in depth, but it will take a day to be ready. If you want you can wait.

      Anyway, the operation is very simple.

      I don't know if you've seen the full video. In it it is explained. What is explained in the video is already a traffic light. The strip lights green, yellow / orange or red depending on the CO2 level.

      If it is not a traffic light of this type that you want, explain your idea a little, to see if I can give you some brief instructions while I finish the video.

      I'm a bit lost ... they are not GND plus four cables, they are three cables in total and in the video it looks very good (minute 23:25). The schematic that appears in the video (and above, in the article) is this:

      WS2812 connection to NodeMCU

      What do you mean if you should put the Neopixel or another? Which?
      And "if the rules would be valid for the same"? For which?

      As I answer you, I realize that I am very confused, maybe I am thick and I have not understood the question. Tell me what you want and I try to help you.

      • Hello

        When one does not know, it is very difficult to make oneself understood, I have seen your videos from cover to cover and many times, by semaforo I mean this, literally https://www.tiendatec.es/3366-large_default/modulo-semaforo-led -three-colors-for-arduino.jpg

        Thank you

      • I want to expand my answer because as I read it, it gives me the impression that I seem angry and / or cutting and it is not like that, on the contrary, very grateful for your selfless work and the time you dedicate to us as well as the information you provide us, that if I would like to make it clear to you.

        • No man no! Do not worry! 😁 hahaha

          Now I know what you mean by the traffic light ...

          Being able to put on, you can, but it is not that simple. You have to put external components that complicate it.

          The NodeMCU can supply maximum 12mA on each pin. I have looked for information on the internet and this traffic light needs: Red 13mA; Yellow 13mA; Green 25mA

          Maybe the red and yellow would show up, but the green would never light up.

          To increase the current, we would have to put three transistors and we are already complicating the circuit a lot ...

          I give you an alternative idea: Print a cover with the printed traffic light for the box and match the holes with the LEDs on the WS2812 strip.

          Another option would be to make a 3D printed traffic light with the WS2812 strip inside.

  3. Hello

    expand or clarify my previous comment, in which as I read it gives me the impression that I seem angry or cutting, and it is the opposite I am very grateful to you for the time you dedicate and the opportunity you give us, I wanted make that clear, I am clear that in a face-to-face conversation it would not have been necessary but when one writes sometimes ...

    • That said, don't worry at all. 😀

      You have not seemed serious or cutting to me. My initial response, maybe it did seem serious or curt, but I was so frustrated that I couldn't give you a better answer that it came out that way. Sure, as you say, face to face this would not have happened ... the writing is very cold sometimes ...

      Greetings and thank you.

      • Good Morning

        With your explanation it is clear to me that the traffic light is completely ruled out and the alternative of printing one for the led strips seems to me a very good solution.

        I'll see how this ends and I'll let you know what I do.

        I said thanks for everything and I am glad that we understood each other.

        a greeting

        • Hi.

          I have added instructions to make the semaphore in «Add a rule to make an LED traffic light«.

          I have tried taking photos, but taking photos of the LEDs is extremely difficult and they turn out to be fatal.

          A greeting.

          • Good afternoon

            I can only thank you and congratulate you for the hard work and generosity, a "gimmick" machine and a 10 as a person.

            a greeting

Leave a Comment