~goorzhel/poeira

PMS5003 sensor. Pi Zero W. Portuguese word for "dust".

044a784 Give Frame Eq

5 months ago

7b600d8 poeira-cli 0.15.1

9 months ago

#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