This uses the Pimoroni Enviro+ HAT to send environmental monitoring stats to Prometheus.
Usual disclaimer: I am not a programmer, so this may all be suuuuuper messy.
I did not include support for the particulate matter sensor, since I don't have one of those to test with.
The other sensors do work. However, I've been unable to find any information (so far) as to what exactly the proximity sensor is measuring, or what the noise sensor is measuring. I assume noise level in db, but I can't find any documentation. Same for amplitude. The examples provided by Pimoroni are inconsistent, too.
This also doesn't use the screen on the hat at all.
Relevant metrics are exposed using the enviroplus_
prefix. It does work on the regular Enviro (which does not have the gas sensors), despite the prefix having plus
in it.
- Obviously, the HAT.
- Raspberry PI. Any Raspberry PI -- this works very well on a Pi Zero.
- A GPIO extention cable, or some other way to have the HAT not sit directly on the PI. The PI's CPU temperature will affect readings.
- Prometheus server (obviously).
This assumes you'll be using the default 'pi' user.
- Set up Raspberry PI with the latest 'lite' version of Raspberry PI OS.
- Follow the instructions to installing the Pimoroni libraries here.
- Install the Prometheus client python library using
python3 -m pip install prometheus-client
(you might need tosudo apt-get install python3-pip
first). - Download
prometheus_enviroplus_exporter.py
and put it in/usr/local/bin/
. Make sure it is executable.
Run the program manually using /usr/local/bin/prometheus_enviroplus_exporter.py
. If you don't see any errors, congratulations! It's probably working!
By default, the exporter listens on port 9892, so curl localhost:9892/metrics
should show the metrics.
To get the thing to start automatically, download prometheus_enviroplus_exporter.service
and place it in /etc/systemd/system/
. Then run sudo systemctl enable prometheus_enviroplus_exporter.service
.
This is dependent on your own setup, but I create a JSON file in wherever Prometheus' base_node
data is (usually /etc/prometheus_data/base_node
) called enviro-<location>.json
, and it looks something like this:
[
{
"targets": [ "<ip address>:9892" ],
"labels": {
"hostname": "<hostname>",
"location": "<location>"
}
}
]
This allows you to filter by, well, location.