DIY Air Quality Sensor + 3D Printed Case

2,124

19

5

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 (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.

Repository: https://gitlab.com/finnbear/pda/blob/master/PDA_ES...

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 (https://www.arduino.cc/en/Main/Software)
  2. Set up the Arduino IDE and USB drivers (https://learn.sparkfun.com/tutorials/esp32-thing-p...)
  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

Share

    Recommendations

    • Beauty Tips Contest

      Beauty Tips Contest
    • Fandom Contest

      Fandom Contest
    • Frozen Treats Challenge

      Frozen Treats Challenge

    5 Discussions

    0
    None
    finnbearJaimeG93

    Reply 6 weeks ago

    I'm sure you could get it to work, with a slightly larger enclosure and different code to communicate over SPI rather than I2C.

    0
    None
    JaimeG93finnbear

    Reply 6 weeks ago

    Thank you! Will try it out once the parts arrive, I already made the case XD

    1
    None
    audreyobscura

    2 months ago

    Thanks for sharing your sensor build out!

    0
    None
    finnbear

    Tip 2 months ago on Step 4

    You can use a small pair of scissors to cut the protective plastic of the battery, allowing its wires to extend directly upwards. Otherwise, the enclosure may be too small.