Build an Air Pollution Monitor with a Raspberry Pi, a Particulate Matter sensor and IoT Central

Published Jul 23 2020 06:36 PM 4,300 Views
Microsoft

Monitor Air Pollution with a Raspberry Pi, a Particulate Matter sensor and IoT Central

Background

Born of necessity, this project tracked the air quality over Sydney during the height of the Australian bushfires. I wanted to gauge when it was safe to go outside, or when it was better to close up the apartment and stay in for the day.


banner.png


#JulyOT

This is part of the #JulyOT IoT Tech Community series, a collection of blog posts, hands-on-labs, and videos designed to demonstrate and teach developers how to build projects with Azure Internet of Things (IoT) services. Please also follow #JulyOT on Twitter.


Introduction

In this hands-on lab, you will learn how to create and debug a Python application on a Raspberry Pi with Visual Studio Code and the Remote SSH extension. The app requires the Pimoroni Enviro+ pHAT, and reads data from the PMS5003 particulate matter (PM) and BME280 sensors and streams the data to Azure IoT Central.


Parts required

  1. Raspberry Pi 2 or better, SD Card, and Raspberry Pi power supply
  2. Pimoroni Enviro+ pHAT
  3. PMS5003 Particulate Matter Sensor with Cable available from Pimoroni and eBay.

This lab depends on Visual Studio Code and Remote SSH development. Remote SSH development is supported on Raspberry Pis built on ARMv7 chips or better. The Raspberry Pi Zero is built on ARMv6 architecture. The Raspberry Pi Zero is capable of running the solution, but it does not support Remote SSH development.

Solution Architecture


Let's get started

 

Head to Raspberry Pi Air Pollution Monitor

 

There are five modules covering the following topics:

 

  • Module 1: Create an Azure IoT Central application
  • Module 2: Set up your Raspberry Pi
  • Module 3: Set up your development environment
  • Module 4: Run the solution
  • Module 5: Dockerize the Air Quality Monitor solution

Source code

All source code available for the Raspberry Pi Air Pollution monitor


Acknowledgements

This tutorial builds on the Azure IoT Python SDK 2 samples.


Have fun and stay safe and be sure to follow us on #JulyOT.

%3CLINGO-SUB%20id%3D%22lingo-sub-1542844%22%20slang%3D%22en-US%22%3EBuild%20an%20Air%20Pollution%20Monitor%20with%20a%20Raspberry%20Pi%2C%20a%20Particulate%20Matter%20sensor%20and%20IoT%20Central%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1542844%22%20slang%3D%22en-US%22%3E%3CH1%20id%3D%22monitor-air-pollution-with-a-raspberry-pi-a-particulate-matter-sensor-and-iot-central%22%20id%3D%22toc-hId-498763094%22%20id%3D%22toc-hId-498763094%22%3EMonitor%20Air%20Pollution%20with%20a%20Raspberry%20Pi%2C%20a%20Particulate%20Matter%20sensor%20and%20IoT%20Central%3C%2FH1%3E%0A%3CH2%20id%3D%22background%22%20id%3D%22toc-hId-1189324568%22%20id%3D%22toc-hId-1189324568%22%3EBackground%3C%2FH2%3E%0A%3CP%3EBorn%20of%20necessity%2C%20this%20project%20tracked%20the%20air%20quality%20over%20Sydney%20during%20the%20height%20of%20the%20Australian%20bushfires.%20I%20wanted%20to%20gauge%20when%20it%20was%20safe%20to%20go%20outside%2C%20or%20when%20it%20was%20better%20to%20close%20up%20the%20apartment%20and%20stay%20in%20for%20the%20day.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22banner.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F207578i8432E74C2DAEAE63%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22banner.png%22%20alt%3D%22banner.png%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CHR%20%2F%3E%0A%3CH2%20id%3D%22julyot%22%20id%3D%22toc-hId--618129895%22%20id%3D%22toc-hId--618129895%22%3E%23JulyOT%3C%2FH2%3E%0A%3CP%3EThis%20is%20part%20of%20the%20%23JulyOT%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fhashtag%2FJulyOT%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EIoT%20Tech%20Community%3C%2FA%3E%20series%2C%20a%20collection%20of%20blog%20posts%2C%20hands-on-labs%2C%20and%20videos%20designed%20to%20demonstrate%20and%20teach%20developers%20how%20to%20build%20projects%20with%20Azure%20Internet%20of%20Things%20(IoT)%20services.%20Please%20also%20follow%20-ERR%3AREF-NOT-FOUND-%23JulyOT%20on%20Twitter.%3C%2FP%3E%0A%3CHR%20%2F%3E%0A%3CH2%20id%3D%22introduction%22%20id%3D%22toc-hId-1869382938%22%20id%3D%22toc-hId-1869382938%22%3EIntroduction%3C%2FH2%3E%0A%3CP%3EIn%20this%20hands-on%20lab%2C%20you%20will%20learn%20how%20to%20create%20and%20debug%20a%20Python%20application%20on%20a%20Raspberry%20Pi%20with%20%3CA%20href%3D%22https%3A%2F%2Fcode.visualstudio.com%2F%3FWT.mc_id%3Djulyot-aqm-dglover%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EVisual%20Studio%20Code%3C%2FA%3E%20and%20the%20%3CA%20href%3D%22https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3Dms-vscode-remote.remote-ssh%26amp%3BWT.mc_id%3Djulyot-aqm-dglover%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ERemote%20SSH%3C%2FA%3E%20extension.%20The%20app%20requires%20the%20%3CA%20href%3D%22https%3A%2F%2Flearn.pimoroni.com%2Ftutorial%2Fsandyj%2Fgetting-started-with-enviro-plus%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EPimoroni%20Enviro%2B%20pHAT%3C%2FA%3E%2C%20and%20reads%20data%20from%20the%20PMS5003%20particulate%20matter%20(PM)%20and%20BME280%20sensors%20and%20streams%20the%20data%20to%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fiot-central%2F%3FWT.mc_id%3Djulyot-aqm-dglover%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20IoT%20Central%3C%2FA%3E.%3C%2FP%3E%0A%3CHR%20%2F%3E%0A%3CH2%20id%3D%22parts-required%22%20id%3D%22toc-hId-61928475%22%20id%3D%22toc-hId-61928475%22%3EParts%20required%3C%2FH2%3E%0A%3COL%3E%0A%3CLI%3ERaspberry%20Pi%202%20or%20better%2C%20SD%20Card%2C%20and%20Raspberry%20Pi%20power%20supply%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Flearn.pimoroni.com%2Ftutorial%2Fsandyj%2Fgetting-started-with-enviro-plus%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EPimoroni%20Enviro%2B%20pHAT%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EPMS5003%20Particulate%20Matter%20Sensor%20with%20Cable%20available%20from%20%3CA%20href%3D%22https%3A%2F%2Fshop.pimoroni.com%2Fproducts%2Fpms5003-particulate-matter-sensor-with-cable%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EPimoroni%3C%2FA%3E%20and%20eBay.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EThis%20lab%20depends%20on%20Visual%20Studio%20Code%20and%20Remote%20SSH%20development.%20Remote%20SSH%20development%20is%20supported%20on%20Raspberry%20Pis%20built%20on%20ARMv7%20chips%20or%20better.%20The%20Raspberry%20Pi%20Zero%20is%20built%20on%20ARMv6%20architecture.%20The%20Raspberry%20Pi%20Zero%20is%20capable%20of%20running%20the%20solution%2C%20but%20it%20does%20not%20support%20Remote%20SSH%20development.%3C%2FP%3E%0A%3CH2%20id%3D%22solution-architecture%22%20id%3D%22toc-hId--1745525988%22%20id%3D%22toc-hId--1745525988%22%3ESolution%20Architecture%3C%2FH2%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fraw.githubusercontent.com%2Fgloveboxes%2FRaspberry-Pi-Python-Environment-Monitor-with-the-Pimoroni-Enviro-Air-Quality-PMS5003-Sensor%2Fmaster%2Fzdocs%2Fresources%2Fazure-iot-central-air-quality-monitor.png%22%20border%3D%220%22%20alt%3D%22%22%20%2F%3E%3C%2FP%3E%0A%3CHR%20%2F%3E%0A%3CH2%20id%3D%22lets-get-started%22%20id%3D%22toc-hId-741986845%22%20id%3D%22toc-hId-741986845%22%3ELet's%20get%20started%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHead%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-Raspberry%20Pi%20Air%20Pollution%20Monitor%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20five%20modules%20covering%20the%20following%20topics%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EModule%201%3A%20Create%20an%20Azure%20IoT%20Central%20application%3C%2FLI%3E%0A%3CLI%3EModule%202%3A%20Set%20up%20your%20Raspberry%20Pi%3C%2FLI%3E%0A%3CLI%3EModule%203%3A%20Set%20up%20your%20development%20environment%3C%2FLI%3E%0A%3CLI%3EModule%204%3A%20Run%20the%20solution%3C%2FLI%3E%0A%3CLI%3EModule%205%3A%20Dockerize%20the%20Air%20Quality%20Monitor%20solution%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CHR%20%2F%3E%0A%3CH2%20id%3D%22source-code%22%20id%3D%22toc-hId--1065467618%22%20id%3D%22toc-hId--1065467618%22%3ESource%20code%3C%2FH2%3E%0A%3CP%3EAll%20source%20code%20available%20for%20the%20-ERR%3AREF-NOT-FOUND-Raspberry%20Pi%20Air%20Pollution%20monitor%3C%2FP%3E%0A%3CHR%20%2F%3E%0A%3CH2%20id%3D%22acknowledgements%22%20id%3D%22toc-hId-1422045215%22%20id%3D%22toc-hId-1422045215%22%3EAcknowledgements%3C%2FH2%3E%0A%3CP%3EThis%20tutorial%20builds%20on%20the%20-ERR%3AREF-NOT-FOUND-Azure%20IoT%20Python%20SDK%202%20samples.%3C%2FP%3E%0A%3CHR%20%2F%3E%0A%3CP%3EHave%20fun%20and%20stay%20safe%20and%20be%20sure%20to%20follow%20us%20on%20-ERR%3AREF-NOT-FOUND-%23JulyOT.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1542844%22%20slang%3D%22en-US%22%3E%3CP%3EBorn%20of%20necessity%2C%20this%20project%20tracked%20the%20air%20quality%20over%20Sydney%20during%20the%20height%20of%20the%20Australian%20bushfires.%20I%20wanted%20to%20gauge%20when%20it%20was%20safe%20to%20go%20outside%2C%20or%20when%20it%20was%20better%20to%20close%20up%20the%20apartment%20and%20stay%20in%20for%20the%20day.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22banner.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F207577i8BE5DA69CFB9C528%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22banner.png%22%20alt%3D%22banner.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Version history
Last update:
‎Jul 23 2020 07:20 PM
Updated by: