{"id":241,"date":"2020-03-29T15:48:25","date_gmt":"2020-03-29T06:18:25","guid":{"rendered":"https:\/\/sighmon.com\/says\/?p=241"},"modified":"2020-03-29T15:48:26","modified_gmt":"2020-03-29T06:18:26","slug":"enviro-plus-air-quality-sensors","status":"publish","type":"post","link":"https:\/\/sighmon.com\/says\/enviro-plus-air-quality-sensors\/","title":{"rendered":"Enviro+ air quality sensors"},"content":{"rendered":"\n<p>The Pimoroni Enviro+ sensors arrived, and they were really easy to setup and get started which is always nice. Because I had a Raspberry Pi A+ laying around from a previous project I decided to use that instead of buying a new W. Unfortunately the clearance to the USB port isn&#8217;t quite enough, so I had to use a <a href=\"https:\/\/core-electronics.com.au\/2x20-socket-riser-header-for-raspberry-pi-hats-and-bonnets.html?utm_source=google_shopping&amp;gclid=EAIaIQobChMIm9yi0_S-6AIVkRiPCh3Thg64EAQYAiABEgL83PD_BwE\">header riser<\/a> to clear it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"679\" src=\"https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/pimoroni-enviro-plus-raspberry-pi-a-1024x679.jpg\" alt=\"Pimoroni Enviro+ air quality sensors connected to a Raspberry Pi A+\" class=\"wp-image-242\" srcset=\"https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/pimoroni-enviro-plus-raspberry-pi-a-1024x679.jpg 1024w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/pimoroni-enviro-plus-raspberry-pi-a-300x199.jpg 300w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/pimoroni-enviro-plus-raspberry-pi-a-768x509.jpg 768w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/pimoroni-enviro-plus-raspberry-pi-a-1536x1019.jpg 1536w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/pimoroni-enviro-plus-raspberry-pi-a-1568x1040.jpg 1568w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/pimoroni-enviro-plus-raspberry-pi-a.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Enviro+ sensors with a PMS5003 air quality sensor connected to a Raspberry Pi 3 A+<\/figcaption><\/figure>\n\n\n\n<p>After assembly I started with the basics using a <a href=\"https:\/\/www.raspberrypi.org\/downloads\/raspbian\/\">Raspbian<\/a> image to test out the <a href=\"https:\/\/github.com\/pimoroni\/enviroplus-python\">Pimoroni<\/a> sample code following their excellent <a href=\"https:\/\/learn.pimoroni.com\/tutorial\/sandyj\/getting-started-with-enviro-plus\">tutorial<\/a>. The output from the <a href=\"https:\/\/github.com\/pimoroni\/enviroplus-python\/blob\/master\/examples\/all-in-one.py\">all-in-one.py<\/a> script was pretty noise free and consistent. The only bug I hit was that on first boot I occasionally had to run the script twice to get the PMS5003 sensor to return values. Here&#8217;s a sample of the sensor data available:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2020-03-11 12:16:33.346 INFO pm1: 4.0 ug\/m3\n2020-03-11 12:16:33.347 INFO pm25: 6.0 ug\/m3\n2020-03-11 12:16:33.348 INFO pm10: 10.0 ug\/m3\n2020-03-11 12:16:33.455 INFO temp: 23.8 C\n2020-03-11 12:16:33.509 INFO pres: 1020.0 hPa\n2020-03-11 12:16:33.562 INFO humi: 32.1 %\n2020-03-11 12:16:33.570 INFO ligh: 13.3 Lux\n2020-03-11 12:16:33.660 INFO oxid: 1.5 kO - nitrogen dioxide (oxidising)\n2020-03-11 12:16:33.661 INFO redu: 525.1 kO - carbon monoxide (reducing)\n2020-03-11 12:16:33.661 INFO nh3: 47.9 kO - ammonia (NH3)<\/code><\/pre>\n\n\n\n<p>My next step was to get <a href=\"https:\/\/prometheus.io\">Prometheus<\/a> (software to store the sensor data) and <a href=\"https:\/\/grafana.com\">Grafana<\/a> (software to graph that data visually) installed and running so I could visualise what it looked like. Because I didn&#8217;t have a dedicated local server to run it on and wanted to containerise the software (with <a href=\"https:\/\/www.docker.com\">Docker<\/a>) in the long run, I decided to set it up on the Raspberry Pi.<\/p>\n\n\n\n<p>A couple of searches found a nice project to base it off of by <a href=\"https:\/\/github.com\/finestructure\/blogpost-prometheus\">Sven A. Schmidt<\/a>. I modified the Dockerfile to point to armv7 images for the Pi, and ended up with a nice multi-container <a href=\"https:\/\/github.com\/sighmon\/prometheus-grafana-raspberry-pi\">docker-compose<\/a> that will also work well with <a href=\"https:\/\/www.balena.io\">Balena<\/a> (software to deploy lots of Raspberry Pis) in the future.<\/p>\n\n\n\n<p>The only trick to get that up and running was pointing Grafana at the Prometheus data-source address: http:\/\/prometheus:9090 to start graphing data.<\/p>\n\n\n\n<p>Next I needed to get a Prometheus data exporter to expose the Enviro+ data. Open Source projects are so great, because another search and I came across <a href=\"https:\/\/github.com\/tijmenvandenbrink\/enviroplus_exporter\">Tymen&#8217;s Enviro+ exporter<\/a>! He didn&#8217;t have the PMS5003 sensor, so I put in a <a href=\"https:\/\/github.com\/tijmenvandenbrink\/enviroplus_exporter\/pull\/2\">pull-request<\/a> to add that feature. &#x1f5a4; Tymen also had a really great <a href=\"https:\/\/grafana.com\/grafana\/dashboards\/11605\">Grafana dashboard<\/a> setup, so here&#8217;s what the first data looked like:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"698\" src=\"https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/grafana-dashboard-enviro-plus-1024x698.png\" alt=\"\" class=\"wp-image-245\" srcset=\"https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/grafana-dashboard-enviro-plus-1024x698.png 1024w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/grafana-dashboard-enviro-plus-300x204.png 300w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/grafana-dashboard-enviro-plus-768x523.png 768w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/grafana-dashboard-enviro-plus-1536x1047.png 1536w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/grafana-dashboard-enviro-plus-2048x1396.png 2048w, https:\/\/sighmon.com\/says\/wp-content\/uploads\/2020\/03\/grafana-dashboard-enviro-plus-1568x1069.png 1568w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>The Pimoroni Enviro+ sensor output graphed by Grafana.<\/figcaption><\/figure>\n\n\n\n<p>Thinking of the end goal, it&#8217;d be great to containerise the sensor code &#8211; and again the Open Source community did most of the work for me! <a href=\"https:\/\/github.com\/sepulworld\/balena-environ-plus\">Zane Williamson&#8217;s project<\/a> was even built with Balena in mind, but it&#8217;s focus was exporting to <a href=\"https:\/\/meine.luftdaten.info\/\">Luftdaten<\/a>, so I forked his code and <a href=\"https:\/\/git-scm.com\/book\/en\/v2\/Git-Tools-Submodules\">Git-submoduled<\/a> in the enviro+ exporter. The outcome, a <a href=\"https:\/\/github.com\/sighmon\/balena-enviro-plus\">Docker container running the enviro+ exporter<\/a>.<\/p>\n\n\n\n<p>The final next step is to pull all of this together into a Balena app and deploy it with a public IP address so you can all access the data and see what it looks like. Stay tuned.<\/p>\n\n\n\n<p>If you&#8217;d like to support this project and have the skills to build your own, please purchase a <a href=\"https:\/\/core-electronics.com.au\/pimoroni-enviro-air-quality-for-raspberry-pi.html\">Enviro+<\/a> &amp; <a href=\"https:\/\/core-electronics.com.au\/pm2-5-air-quality-sensor-and-breadboard-adapter-kit-pms5003.html\">PMS5003<\/a> sensor kit, and then let&#8217;s deploy the code to yours remotely so we can compare data.<\/p>\n\n\n\n<p>Else if you&#8217;d like to support me purchasing more hardware: <a href=\"https:\/\/paypal.me\/simonloffler\">paypal.me\/simonloffler<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pimoroni Enviro+ air quality sensors exporting their data to Prometheus and graphed by Grafana.<\/p>\n","protected":false},"author":1,"featured_media":242,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54,9],"tags":[58,56,57,55,14],"class_list":["post-241","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry-pi","category-sensors","tag-air-quality","tag-enviro","tag-enviro-plus","tag-pimoroni","tag-sensors","entry"],"_links":{"self":[{"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/posts\/241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/comments?post=241"}],"version-history":[{"count":5,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/posts\/241\/revisions"}],"predecessor-version":[{"id":248,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/posts\/241\/revisions\/248"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/media\/242"}],"wp:attachment":[{"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/media?parent=241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/categories?post=241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sighmon.com\/says\/wp-json\/wp\/v2\/tags?post=241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}