This project is not affiliated with AirGradient Co Ltd., I am just a fan and user of their products.
Receive data from AirGradient sensors and expose it as Prometheus metrics.
For the device to send data to the exporter, it needs to be configured to send data to the exporter's IP address and port. This will require flashing the device with a custom sketch.
The following steps will guide you through the process of preparing your computer to flash the device.
- Install the Arduino Software for the ESP32-C3
- Install ESP8266 Arduino Core
- Install the required libraries
- Download the AirGradient sketch
- Open the sketch in the Arduino IDE
- Find and replace
YOUR_IP
with the IP address system that will host the exporter - Find and replace
YOUR_PORT
with the port the exporter will listen on (Default: 10000) - Select the correct board and port
- Upload the sketch to the device
- The device should now be configured send data to the exporter
The exporter will also serve configuration data back to the device. This cannot currently be disabled but will be configurable in the future. See the all of the AG prefixed options under Exporter Configuration for more information.
- Download the latest release for your platform
- If on Debian, copy dist/debian/airgradient-exporter.service to /etc/systemd/system/airgradient-exporter.service
- Run
sudo systemctl enable airgradient-exporter.service
- Copy the relevant binary to the system (/bin/airgradient-exporter)
- Run
sudo systemctl start airgradient-exporter.service
- Check the metrics endpoint by opening a web browser and going to
http://YOUR_IP:YOUR_PORT/metrics
The exporter can be configured using command line flags or environment variables. The following table lists the available configuration options.
Name | Description | Default | Options | CLI Flag | Environment Variable |
---|---|---|---|---|---|
Address | The address the exporter will listen on | 0.0.0.0 | * or a valid IP | --address |
AIRGRADIENT_EXPORTER_ADDRESS |
Port | The port the exporter will listen on | 10000 | 1-65536 | --port |
AIRGRADIENT_EXPORTER_PORT |
Path | The path the exporter will expose metrics on | /metrics | --path |
AIRGRADIENT_EXPORTER_PATH |
|
Log Level | The log level of the exporter | info | debug, info, warn, error, fatal, panic | --log-level |
LOG_LEVEL |
Country | The country the device is located in. Specifying US will cause the device to report in Fahrenheit |
US | Valid Country Code | --ag-country |
AIRGRADIENT_EXPORTER_AG_COUNTRY |
PM Standard | The PM standard to use. If left empty, the US AQI is used. | not set | empty, ugm3 | --ag-pm-standard |
AIRGRADIENT_EXPORTER_AG_PM_STANDARD |
CO2 Calibration Requested | Whether CO2 calibration is requested | false | true, false | --ag-co2-calibration-requested |
AIRGRADIENT_EXPORTER_AG_CO2_CALIBRATION_REQUESTED |
LED Bar Test Requested | Whether the LED bar test is requested | false | true, false | --ag-led-bar-test-requested |
AIRGRADIENT_EXPORTER_AG_LED_BAR_TEST_REQUESTED |
LED Bar Mode | The LED bar mode. If set to something other than off then the LED bar will represent the level of the measurement specified |
off | off, pm, co2 | --ag-led-bar-mode |
AIRGRADIENT_EXPORTER_AG_LED_BAR_MODE |
Model | The model of the device | not set | --ag-model |
AIRGRADIENT_EXPORTER_AG_MODEL |
|
MQTT Broker URL | The URL of the MQTT broker | not set | --ag-mqtt-broker-url |
AIRGRADIENT_EXPORTER_AG_MQTT_BROKER_URL |
- AirGradient
- Monitoring my home's air quality (CO2, PM2.5, Temp/Humidity) with AirGradient's DIY sensor
This project is licensed under the MIT License - see the LICENSE file for details.