An air quality monitoring app.
Reads data from an SDS011 particulate matter sensor via a serial port and uploads it to an Adafruit IO account.
Inspired by an article from HackSpace magazine issue 21 (August 2019).
There are probably much more comprehensive and robust implementations out there for reading from the SDS011 sensor. Don't rely on this app for accurate and reliable data.
Small particulate matter less than 10 microns in diameter (PM 10) is recognised globally by health and environmental organisations as a common contributor to air pollution.
Exposure to particle matter less than 2.5 microns in diameter (PM 2.5) is known to cause and contribute to respiratory and cardiovascular illness.
There is some evidence which suggests that high levels of PM may contribute to the transmission and lethality of COVID-19.
- Raspberry Pi (for convenience of placing the sensor)
- SDS011 PM sensor
- Serial to USB adapter
A python virtual environment is recommended. You can easily create a new virtual environment using venv.
python -m venv PM-App
Launch the virtual environment
E.g on a Unix/Linux OS run the execute the following from the root of the repo
source PM-App/bin/activate
Required dependencies are defined in requirements.txt.
You can install these using pip.
Pip install -r requirements.txt
An Adafruit IO account and API key are required in order to upload data.
Run python main.py setup
to launch the setup script.
This script will prompt for input and write the following values to the config.yml file:
- AIO username
- AIO API Key
- PM 2.5 feed name in AIO account
- PM 10 feed name in AIO account
Your AIO username and API key can be found on the AIO profile page, in the My Key
tab.
See the AIO API docs for more details on creating and useing API keys
Check that the feeds exist in your AIO account before proceeding to start the app. You may need to manually creat the feeds.
Check the contents of the config.yml
file before proceeding to start the app.
Ensure that the PM sensor unit is connected via a USB port to the device which will run the application
Check that the device has an active network connection
Run python main.py start
to launch the app.
Check the temrinal output to confirm that the sensor is active and the application is correctly reading and logging values Check the AIO feeds to confirm that the application is correctly sending data to the feeds
Automated tests are implemented using the Pytest framework.
From the root directory of the repo run python -m pytest
to execute tests.
This project uses cov for reporting test coverage
From the root directory of the repo run python -m pytest --cov
to execute tests and generate a coverage report.