Skip to content

MaxAnderson95/aranet4_exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prometheus exporter for the aranet4 CO2 sensor

This is a Prometheus metrics exporter for the Aranet4 CO2 sensor. It is written in Python and uses the Prometheus client library

The exporter connects to the sensor over bluetooth and exposes the following metrics:

  • aranet4_co2
  • aranet4_temperature
  • aranet4_pressure
  • aranet4_humidity
  • aranet4_battery_level
  • aranet4_update_interval
  • aranet4_since_last_update

Usage

  1. Set environment variables to configure the exporter:

    • POLLING_INTERVAL_SECONDS how often to poll the sensor (default: 5)
    • EXPORTER_PORT port to expose the metrics on (default: 80)
    • SENSOR_MAC_ADDRESS MAC address of the sensor to poll. If not set, the exporter will use autodiscovery to find the sensor.
  2. Install the dependencies:

    pip install -r requirements.txt
  3. Run the exporter:

    python src/main.py
  4. Test the exporter by view the output in a browser: http://localhost:80

Scraping and Dashboard

  1. Add the exporter to your prometheus config:

    scrape_configs:
      - job_name: co2-monitor
        static_configs:
          - targets:
              - {IP ADDRESS OF EXPORTER}:{EXPORTER_PORT}
            labels: null
            job: co2-monitor

    OR if you're using Prometheus Operator in Kubernetes, create the following ScrapeConfig CRD:

    apiVersion: monitoring.coreos.com/v1alpha1
    kind: ScrapeConfig
    metadata:
      name: co2-monitor
      namespace: monitoring
      labels:
        release: kube-prometheus-stack
    spec:
      staticConfigs:
        - labels:
          job: co2-monitor
          targets:
            - {IP ADDRESS OF EXPORTER}:{EXPORTER_PORT}
  2. Import the Grafana dashboard from dashboard.json into your Grafana instance. Choose the Prometheus data source that is configured to scrape the exporter.

    Grafana Dashboard showing air quality metrics.

Notes & credits

  • The exporter uses the pyaranet4 library to communicate with the sensor. Currently there is a bug when specifying a MAC address manually, so until this pr is merged, i've bundled a forked version of the library in this repo with the fix applied. Thanks stinjnstijn!

  • The basic scaffolding of the code for the exporter is based on Thomas Stringer's example. Thanks Thomas!

About

A Prometheus exporter for the aranet4 CO2 monitor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages