AirGradient Pro v4.2 Arduino Sketch to track metrics to a Prometheus Pushgateway.
Here, pushgateway is used to avoid network access problems where the Prometheus server is on a different network, and NAT port forwarding cannot be configured. Prometheus only recommend using pushgateway for batch jobs. If you don't need to use pushgateway, you should probably use airgradient-prometheus over this (but it doesn't log the extra Pro sensor fields at time of writing).
Tested with an HTTPS pushgateway host, possibly needs modifications to work with insecure HTTP.
- Save certificate chain for your pushgateway domain:
cert.py -s example.com -n pushgateway_domain > certs.h
- Follow the Arduino setup instructions for flashing the AirGradient sensor. Make sure you connect the USB-C cable to the chip - not the power port on the back of the housing.
- Install the following libraries from the Arduino library manager (Tools -> Manage Libraries):
- AirGradient Air Quality Sensor (tested with 2.4.7)
- All the libraries from the header comment in the code
- Open the the code in Arduino Studio.
- Configure
pushgateway_host
andprometheus_http_basic_auth
(if desired). - Hit Upload in Arduino Studio.
- Check your monitoring set up is receiving data.
grafana.json
is the model JSON for an example dashboard to visualize this data (screenshot below).