Last modified January 17, 2021
- 1 features
- 2 Print
- 3 Print file
- 4 Connections
- 5 ESPEasy configuration
- 5.1 Add the MH-Z19B sensor to ESPEasy
- 5.2 Add the SSD1316 display to ESPEasy
- 5.3 Add WS2812 LEDs to ESPEasy
- 5.4 Do you want to add a buzzer?
- 5.5 Activate the ESPEasy rules engine
- 5.6 Add a rule so that when it turns on it does so with the LEDs off
- 5.7 Add a ruler to change the color of the LEDs depending on the CO2 level
- 5.8 Add a rule to make an LED traffic light
- 6 Step-by-step video tutorial
- 7 Front cover
- 8 Upcoming improvements
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.
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.
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:
- Add the MH-Z19B sensor to ESPEasy
- Add the SSD1316 display to ESPEasy
- Add WS2812 LEDs to ESPEasy
- Activate the ESPEasy rules engine
- Add a rule so that when it turns on it does so with the LEDs off
- 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:
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:
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, 220.127.116.11 // 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.
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.
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.
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.