Skip to main content

Air Quality Index Monitor

Project description

AQIMON

A simple Air Quality Index monitor, designed to work on the Raspberry Pi with the SDS011 Nova PM Sensor.

Screenshot

Screenshot

Installation

Pre-Requisites

  • Python 3.9+

Install

pip install aqimon

Running Aqimon

Aqimon is a simple web server. To start with all the defaults (assuming available SDS011 hardware on /dev/ttyUSB0), you can just run:

aqimon

And then go to your browser at http://{serveraddress}:8000/ to view the UI.

If you don't have the requisite SDS011 hardware, you can use a mock data source via a mock reader.

Configure With Systemd

Generally, you'd want to run Aqimon as an always-on service, using systemd.

To do so, create a file at /etc/systemd/system/aqimin.service with the following contents:

[Unit]
Description=AQIMON
After=multi-user.target

[Service]
Type=simple
Restart=always
ExecStart=aqimon

[Install]
WantedBy=multi-user.target

And then run:

sudo systemctl daemon-reload
sudo systemctl start aqimon

Configuration

Aqimon uses environment variables for configuration, but all values should ship with sensible defaults.

Variable Default Description
AQIMON_DB_PATH ~/.aqimon/db.sqlite The path to the database file, where read information is stored. It should be an absolute path; user home expansion is supported.
AQIMON_POLL_FREQUENCY_SEC 900 (15 minutes) Sets how frequently to read from the device, in seconds.
AQIMON_RETENTION_MINUTES 10080 (1 week) Sets how long data will be kept in the database, in minutes.
AQIMON_READER_TYPE NOVAPM The reader type to use, either NOVAPM or MOCK.
AQIMON_USB_PATH /dev/ttyUSB0 The path to the USB device for the sensor.
AQIMON_SLEEP_SEC_BETWEEN_READS 5 The number of seconds to wait for between each read in a set of reads.
AQIMON_SAMPLE_COUNT_PER_READ 5 The number of reads to take with each sample.
AQIMON_WARM_UP_SEC 15 The number of seconds to wait for the device to warm up before reading.
AQIMON_COMMAND_WAIT_TIME 1 The number of seconds to wait for the device respond to a command.
AQIMON_EPA_LOOKBACK_MIN 60*8 The number of minutes to look back at read data to calculate the EPA AQI.
AQIMON_SERVER_PORT 8000 The port to run the server on.
AQIMON_SERVER_HOST 0.0.0.0 The host to run the server on.

Contributing

Toolset

To start developing, you'll need to install the following tools:

Optionally, we have pre-commit hooks available as well. To install hooks, just run pre-commit install and then linters and autoformatting will be applied automatically on commit.

Quickstart

To build the project, and install all dev-dependencies, run:

just build

To start the server in develop mode, run:

poetry run aqimond

To compile elm changes, run:

just compile_elm

To manually run lint checks on the code, run:

just lint

To run auto-formatters, run:

just format

Using the Mock Reader

Aqimon ships with a mock reader class that you can use in the event that you don't have a reader available on your development computer. The mock reader just returns randomized reads. To use it, you can start the server like:

AQIMON_READER_TYPE=MOCK poetry run aqimon

Submitting a PR

Master branch is locked, but you can open a PR on the repo. Build checks must pass, and changes approved by a code owner, before merging.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aqimon-0.6.0.tar.gz (183.8 kB view details)

Uploaded Source

Built Distribution

aqimon-0.6.0-py3-none-any.whl (185.1 kB view details)

Uploaded Python 3

File details

Details for the file aqimon-0.6.0.tar.gz.

File metadata

  • Download URL: aqimon-0.6.0.tar.gz
  • Upload date:
  • Size: 183.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1037-azure

File hashes

Hashes for aqimon-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ecc38dc45db668c7ad2e4f0f47eea662ce62ca3d4979c61fc572dffd8169e9d6
MD5 98ea9106ed34239c4fa032cbb902e421
BLAKE2b-256 8798c7fa3591bd9be848a897c81b4db0abce5a231d3cff6da8674f0208791282

See more details on using hashes here.

File details

Details for the file aqimon-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: aqimon-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 185.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1037-azure

File hashes

Hashes for aqimon-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d1ebabfc373343a11b07c4decc210cf3d9669984418dd210f8cc09e86354a70
MD5 a1cf0137ef347d35ca4d63d447dc06e5
BLAKE2b-256 5a7771ee5e5308e5bbaced887e03e68008d2d0ce921efea373aba7818d35298d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page