A $90 DIY Weather Station with Air Quality Monitoring

About a month ago, I built a weather station to put on my front porch (where all the good shade lives). I hadn’t done a write-up yet, but since this weather station includes a Particulate Matter sensor and we live in these times where suddenly Air Quality is important for quite a lot of people who didn’t need to notice it previously, I’m doing that write-up now.

This weather station captures the following metrics:

  • Temperature
  • Atmospheric Pressure
  • Relative Humidity
  • VOC (note that this is mostly useless unless running the board in Arduino mode, for which no code is supplied)
  • Particulate Matter (PM1.0, PM2.5, PM10, Particles per 0.1L air at < 0.3, <0.5, <5.0, and <10.0 microns particle size)

The Hardware

I can’t guarantee that these parts will be available forever – if this article is old, you may find you need to substitute some parts. Listed prices are USD.

  • Feather S3 by Unexpected Maker – $22
  • PMSA003i PM sensor with STEMMA QT I2C Connector – $45
  • BME680 sensor with STEMMA QT I2C Connector – $19
  • 2 x STEMMA QT cables – $1 each
  • Enclosure – custom enclosure STL files are available in the Gitlab repo for this project (see link in next section), or you can make your own any way you like. It needs to be ventilated, shaded, and protected from precipitation.
  • USB-C cable – for programming the Feather S3, a cable capable of data transfer is needed. Once programmed, a power-only cable is sufficient.
  • Optional: a LiPo battery. The Feather S3 board has on-board battery management and a connector. A battery will enable you to move the station without it losing power, and will allow it to survive short power outages without restarting. A large enough battery will allow it to be placed in otherwise un-powered locations, possibly with solar panel support.
  • Optional: a graphical display. This could be in the form of a FeatherWing, a separate board with a STEMMA QT connector, or a board with basic GPIO pins requiring a custom connection. The enclosure does not support a graphical display as-is, and you will need to write in the code to connect to and display the data on the display.

The Project

For the complete code that is running on my weather station, please visit my Weather Station Gitlab Repository. Because not everyone will want to use MQTT as the data transport mechanism, I will also provide some resources below to help you modify the code to fit your needs.

Secrets

This script comes with a file named secrets-example.py. You should edit this file to include the relevant secrets (at minimum you’re likely going to need wifi credentials) and save it as secrets.py. You can also add additional secrets to the file to meet your needs.

External Libraries

This script makes use of some CircuitPython libraries that are not part of CircuitPython’s core. You’ll need to grab a copy of the CircuitPython bundle that matches your board’s CircuitPython version. The easiest way to confirm your board’s CircuitPython version is to connect to the board’s serial console and enter the REPL. The version will be printed in the welcome line.

If you’re not sure how to connect to the serial console, check Connecting to the Serial Console in the Adafruit Learning Portal’s Welcome to CircuitPython tutorial.

The libraries you will need are:

  • adafruit_bme680
  • adafruit_minimqtt
  • adafruit_pm25

These libraries should be copied into the lib directory on the board’s USB drive. If there’s no lib directory, make one at the top level. Some libraries have their own directory, while others are single .mpy files.

MQTT

If you want to use the code as-is, you will need an MQTT broker. You can run your own MQTT broker service or subscribe to an already-established service – which one you choose is beyond the scope of this article.

Once you have MQTT and WiFi credentials, enter them into secrets.py and you should be good to run the script.

What do I do with the Data?

Once the data from my weather station reaches my MQTT broker, I pull it into OpenHAB and display it in a weather dashboard along with data pulled from a weather API. I also poll the temperature data using a Huginn agent for other Huginn agents to act on depending on the temperature value (sends Pushover notifications when the temperature crosses freezing/not freezing and open-the-windows/close-the-windows thresholds).

Data Transport Alternatives

In the event that you do not want to use MQTT as your data transport mechanism, here are a few alternatives.

  • http api – serve up individual datapoints in JSON via http using the CircuitPython http server
  • prometheus – serve up all datapoints on one plaintext document via http using Prometheus Express (NB: the last meaningful update to that repository was made about 3 years prior to this article’s publication date)
  • Direct to connected display – make this a completely portable solution by adding a LiPo battery and a display for on-the-go air quality information. Put it in an enclosure so you don’t damage the electronics or scare the normies. Add some buttons and button-press handling code to allow rotating through the different datapoints. Readings can be logged to a file on the board’s USB drive as long as it’s not mounted to a computer. Or, add an I2C SD card board and log your data there.
  • Using the on-board RGB LED – add in AQI calculation (see next section) and use the Feather S3’s on-board RGB LED to communicate the AQI by official color for an extremely low-res visual indication

Calculating the Air Quality Index

The weatherstation.py script does not currently calculate the Air Quality Index, but I do have an AQI calculation script for the PMSA003i that I originally wrote for the MagTag, which could be adapted and incorporated into weatherstation.py. I wrote this script using the EPA’s Technical Assistance Document for the Reporting of Daily Air Quality – The Air Quality Index (AQI) resource. This document details how the US Air Quality Index (used, for example, by AirNow.gov) is calculated.

You may alternately choose to use Patrick Ferraz’s airquality Python library, which does the same thing but encloses the calculations within a library function and can handle calculations for more pollutants than PM2.5 and PM10.0.

If you’re using MQTT, you could easily run a separate Python script on a separate machine to calculate the AQI using your local readings and report them back over to your MQTT broker.

What About Indoor Air Quality?

You could choose to run this weather station indoors, but if your home’s air filtration is up to par, the PMSA003i will yield extremely low readings and probably won’t be worthwhile. A more useful sensor for an indoor air quality monitor is one that reads CO2 concentration. CO2 concentration is commonly used to determine whether an indoor space’s ventilation is adequate.

Conclusion

Manufactured outdoor weather stations usually don’t include a particulate matter sensor. PM sensors can be purchased as add-on modules for some systems. Chances are good that you’ll spend several hundred dollars on such solutions. If you’re DIY-inclined, this weather station may be a good low-cost alternative.

If you find an error in this article or within the linked Gitlab repository, please let me know by submitting a comment here or you may contact me via ActivityPub.

10 Micro-electronics Projects that Aren’t Robotics

There’s more to educational/hobby micro-electronics than building robots.

If you or your kid can’t muster up excitement about robotics, go take a peek at these 10 projects. I’ve included a variety of different projects that do different things, run on different platforms, require different knowledge levels, and have different price points. Some of them also include the opportunity to learn about enclosure fabrication.

1. The Pimoroni Grow

https://learn.pimoroni.com/assembling-grow

This handy widget is a Raspberry Pi “HAT” (that stands for “Hardware-On-Top”). It connects to a Raspberry Pi’s GPIO pins, and is compatible with any Raspberry Pi model that has 40 GPIO pins (so, not the very earliest Pis). It is easy to connect to a Raspberry Pi – you just (carefully) plug it in so that all 40 pins are seated in the Grow’s GPIO socket. You can separate the two boards later if you need to.

The Grow uses connected capacitive touch sensors on custom-designed plant marker sticks to detect the moisture level in potted plant soil, and then gives a visual indication of moisture level for up to 3 sensors.

2. SparkFun OBD-II UART board

https://learn.sparkfun.com/tutorials/obd-ii-uart-hookup-guide

Learn how to read vehicle diagnostics over a serial connection. Those with more experience in micro-electronics should be able to, for example, create a portable version that runs on an Arduino or Raspberry Pi, features a screen and selection options, is rechargeable, and has a custom enclosure.

3. PiHut RasPi TV HAT

https://thepihut.com/blogs/raspberry-pi-tutorials/how-to-stream-digital-tv-with-the-raspberry-pi-tv-hat

Feed digital OTA (broadcast) TV into this board while it’s plugged into a Raspberry Pi and you can stream broadcast TV to other devices on your network.

4. MagTag Pet Feeding Clock

Does your pet tell lies about not having been fed yet? This project is for you!

You can easily program this lightweight smart display to update the date and time your pet was last fed by pushing the left-most button. While it’s not included in the tutorial, a more advanced version of this would give you the ability to track most-recent mealtimes for up to 4 pets (or food plus 3 different medications).

5. Pwnagotchi WiFi Pentester

Test your home network’s wireless security.

Reminder: hack responsibly.

6. Digital-to-Analog Audio Conversion

https://www.hifiberry.com/docs/hardware/up-cycle-your-vintage-audio-system-what-to-do/

Have you found a nice pair of old analog speakers at a yard sale? Give them new life with a Raspberry Pi HAT from HiFiBerry.

While you’re at it, you can use the same Raspberry Pi board to also host a local streaming music server using Jellyfin. Note that you will need to have music files stored locally.

7. Environment Sensor HAT

There’s no specific project tutorial for this one, but similar tutorials are available, and part of the lesson can be adapting to using different hardware. This HAT would be great for an offline local weather conditions display. It even has onboard motion sensing for those of you who live in places where earthquakes are frequent. For even more experienced programmers, how about including weather prediction by data analysis?

9. Binary Clock Soldering Kit

This Binary Clock project is a soldering kit that also presents an opportunity to custom fabricate a case. It comes with a printed circuit board, board components, and a pre-programmed IC, so no programming skills are needed for this one.

10. E-Paper Badge

Show your name (or whatever else you want) on a small e-paper display you can wear. You can add magnets to the back to attach it to your shirt or connect it to a badge lanyard (tip: make that easier by adding a bezel-type frame with lanyard loops).

Where to Next?

Once you learn the basic concepts of connecting peripherals and programming logic, you can take disparate components and make something completely new! There are quite a few hobby electronics suppliers out there these days, with lots of platform and form-factor options (we didn’t even get into soft circuits, which are electronics built into clothing using conductive thread and sew-on components!). Browse those tutorial sections, follow makers on Twitter, and maybe even write a tutorial of your own!

Indoor COVID-19 Mitigation Strategies for Fall 2021

You know it’s coming: you’re going to be guilt-tripped into attending a family shindig during a major holiday during the part of the year (in the Northern Hemisphere) where being outdoors isn’t a comfortable alternative. And maybe some of your family members are refusing to be vaccinated, while others may be immunocompromised. It is a pickle, but there are some things you can do to lower the risk of those gatherings turning into super-spreader events. I don’t know about you, but even though I’m vaccinated, I don’t relish needing to spend an entire week sick, miserable, and in bed!

Risk mitigation is when you take an action or put a control in place that reduces the risk of bad things happening. Mitigations are rarely 100% effective, but they don’t need to be, either. When you combine two or more risk-mitigating actions or controls, you combine the risk-reducing effect they have. Combining mitigations that work in different ways (for example, providing both shade and water to people working outdoors in hot conditions) works better than each action alone does.

1. Everyone Wears a Mask

Pick a mask, any mask. As long as it fits well and is worn properly, a mask can reduce the number of viral particles ejected into the air from your nose and mouth while you are breathing, talking, singing, yelling, coughing, or even sneezing. By reducing the number of viral particles that make it into the air, you also reduce the total number of viral particles in the air.

2. Everyone Wears a (K)N95 Mask

Cloth and surgical masks are great at blocking large droplets. Certified N95 masks and their untested-but-possibly-easier-to-find cousins KN95 masks can stop fine aerosols. They also are much better at keeping air from leaking out via the edges – and they don’t tend to push against your nose the way cloth masks do. Make sure you get the kind that doesn’t have valves – those aren’t as effective because they don’t block viral particles and fine aerosols on the way out. An added benefit is that this type of mask works in both directions – it can help keep viral particles out of your respiratory system (though they won’t keep the virus out of your eyes).

3. Monitor CO2 Levels and Cross-ventilate When Necessary

Researchers at UC Boulder figured out that CO2 concentrations in a space correlate to the risk of covid-19 spread. Properly ventilating indoor spaces to reduce viral spread is a concept that dates back at least to the 1918 pandemic. The tl;dr is that you can use a CO2 monitor to tell you when you need to throw open a window or two and let in some fresh air.

However, a pro-grade CO2 monitor may cost you several hundred dollars, something a lot of people just don’t have. DIY electronics hobbyists have an alternate solution for you, though: DIY CO2 monitors.

There are a variety of plans and tutorials available, all the way from source-all-parts-yourself to programmable gadgets (such as the Raspberry Pi) that just need a CO2 sensor plugged in.

4. Add Ad-hoc Filtration

The EPA recommends increasing ventilation system airflow in both homes and institutional spaces to reduce the spread of covid-19. When modifying an existing ventilation system is cost-prohibitive, or you don’t have any control over it, an in-room filtration solution can help out. Some air filters can be very pricey – but some smart people at an air filter company – working with an environmental engineer at Portland State U – came up with an accessible, inexpensive, high-capacity solution: a 20″ box fan and some 20″ x 20″ MERV-13 rated air filters. The design calls for 5 filters, but if one side of the resulting cube is going to sit flush on a flat surface, you can probably do just 4 filters.

5. Maintain Adequate Relative Humidity

The consistently cold temperatures of winter cause relative humidity to drop. Viral particles (of all kinds) thrive in drier air. The solution? Monitor and maintain an indoor relative humidity of 40-60%. Your respiratory system will be happier. It is also harder for viruses to infect people who have sufficiently moist respiratory passages. Some DIY CO2 sensor modules will also report temperature and relative humidity, so if you’re going to build a DIY CO2 monitor, you may be able to add in humidity reporting!

In Conclusion…

The covid-19 pandemic is far from over. Life tries to go on in spite of that, but we can all take part in reducing covid transmission by adopting mitigation strategies. Don’t think your family will go for it? Try making your attendance contingent on these controls being put into place, and stick to that. Or, host the next one, and make everyone else’s attendance contingent on their compliance. Use FOMO to your advantage, here.


Image: Yoga in a Yellow Suit by Cottonbro