Introduction: DIY Air Quality Sensor + 3D Printed Case
This guide has all the information you need to create a very capable, pocket sized sensor.
Step 1: Setting the Requirements
To get the most out of our DIY air quality sensor, we need it to be:
- Have a charging circuit included
- Connected to USB
- Connected to WiFi and Bluetooth
- Readable with an included OLED screen
- Under $100
We want our pocket-sized sensor to be able to measure:
- CO2 levels which affect brain function
- TVOC (air quality) levels to help stay safe around a 3d printer
Step 2: Collecting the Materials
For this project, you will need several components. The total cost is $82.57 at the time of writing.
- 1 x Thing Plus - ESP32 WROOM (https://www.sparkfun.com/products/14689)
- 1 x Lithium Ion Battery - 2Ah (https://www.sparkfun.com/products/13855)
- 1 x Micro OLED Breakout (https://www.sparkfun.com/products/14532)
- 1 x Environmental Combo Breakout - CCS811/BME280 (https://www.sparkfun.com/products/14348)
- 1 x Standoffs Plastic 4-40; 3/8" (https://www.sparkfun.com/products/10461)
- 1 x Screw - Phillips Head 4-40; 1/4" (https://www.sparkfun.com/products/10453)
- 2 x Qwiic Cable - 50mm (https://www.sparkfun.com/products/14426)
You will also need:
- A 3D printer, I used the MonoPrice Mini Delta 3D printer (https://www.monoprice.com/product?p_id=21666)
- 3D printer filament, I used PLA
- A Philips head screw driver
- Scrap plastic sheet for the transparent face plate
- Larger bolts to attach the transparent face plate
Step 3: 3D Printing the Enclosure
Normally, you would have to design your own 3D printed enclosure. Luckily, I have published the 3D printing files on Thingiverse: https://www.thingiverse.com/thing:3545884. In total, it took 4 iterations to get to the final design.
I used the following settings to print the design:
- 0.2mm layer height
- 20% infill
- No bed adhesion layer
Step 4: Assembly
First, attach the standoffs to the 6 small mounting holes in the enclosure.
Second, insert the battery between the standoffs. It will fit under the circuit boards.
Third, screw in the electronics. If the proper standoffs were used, the USB port should line up perfectly with the hole in the enclosure.
Fourth, connect the electronics together. After plugging in the battery to the microcontroller, use the QWIIC cables to connect the sensor and the display in series.
Lastly, cut a small sheet of scrap plastic for the transparent face plate. Drill holes to match the two larger mounting holes in the enclosure and then attach it with longer bolts.
Step 5: Programming
Rather than programming from scratch, I suggest you download my code from the repository linked below.
Currently, the code:
- Reads data from each sensor
- Calculates a rate of change
- Displays data on the OLED display
- Connects to WiFi and displays data on a generated web-page (on the IP address displayed on the screen)
To program the microcontroller, you will need to:
- Download the Arduino IDE (https://www.arduino.cc/en/Main/Software)
- Set up the Arduino IDE and USB drivers (https://learn.sparkfun.com/tutorials/esp32-thing-p...)
- Download the libraries for the sensor and the OLED using the Arduino IDE libraries manager
- Save your WiFi SSID and password in the boards "preferences"
Step 6: Future Improvements
Here are some ideas to improve the project:
- Use WiFi to upload data to ThingSpeak or another service to graph it
- Measure the battery voltage and display remaining time
- Use WiFi to download weather information, news, and anything a smart watch would display
- Add an alarm if CO2 levels are too high
- Add an alarm if TVOC levels are too high
Note: #4 would be a really awesome way to stay safe in enclosed spaces and #5 is very applicable to 3D printer users like myself!
Participated in the
Pocket Sized Contest