{"id":2235,"date":"2020-09-07T09:39:45","date_gmt":"2020-09-07T17:39:45","guid":{"rendered":"https:\/\/chriscarey.com\/blog\/?p=2235"},"modified":"2020-09-07T11:44:37","modified_gmt":"2020-09-07T19:44:37","slug":"purpleair-raspberry-pi","status":"publish","type":"post","link":"https:\/\/chriscarey.com\/blog\/2020\/09\/07\/purpleair-raspberry-pi\/","title":{"rendered":"PurpleAir Raspberry Pi"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"666\" data-attachment-id=\"2237\" data-permalink=\"https:\/\/chriscarey.com\/blog\/2020\/09\/07\/purpleair-raspberry-pi\/purple-pi\/\" data-orig-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2020\/09\/purple-pi.png\" data-orig-size=\"900,666\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"purple-pi\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2020\/09\/purple-pi.png\" data-large-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2020\/09\/purple-pi.png\" src=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2020\/09\/purple-pi.png\" alt=\"Purple Raspberry Pi\" class=\"wp-image-2237\"\/><\/figure>\n\n\n\n<p>With all the fires in California, I found myself checking <a rel=\"noreferrer noopener\" href=\"https:\/\/purpleair.com\" target=\"_blank\">PurpleAir<\/a> multiple times per day to track what the air is like outside &#8211; waiting for a moment when the AQI improves so we can open some windows or take a walk.<\/p>\n\n\n\n<p>I have a bunch of Raspberry Pi boards handy, and two with the Pimoroni <a href=\"https:\/\/shop.pimoroni.com\/products\/unicorn-hat\" target=\"_blank\" rel=\"noreferrer noopener\">Unicorn Hat<\/a> 64 RGB light array on them. This would work perfectly as a display for current air quality conditions.<\/p>\n\n\n\n<p>In addition I have a few of the <a href=\"https:\/\/blink1.thingm.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Blink(1) USB lights<\/a>. This will add even more color.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>The basic premise is quite simple:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Fetch PurpleAir data from the website<\/li><li>Display colors on the Pi<\/li><\/ul>\n\n\n\n<p>The script got a little more complicated in that I want it to:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Only hit PurpleAir once every x seconds<\/li><li>Update the colors on the Unicorn Hat slowly so we can more easily see when we are transitioning from one color to another<\/li><li>Show some indication that the script is still running<\/li><li>Handle HTTP errors gracefully<\/li><\/ul>\n\n\n\n<p>I posted the code over on GitHub. Right now it&#8217;s pretty specific to my setup but will make it a bit more generic to work with more hardware options going forward.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/chriscareycode\/purpleair-raspberry-pi\" target=\"_blank\" rel=\"noreferrer noopener\">Code on GitHub<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With all the fires in California, I found myself checking PurpleAir multiple times per day to track what the air is like outside &#8211; 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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[59],"tags":[],"class_list":["post-2235","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/prpYG-A3","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/posts\/2235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/comments?post=2235"}],"version-history":[{"count":7,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/posts\/2235\/revisions"}],"predecessor-version":[{"id":2244,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/posts\/2235\/revisions\/2244"}],"wp:attachment":[{"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/media?parent=2235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/categories?post=2235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/tags?post=2235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}