Introduction: DIY Air Quality Sensor + 3D Printed Case

About: I like squirrels!

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:

  • Pocket-sized
  • Battery-powered
  • 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:

  • Temperature
  • Pressure
  • Humidity
  • 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.

You will also need:

  • A 3D printer, I used the MonoPrice Mini Delta 3D printer (
  • 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: 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:

  1. Download the Arduino IDE (
  2. Set up the Arduino IDE and USB drivers (
  3. Download the libraries for the sensor and the OLED using the Arduino IDE libraries manager
  4. Save your WiFi SSID and password in the boards "preferences"

Step 6: Future Improvements

Here are some ideas to improve the project:

  1. Use WiFi to upload data to ThingSpeak or another service to graph it
  2. Measure the battery voltage and display remaining time
  3. Use WiFi to download weather information, news, and anything a smart watch would display
  4. Add an alarm if CO2 levels are too high
  5. 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!

Pocket Sized Contest

Participated in the
Pocket Sized Contest