Skip to content

Commit

Permalink
Merge branch 'sighmon-add/1-pms5003-particulate-matter-sensor'
Browse files Browse the repository at this point in the history
  • Loading branch information
tijmenvandenbrink committed Mar 15, 2020
2 parents ec69ec4 + 0e1a1a3 commit 0a52f81
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,19 @@ I added two labels to the targets ```group: environment``` and ```location: Some

### Grafana

I will publish a Grafana Dashboard shortly.
I published the dashboard on [grafana.com](https://grafana.com/grafana/dashboards/11605). You can import this dashboard using the the ID 11605. Instructions for importing the dashboard can be found [here](https://grafana.com/docs/grafana/latest/reference/export_import/).

<p align="center">
<a href="images/grafana_dashboard_1.png">
<img src="images/grafana_dashboard_1.png" alt="Grafana Dashboard 1" width="480" height="280">
</a>
<a href="images/grafana_dashboard_2.png">
<img src="images/grafana_dashboard_2.png" alt="Grafana Dashboard 2" width="480" height="280">
</a>
<a href="images/grafana_dashboard_3.png">
<img src="images/grafana_dashboard_3.png" alt="Grafana Dashboard 3" width="480" height="280">
</a>
</p>

<!-- ROADMAP -->
## Roadmap
Expand Down
17 changes: 17 additions & 0 deletions enviroplus_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from bme280 import BME280
from enviroplus import gas
from pms5003 import PMS5003, ReadTimeoutError as pmsReadTimeoutError

try:
from smbus2 import SMBus
Expand All @@ -34,6 +35,7 @@

bus = SMBus(1)
bme280 = BME280(i2c_dev=bus)
pms5003 = PMS5003()

TEMPERATURE = Gauge('temperature','Temperature measured (*C)')
PRESSURE = Gauge('pressure','Pressure measured (hPa)')
Expand All @@ -43,6 +45,9 @@
NH3 = Gauge('NH3', 'mostly Ammonia but could also include Hydrogen, Ethanol, Propane, Iso-butane (Ohms)')
LUX = Gauge('lux', 'current ambient light level (lux)')
PROXIMITY = Gauge('proximity', 'proximity, with larger numbers being closer proximity and vice versa')
PM1 = Gauge('PM1', 'Particulate Matter of diameter less than 1 micron. Measured in micrograms per cubic metre (ug/m3)')
PM25 = Gauge('PM25', 'Particulate Matter of diameter less than 2.5 microns. Measured in micrograms per cubic metre (ug/m3)')
PM10 = Gauge('PM10', 'Particulate Matter of diameter less than 10 microns. Measured in micrograms per cubic metre (ug/m3)')

OXIDISING_HIST = Histogram('oxidising_measurements', 'Histogram of oxidising measurements', buckets=(0, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 100000))
REDUCING_HIST = Histogram('reducing_measurements', 'Histogram of reducing measurements', buckets=(0, 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 1300000, 1400000, 1500000))
Expand Down Expand Up @@ -104,6 +109,17 @@ def get_light():
LUX.set(lux)
PROXIMITY.set(prox)

def get_particulates():
"""Get the particulate matter readings"""
try:
pms_data = pms5003.read()
except pmsReadTimeoutError:
logging.warn("Failed to read PMS5003")
else:
PM1.set(pms_data.pm_ug_per_m3(1.0))
PM25.set(pms_data.pm_ug_per_m3(2.5))
PM10.set(pms_data.pm_ug_per_m3(10))


if __name__ == '__main__':
parser = argparse.ArgumentParser()
Expand All @@ -128,3 +144,4 @@ def get_light():
get_humidity()
get_gas()
get_light()
get_particulates()
Binary file added images/grafana_dashboard_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/grafana_dashboard_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/grafana_dashboard_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0a52f81

Please sign in to comment.