PurpleAir Raspberry Pi

Purple Raspberry Pi

With all the fires in California, I found myself checking PurpleAir multiple times per day to track what the air is like outside – waiting for a moment when the AQI improves so we can open some windows or take a walk.

I have a bunch of Raspberry Pi boards handy, and two with the Pimoroni Unicorn Hat 64 RGB light array on them. This would work perfectly as a display for current air quality conditions.

In addition I have a few of the Blink(1) USB lights. This will add even more color.

There is example code provided in python for both the Unicorn Hat and the blink(1) light, so that would be easiest to throw something together in python.

The basic premise is quite simple:

  • Fetch PurpleAir data from the website
  • Display colors on the Pi

The script got a little more complicated in that I want it to:

  • Only hit PurpleAir once every x seconds
  • Update the colors on the Unicorn Hat slowly so we can more easily see when we are transitioning from one color to another
  • Show some indication that the script is still running
  • Handle HTTP errors gracefully

I posted the code over on GitHub. Right now it’s pretty specific to my setup but will make it a bit more generic to work with more hardware options going forward.

Code on GitHub


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *