Categories
3D Printing COVID-19

DIY CO2 Monitoring on a Budget

Introduction

There is clear, long proven evidence that spread and infection of our novel fiend SARS-CoV-2 is via airborne particles. These particles could spend up to a whole 24 hours in the air before capturing to a surface without proper filtration or ventilation. As a result we’re seeing experts encouraging more effective respirators like N95s over surgical or medical masks. The push for HEPA filters and improved ventilation in schools and other public spaces has grown immensely. One way to measure how effective a given space’s ventilation is to measure the amount of CO2 (Carbon Dioxide) in the room.

Carbon Dioxide is what we humans constantly exhale as a waste gas. It spreads easily in the atmosphere so changes in the CO2 concentration in a space is a useful indicator how well ventilated (or not) it is such as this tracking board in a Japanese movie theatre.

Originally tweeted by NOG (@NOGjp) on July 17, 2021.

Through knowing the CO2 concentrations in a given space, we can make an inference that the higher CO2 concentration the higher risk to being exposed to SARS-CoV-2 and therefore contracting COVID-19.

Commercial CO2 Monitors

There’s a number of commercially available CO2/air quality monitors available including the Aranet4, but they’re generally pretty expensive (USD$200+) and as a result not accessible to the average person let alone education or the arts.

The Atmo Monitor v1

Assembly and Programming Video

Getting Started

Introducing the Atmo Monitor v1! This ultra compact device has been designed to be much more inexpensive than commercially available CO2 monitoring options and I’ve decided to open source this for educational purposes. This is in no way intended to be used as a medical device.

The Atmo Monitor v1 is based on a Raspberry Pico, a USD$4 microcontroller with plenty of Input/Output for our various peripheral sensors we’ll be attaching. The code is written in MicroPython, similar to Python 3 but optimized to run on a microcontroller.

As with all my projects, I started on a breadboard. This helped me visualize the I2C bus for chip communication and the power needs along the way. All of the chips required me to solder on their header pins and using a breadboard to make sure everything was nice and straight makes it all the easier.

What to expect

Upon plugging in the monitor, the LED will be white. Once the monitor has initialized it will turn blue indicating it received its first readings from the sensors and is starting the warm up phase. This phase lasts twenty minutes.

If, within the first five seconds of starting it starts getting reasonable readings from the sensors it will switch to its operating mode. The LED will now indicate the level of CO2 being detected in your air.

LED ColourDescription
WhiteInitializing
BlueWarm Up Mode
GreenCO2 < 1000ppm
Yellow1400ppm < CO2 > 1000ppm
RedCO2 > 1400ppm
LED Colour table

You may find that the sensor resets itself after a random period of time. It does this if the sensors send back a value that’s completely out of line. Rarely, and I mean rarely, the device may hang in the white or blue phase with the OLED not refreshing. Simply unplug the monitor and plug it back in.

When you first power on your monitor it’s important to let it sit for two days to allow the sensors to calibrate.

Bill of Materials

  • Raspberry Pico
  • ScioSense CCS811 breakout
  • Bosch-Sensortec BME280 breakout
  • An I2C-compatible 128×64 OLED package (SSD1306 recommended)
  • Common cathode RGB LED
  • Package of Dupont Wires
  • 830-Point Breadboard for prototyping
  • Header pins (if not included with your Pico or breakouts)

The CCS811 from ScioSense is a teeny tiny little chip that detects both CO2 and Total Volatile Organic Compounds (TVOC) that exist in the air you are sampling via what’s called a Metal-Oxide(MOX) sensor, also known as a chemiresistor.

Pictured here is the breakout board by SparkFun which made this project simpler was not cheap to ship to Canada.

The Bosch-Sensortec BME280 is the other important piece of the puzzle. The CCS811 on its own will report pretty okay values but it’s strongly recommended to pair it with some humidity and temperature values.

Pictured here is the breakout board by SparkFun.

Where to Buy

For those in the States or are unconcerned about shipping costs otherwise, I’d recommend the boards from SparkFun. They offer the Raspberry Pico, CCS811, and BME280. SparkFun does have distributors in Canada, like Calgary based Solarbotics. I would shop around if you’re looking for these specific boards.

One thing to note about SparkFun, the OLED I purchased from them was DOA and though it’s been two weeks since I inquired with them about a replacement I have not heard back.

Otherwise, I’m stuck having to recommend Amazon. The SSD1306 OLED package I ordered had five parts and included the header pins which made the price very right. I was able to pick up both sensor boards in bulk as well.

TAKE NOTE of the arrangement of the pins on the boards you purchase as we will be soldering them directly to the PCB. If you plan to use my PCB, the GND and 3V3 pins may be swapped on the boards you’re planning to purchase and you will have to modify the part footprints and wire paths to match.

The WAKE pin on the CCS811 may be the fifth or sixth pin so the PCB allows for either. If the WAKE pin is sixth pin, do not populate the fifth pin on the breakout board.

Code

You can find the complete program plus the required libraries in my GitHub repository.

I recommend using the Thonny IDE. It makes interfacing with the Raspberry Pico very easy and helps manage required libraries pretty simple. For the libraries I include in the repo, open and save them to the Pico under a folder called libs.

It’s important to note that when you save a file to the Pico named main.py that the next time the Pico is power cycled it will automatically execute the program that exists inside that file. It’s pretty difficult to get the Pico to accept an interrupt at that point so until you’re completely satisfied that you aren’t going to make any more changes to main.py that you run the program from the Thonny IDE.

If you do end up wanting to flash a new main.py to the Pico, hold down the BOOT SEL button on the Pico while you plug it in. It will appear on your computer as a USB drive where you should uncompress and upload this file to. Unplug and hold down BOOT SEL again, return to the Thonny IDE and reflash the Micropython bootloader to the Pico. Your main.py will have been renamed main-1.py so you can continue to work with your Pico. (Thanks to the MicroPython Forum for this tip.)

PCB

I designed the PCB in a free software suite called KiCad. The files available will only open in KiCad 6.0 and above. I use JLCPCB for the PCB construction as I’ve been very happy with them in the past with their super fast turn around time and reasonable pricing. Simply upload the Gerber files, specify your options, and they take care of the rest. Most importantly for this project (being it could end up in classrooms) is that they offer HASL lead-free finishing.

3D Printed Case

I’m in no way an expert in CAD design but I designed this 3D printed case in Autodesk Inventor. They offer discount pricing for education.

To download the STL files, find the design on Thingiverse.

MOX vs NDIR Sensors

Some familiar in this field may know that most commercially available air quality monitors use NDIR (Non-Dispersive Infrared) sensors. They use a specific wavelength of light to measure the amount of CO2 in the air. It powers a special LED on one side of the package and it collects on a sensor on the other side. When CO2 passes through the beam it absorbs this light so the sensor knows when less light is being detected by the sensor there’s CO2 present. They have a long life span, up to ten years.

Sensirion SCD30 CO2 NDIR I2C Package

Metal-Oxide (MOX) sensors measure the resistivity of specific metal compounds to test the amount of CO2 in the air. They have a tiny metal strip exposed to the air you want to test and when CO2 comes in contact it changes the chemical composition of the metal and the resistance across it changes.

Both of these sensors can be affected by temperature and humidity but the price difference and size of these two sensors is what helped me make this important design decision. I may design a version 2 which incorporates an NDIR sensor in the future but until then I’m confident the MOX sensor accomplishes what we’re going after.

License

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

I have chosen this license so others can adapt upon the various aspects of it but I do not believe that others should financially benefit from it as the goal of documenting this project is to encourage others to build these to help make their spaces safer in respect to exposure to SARS-CoV-2.

Categories
3D Printing Creality Ender-3 Pro

Setting up OctoPrint with your Ender 3 Printer

I recently got back into the 3D printing game and realized what my bottle neck was previously. Having my main machine on and not being able to reboot, etc while I was printing. Then I discovered OctoPrint.

The idea of OctoPrint is to offload the printing to a web-based interface so you can rest easy and monitor the print from any device at any time. The platform is incredibly scale-able with hundreds of plugins available from wi-fi switch control, filament inventory management, to timelapse generation. My OctoPrint configuration is a little customized and I’ll go into that later.

For this tutorial I’m using OctoPrint the most recent version at the time of writing, version 0.16.0. This also is the case with balenaEtcher, version 1.5.33. I’m doing this on Windows 10 however balenaEtcher is available on MacOS and Linux as well. If you’re missing any of the items needed to get started I’ve linked my recommendations below.

What you’ll need:

Getting started

First thing you’ll want to do is head over to the OctoPrint website and download the most recent version of the OctoPi distribution. For this tutorial I’m using 0.16.0. You’re also going to need a copy of balenaEtcher. Plug in your USB SD card reader with the micro SD card attached to your computer.

OctoPrint is the software that runs on the Raspberry Pi however the operating system distribution is called OctoPi. Extract the OctoPi image from the zip file you downloaded and open balenaEtcher. Select the img file you extracted and ensure that the software has your micro SD card selected. Then press “Flash!”

balenaEtcher with the OctoPi image and microSD card selected, ready to flash.

This will take a few minutes. When it’s done flashing it will attempt to verify that the operation was successful. In my experience I’ve never had this verification process end successfully and does not impact the rest of the guide.

When balenaEtcher confirms that it’s done go ahead and unplug your SD card reader and plug it back in. Open up “This PC” and you’ll find a new drive called “boot.” In my case it’s been assigned drive letter F:. Go ahead and open that drive.

If you plan on connecting your Raspberry Pi via WiFi, follow this. If you plan on connecting it via Ethernet, skip this entirely, Find the text file called “octopi-wpa-supplicant.txt”. I recommend using Notepad++ for this however Windows Notepad will work just fine. Scroll down to line 26 and remove the # beside lines 27, 28, 29, and 30 as I’ve done below. Fill in your WiFi SSID and password here. You’ll also want to ensure that the correct country is selected farther down in the file starting at Line 49. For me, that was adding a # beside "country=GB" and removing the # beside "country=CA". Lastly, save and close the file.

octopi-wpa-supplicant.txt with the WPA/WPA2 (most common) settings uncommented.

Safely eject and remove the SD card reader from your PC. Slide the SD card into your Raspberry Pi and plug it into power with the kit’s supplied mains power adapter. You should see a red LED indicator light on steady indicating the Raspberry Pi has power and a green LED indicator light flashing from time to time indicating it is accessing the micro SD card. Give it about 45-60 seconds to boot up.

Generally you should be able to point your web browser to octopi.local. It will bring you to the OctoPrint setup wizard. If not, log into your router and find the IP address for your OctoPrint instance. Every router/modem is different so if you’re not familiar on how to do this I would recommend doing a quick Google search.

OctoPrint’s Setup Wizard Welcome screen

When you’re successful in connecting to OctoPrint you’ll be greeted by this Setup Wizard screen. It’s pretty straight forward and each screen explains what’s recommended.

It’s really required that you set up a username and password for OctoPrint. Even if you don’t plan on having the interface accessible outside your network it’s a good idea to have some sort of access control to a device that heats up and potentially could set fire to your home, right? Set up your username and password on the Access Control screen and choose “Keep Access Control Enabled” to continue.

OctoPrint’s developers ask that you enable Anonymous Usage Tracking – you have the option to disable it but for me it’s not really a big deal that OctoPrint phones home about bugs and such. There’s also more granular controls later on in the settings related to this.

The connectivity check helps to confirm your Raspberry Pi has internet connectivity. Turning this off will only slow down your Pi if you don’t have an internet connection. The default check interval is 15 minutes but I bumped it up to 60. They also use Google’s DNS servers – which do track all requests – so I went ahead and changed to OpenDNS’ first DNS server, 208.67.222.222.

Next up is the plugin blacklist. Go ahead and enable it for safety’s sake. It’ll ask you to set up a slicing profile – I don’t recommend slicing directly on a Raspberry Pi and even still you’d need an older version of Cura to actually export a profile that this would support.

Finally, finish up by giving your printer a name, ensure the print bed and all other settings are correct.

That’s it! You’re done. Congratulations. Start by uploading your GCode and start printing. You can either click the upload button or drag the file over to the left hand side of the screen. The right hand “Upload to SD” is not active and not needed. It’s that easy!

Next I’d take a look through the OctoPrint Plugin Repository and see if you find anything that would make printing easier for you. For me, I use the following plugins:

There’s a lot there and not all of them are going to be applicable for your own particular use cases. It’s worth having a look through the Repository and seeing the possibilities OctoPrint can bring to your 3D printing experience.

I hope that this guide helped and if you have any questions, comments, or concerns don’t hesitate to leave a comment below. If this guide helped you please give it a share on your favourite social media platform. Good luck!