Plug & Play CO2 Sensor Display With NodeMCU/ESP8266 for Schools, Kindergardens or Your Home

Introduction: Plug & Play CO2 Sensor Display With NodeMCU/ESP8266 for Schools, Kindergardens or Your Home

I am going to show you how to quickly build a plug & play CO2 sensor where all elements of the project will be connected with DuPont wires.

There will only be 5 points that need to soldered, because I did not solder before this project at all.

The sensor will have a display where the measured values will be shown every 5 seconds in a big enough Helvetica font.

The housing will be made with a laser cutter out of 4mm simple plywood. All elements will be glued together. A premade container can be an alternative. The display and the sensor will be held in place with duck tape.

The code of this project is put together from 2-3 sample codes I had. It is not sophisticated or pretty but as I did not know anyhting about coding since 2 weeks ago I think it is pretty solid.

The perfect thing about this set up is that once the code is loaded on the NodeMCU/ESP8266 it automatically starts when the power is connected to power and runs as long as the board has power.

In case you do not have a power socket the NodeMCU/ESP8266 can run on a battery pack for good amount of time.

The sensor is already sitting in an elementary classroom and has been working flawlessly for a couple of days so far. It provides the basis for when windows need to be opened to let in fresh air.

Supplies

You will need the following supplies:

- Good soldering iron with adjustable temperature and a very small tip

- Solder (lead free)

- Cleaning wire for soldering iron

- Duck tape

- Third Hand Soldering Station with Magnifying glass

- Micro USB cable (from smartphone)

- Smartphone charger (5V, 1A)

- Dupont Jumper Wires 20cm - 2,54mm female to male 6,99 Euro

- Dupont Jumper Wires 20cm - 2,54mm female to female - 4,99 Euro

- SGP30 TVOC /eCO2 sensor - 25 Euro

- 0,96“ OLED Display I2C Display (SSD1306) 128x64 Pixel - 6,29 Euro (3 Pack 12,49 Euro)

- NodeMCU LUA Amica Module V2 ESP8266 board - 5,99 Euro (3 Pack 13,79 Euro)

- NodeMCU I/O Breakout Board - 4,50 Euro

- 4mm Plywood sheet - 2 small zip ties (not displayed in my picture)

Step 1: Soldering the SGP30 Sensor

The connection pins of the sensor need to be soldered. Set your soldering iron to the needed temperature for your soldering wire and solder the pins to the board.

There is a good tutorial for this on the Adafruit website - https://learn.adafruit.com/adafruit-guide-excellen...

This has helped me a lot.

Let the sensor cold down after soldering and prepare your jumper wires, the NodeMCU and the Breakout board for the next step.

There are SGP30 sensor boards available that have their connections already presoldered - they all use the same CO2 sensors and might be more convenient to use as these are really plug & play (without soldering)

Step 2: Connect NodeMCU to Breakout Board

Take the NodeMCU and the Breakout board and a blue DuPont wire female to male.

Connect the female plug to the NodeMCU D1 pin and the male end to the Breakout board D1.

Now take the orange DuPont wire female to male and connect the female plug to the NodeMCU D2 pin and the male end to the Breakout board D2.

These wires ensure the I2C data connection is set up.

D1 represents SCL

D2 represents SDA

on I2C devices.

To provide power from the NodeMCU to the Breakout board take

- the red wire female to male, connect male to the 3V3 pin and the female to 3V on the Breakout board

- the black wire female to male, connect male to the GND pin and the female to GND on the Breakout board

As final step connect the microUSB cable to the NodeMCU, plug the other end into the smartphone charger (5V, 1A) and plug the charge into a 220 Volt socket.

If you have connected everything correctly the blue led on the Breakout board will light up

Step 3: Connect OLED Display to the Breakout Board

Disconnect the microUSB cable from the NodeMCU board

Take

- 0,96“ OLED Display I2C Display (SSD1306)

- 4 female to female wires (red, black, orange and blue)

Connect Breakout board to display

- blue to D1 and SCL

- orange to D2 and SDA

- red to 3V and VCC

- black to GND and GND

Step 4: Connect the SGP30 CO2 Sensor to the Breakout Board

Take female to female jumper wires and connect breakout board to SGP30 sensor

- yellow wire from D1 to SCL

- green wire from D2 to SDA

- black wire from GND to GND

- red wire from 3V to VIN

Step 5: Build the Enclosure & Install Display and Sensor

If you want to create you own enclosure go to makercase.com, choose the box you like and enter your dimensions and the thickness of your plywood. Download the .dxf file for laser cutting

My dimensions are 120 x 80 x 80mm (inner measurement) for 4mm plywood - I have provided the basic file for usage in your laser cutter software and added holes for

- Sensor

- Display

- microUSB power connection for NodeMCU

- vent holes on the top of the enclosure

Laser cut 4mm plywood and glue together with wood glue

Drill 2 holes with a 3mm wood drill to attach the NodeMCU board with zip ties to side wall to prevent sliding when inserting microUSB power cable

Attach display and sensor to front panel with duck tape - this is the lazy way ;)

Glue rest of walls together and use rubber bands to keep everything together until glue is dry. Do not glue the top to box as you want to be able to access your set up and change/add components

if you do not have a laser cutter buy a cheap clear plastic box/container, drill holes for sensor, NodeMCU board zip ties and microUSB power cable

Step 6: Set Up the Board

If you are new to NodeMCU programming and have not installed the Arduino IDE yet go to https://www.arduino.cc/en/pmwiki.php?n=Guide/Windo... and follow the instructions for Windows

Start Arduino IDE and set up your board in the application. In my case it is a NodeMCU LUA Amica V2 with CP2102-Chip that ensures smooth USB communication with my Windows 10 Surface.

The first thing you need to do is install the ESP8266 core. To install it, open the Arduino IDE and go to:

File> Preferences, and find the field "Additional Boards Manager URLs". Then copy the following url: https://arduino.esp8266.com/stable/package_esp826... Paste this link into the "Additional Boards Manager URLs" field. Click the OK button. Then close the Arduino IDE.

Connect your NodeMCU to your computer via the USB port. The led on the Breakout board should light up and stay on. It is blue on my picures.

Open the Arduino IDE again and go to: Tools> Board> Boards Manager A new window will open, enter "esp8266" in the search field and install the board named "esp8266" from "ESP8266 Community" You have now installed the ESP8266 core. To select the NodeMCU LUA Amica V2 board, go to: Tools> Board> NodeMCU 1.0 (ESP - 12E Module) To upload the sketch code to the NodeMCU card, first select the port to which you have connected the card.

Go to: Tools> Port> {port name} - potentially COM3

Load the drive for your OLED display. In this case I am using the library u8g2. To download the library go to Tools> Manage Libraries. In a new window that opens, enter “u8g2” in the search field and install the “U8g2” library from “oliver”.

The installation is very easy. Just click the "Install" button that appears when you move the mouse over the search result.

Now repeat the same steps to load and install the SGP30 CO2 sensor library. The name of the library is Adafruit_SGP30

Step 7: Get Ready to Test Drive and Use Your CO2 Sensor

Open the provided code in the Arduino IDE. Once the code is loaded it will be displayed in a separate window.

Press the checkmark to compile the code and to load it to your board.

If you have connected everything correctly the display will show "CO2" and the value "400". The sensor is initializing itself and after 30 seconds the sensor is ready to measure real values every 5 seconds.

Breathe gently on the sensor and wait for the value to be shown on the display.

Congrats - you made it and build a CO2 sensor yourself!!

Now disconnect the USB cable from the computer, plug it into the charger and go to a room, school or kindergarden where you want to use your sensor.

After plugging the charger into the wall socket it will take 30 seconds for the sensor to be ready. The sensor will then let you know when to open the windows. You will want to do this at values above 650 (values are measured in ppm)

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Unusual Uses Contest

      Unusual Uses Contest
    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge

    2 Comments

    0
    randofo
    randofo

    11 months ago

    What kind of data is it outputting? What sort of range is normal?

    0
    supervisor268
    supervisor268

    Reply 11 months ago

    The SGP30 is outputting TVOC values (Total Volatile Organic Compound) from 0 bis 60000 ppm (part per million). Additionally it outputs eCO2 (which I measure and display with the device) in the range from 400 to 60000 ppm.
    Literature says you should open the windows when eCO2 reaches 10000. My tests show that from 750 ppm on open windows are a better choice.
    https://www.adafruit.com/product/3709 for more details.
    My approach is now scientifically driven - I am more keen to understand when to really bring in fresh air in winter times in the elementary class room