update installation instructions

This commit is contained in:
raf 2023-11-29 02:02:05 +03:00
parent c266988396
commit 000b7b1c9a
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29

View file

@ -1,22 +1,65 @@
# Raspberry Pi Air Quality Monitor # Raspberry Pi Air Quality Monitor
A simple air quality monitoring service for the Raspberry Pi. A simple air quality monitoring service for the Raspberry Pi.
## Installation ## Installation
Clone the repository and run the following:
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
```bash ```bash
make install nix profile install github:notashelf/air-quality-monitor
``` ```
## Running After which you can use the installed package inside `screen` or with a Systemd service.
To run, use the run command:
```bash ### On NixOS
make run
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;
};
};
# ...
};
};
}
``` ```
## Architecture The above configuration will set up a systemd service and configure necessary environment variables for you without any additional input.
This project uses python, flask, docker-compose and redis to create a simple web server to display the latest historical values from the sensor. 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.
## Example Data ## Example Data
Some example data you can get from the sensor includes the following: Some example data you can get from the sensor includes the following:
```json ```json
@ -33,3 +76,8 @@ 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. 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. Different particles are from different sources, and can be hazardous to different parts of the respiratory system.
## 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/)