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

by supervisor268 in Circuits > Sensors

1961 Views, 2 Favorites, 0 Comments

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

DEAF9032-30C8-4F5A-BC2C-491F4B04E730.jpeg

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)

Soldering the SGP30 Sensor

63FA9A98-91B6-447D-BC8D-3D29B6C1B861.jpeg
EF4F3727-CED2-4F46-ACE3-61BD8232AA06.jpeg
B87B90DD-DCC5-4222-AE81-9485C6286064.jpeg
4306152E-F092-4C4B-8039-16C07132ABB5.jpeg

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)

Connect NodeMCU to Breakout Board

ECFEB6EB-E0CA-4B57-9954-0CC326D09C4A.jpeg
6FDDBC64-29A4-465C-BB1A-9C3F9FB9AABD.jpeg
10DEED3B-2539-4DD3-8A9C-A63DFC44ED90.jpeg
8A6C055D-85B3-42B9-961C-BA2844B24858.jpeg
E89E6C3E-9D10-46BC-A318-091366BA5A1B.jpeg

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

Connect OLED Display to the Breakout Board

9CAE075D-4B1B-456D-8BD7-10648D6C8DFB.jpeg
6B50319D-2324-4369-B1F6-6B573AFB8842.jpeg

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

Connect the SGP30 CO2 Sensor to the Breakout Board

FEC6B495-5089-4632-814A-AC7DAC78089F.jpeg
D9BD36C2-6AFF-43DE-A1CD-8922E66FB9DC.jpeg

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

Build the Enclosure & Install Display and Sensor

5F3FEAEE-A8FD-4134-A335-E94737C92BF2.jpeg
837E2E73-A722-477C-876A-BA2C602D8061.jpeg
DC4B8A0C-8DBC-46B1-8041-7D4E8C9C6418.jpeg
547D9B27-3E28-4A93-B83F-78D68A20BFC6.jpeg
45057802-8A0B-49EE-A71F-F1039B8254E1.jpeg
0DD057E0-F988-433F-A778-65C6A2AF8192.jpeg
9AE94907-3BBC-4D0E-94E6-486686AD0FD5.jpeg
5DDF5875-63F5-4AB7-BBF9-3DD611841EB0.jpeg
CE68D366-03F7-478B-A08A-8706C0A914C2.jpeg

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

Set Up the Board

438A07D2-A0E3-4869-825F-880B90C340CD.jpeg

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

Get Ready to Test Drive and Use Your CO2 Sensor

9705F8C8-EE87-466D-A54E-788861D3EEC0.jpeg
6A86E517-D49A-4DEF-8C55-0A74E73079A5.jpeg

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)