~goorzhel/poeira

PMS5003 sensor. Pi Zero W. Portuguese word for "dust".
1fcbb391 — Antonio Gurgel 2 months ago
Leave TODOs
9c83abb8 — Antonio Gurgel 1 year, 22 days ago
Add GPL notices
044a7847 — Antonio Gurgel 2 years ago
Give Frame Eq

refs

main
browse  log 
cli-0.15.1
release notes 

clone

read-only
https://git.sr.ht/~goorzhel/poeira
read/write
git@git.sr.ht:~goorzhel/poeira

You can also use your local clone with git send-email.

#Poeira

A service for gathering metrics from a Plantower PMS sensor through a Raspberry Pi. The name is Portuguese for dust and pronounced poh-AY-rah.

Thanks to Adafruit for hardware and code.

#Setup

The only device type supported for now is UART. These instructions were tested on a Pi Zero W running Void Linux.

        PMS    Pi
Power     1     2 (or 4)
Ground    2     6
RX        4     8 (UART TX)
TX        5    10 (UART RX)
Reset     6    11 (GPIO #17)
  1. Connect or solder the pins as shown above. So far, Poeira implements no commands that require the UART TX connection, but it's nice to have.
  2. Boot the Pi with enable_uart=1 in /boot/config.txt. The sensor should be accessible at /dev/ttyAMA0.
  3. If not root, the user running poeira should at least be in the dialout and gpio groups. Accordingly, you'll want this udev rule for sending reset commands:
[ag@hell ~]$ cat /etc/udev/rules.d/00-gpio.rules
SUBSYSTEM=="gpio", GROUP="gpio", MODE="0660"

#Usage

By default, the Poeira CLI writes CSV to standard output.

[ag@hell ~]$ poeira /dev/ttyAMA0
Time,PM1.0 CF=1,PM2.5 CF=1,PM10.0 CF=1,PM1.0 CF=atm,PM2.5 CF=atm,PM10.0 CF=atm,0.3 μm,0.5 μm,1.0 μm,2.5 μm,5.0 μm,10.0 μm
2021-11-12 22:36:43.818,9,13,13,9,13,13,1776,510,92,4,0,0
2021-11-12 22:36:44.658,9,13,13,9,13,13,1776,510,92,4,0,0
2021-11-12 22:36:45.498,9,13,13,9,13,13,1776,510,92,4,0,0
2021-11-12 22:36:46.408,9,13,13,9,13,13,1740,500,98,6,0,0
<...>

It's also a good idea to pass -r 17 (or whichever GPIO pin is soldered as the Reset one) to reinitalize the sensor each time Poeira starts.

To activate the Prometheus endpoint, pass -o prometheus. The Poeira CLI will start listening on 127.0.0.1:8016, unless a different socket address is passed with -s.

[ag@hell ~]$ poeira /dev/ttyAMA0 -o prometheus -s 0.0.0.0:9000 -r 17 &
[1] 582

[ag@elsewhere ~]$ curl -s hell:9000/metrics | head -3
# HELP poeira_atm PM measurements using CF=atm
# TYPE poeira_atm gauge
poeira_atm{pm="10"} 1
Do not follow this link