2021-07-01 04:39:22 +00:00
|
|
|
# Raspberry Pi Air Quality Monitor
|
2023-11-28 23:02:05 +00:00
|
|
|
|
2021-07-01 04:39:22 +00:00
|
|
|
A simple air quality monitoring service for the Raspberry Pi.
|
|
|
|
|
|
|
|
## Installation
|
2023-11-28 23:02:05 +00:00
|
|
|
|
|
|
|
There are multiple ways to install this program. The main highlight of this fork is Nix & NixOS support, which would be the recommended way.
|
|
|
|
If you depend on Docker for running this program, refer to the original repository.
|
|
|
|
|
|
|
|
### With Nix
|
|
|
|
|
|
|
|
If you are on non-NixOS, but still have Nix installed on your system; you can install the package with
|
|
|
|
|
2021-07-01 04:39:22 +00:00
|
|
|
```bash
|
2023-11-28 23:02:05 +00:00
|
|
|
nix profile install github:notashelf/air-quality-monitor
|
2021-07-01 04:39:22 +00:00
|
|
|
```
|
|
|
|
|
2023-11-28 23:02:05 +00:00
|
|
|
After which you can use the installed package inside `screen` or with a Systemd service.
|
|
|
|
|
|
|
|
### On NixOS
|
|
|
|
|
|
|
|
This flake provides a NixOS module for automatically configuring the systemd service as well as the redis database for you.
|
|
|
|
A sample configuration would be as follows:
|
|
|
|
|
|
|
|
```nix
|
|
|
|
# flake.nix
|
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
pi-air-monitor.url = "github:notashelf/air-quality-monitor";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, ... } @ inputs: {
|
|
|
|
nixosConfigurations."<yourHostname>" = nixpkgs.lib.nixosSystem {
|
|
|
|
# ...
|
|
|
|
services.pi-air-quality-monitor = {
|
|
|
|
enable = true;
|
|
|
|
openFirewall = true; # if you want your service to only serve locally, disable this - defaults to true
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
port = 8081; # serve web application on port 8081
|
|
|
|
user = "pi-aqm";
|
|
|
|
group = "pi-aqm";
|
|
|
|
device = "/dev/ttyUSB0"; # this is the device port that corresponds to your sensor device
|
|
|
|
|
|
|
|
redis.createLocally = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
# ...
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
2021-07-01 04:39:22 +00:00
|
|
|
```
|
|
|
|
|
2023-11-28 23:02:05 +00:00
|
|
|
The above configuration will set up a systemd service and configure necessary environment variables for you without any additional input.
|
|
|
|
Plug in your sensor, and observe.
|
|
|
|
|
|
|
|
For a more hands-on approach, you may also choose to add `pi-air-monitor` package exposed by this flake to your systemPackages and
|
|
|
|
use it manually, or write your own systemd service.
|
2021-07-01 04:39:22 +00:00
|
|
|
|
|
|
|
## Example Data
|
2023-11-28 23:02:05 +00:00
|
|
|
|
2021-07-01 04:39:22 +00:00
|
|
|
Some example data you can get from the sensor includes the following:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2023-11-28 23:02:05 +00:00
|
|
|
"device_id": 13358,
|
|
|
|
"pm10": 10.8,
|
|
|
|
"pm2.5": 4.8,
|
|
|
|
"timestamp": "2021-06-16 22:12:13.887717"
|
2021-07-01 04:39:22 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
The sensor reads two particulate matter (PM) values.
|
|
|
|
|
|
|
|
PM10 is a measure of particles less than 10 micrometers, whereas PM 2.5 is a measurement of finer particles, less than 2.5 micrometers.
|
|
|
|
|
|
|
|
Different particles are from different sources, and can be hazardous to different parts of the respiratory system.
|
2023-11-28 23:02:05 +00:00
|
|
|
|
|
|
|
## Useful references
|
|
|
|
|
|
|
|
- [SDS011 datasheet](https://cdn-reichelt.de/documents/datenblatt/X200/SDS011-DATASHEET.pdf)
|
|
|
|
- [Air Quality Index meaning](https://www.airnow.gov/aqi/aqi-basics/)
|