Skip to content

Influx logging for the AirGradient DIY Pro

License

Notifications You must be signed in to change notification settings

TakosThings/AirGradient-Influx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AirGradient-Influx

Save data from the AirGradient DIY Pro air quality monitor to a locally hosted Influx DB 2 instance.

Setup

AirGradient instructions (PCB < 3.7)
Arduino IDE instructions

  1. Install libraries
    • ESP8266 by ESP8266 Community v2.7.4 (in Board Manager) *
    • AirGradient Air Quality Sensor by AirGradient v2.2.0
    • WifiManager by tzapu, tablatronix v2.0.11-beta
    • U8g2 by oliver v2.32.15
    • ESP8266 Influxdb by Tobias Schurg v3.13.1
  2. mv or rename arduino_secrets.h.example to arduino_secrets.h
  3. In Influx DB: create a new org and bucket for your AirGradient
  4. Go to Load Data > Sources > Arduino
  5. Copy INFLUXDB_URL, INFLUXDB_TOKEN, INFLUXDB_ORG, INFLUXDB_BUCKET to arduino_secrets.h
  6. Find TZ_INFO in the sketch file and set your timezone from this list. The default is GMT0
  7. Verify and upload

Displaying the data in Grafana

  1. In Influx DB: create a new read-only API token for Grafana
  2. Add a new data source in Grafana using the API token (Change Query Language to Flux)
  3. Create a new panel in your dashboard and select the AirGradient data source
  4. Use the InfluxDB Data Explorer to create the Flux queries for you

Other

  • Tested with PCB v3.3
  • Use board LOLIN(WEMOS) D1 R2 & Mini
  • OLED brightness can be adjusted by setting u8g2.setContrast(value) in setup()
    • Default is 50
    • value: 0 to 255

* I experienced frequent crashing using anything newer than ESP8266 v2.7.4, YMMV

Variants

  • default: This is based off the DIY_PRO example. Sensor readings are reported to an InfluxDB instance
  • no-pm2.5: Same as above, but with the PM2.5 sensor unplugged. Useful for quiet environments like a bedroom or studio.
  • scheduled-oled: Based off no-pm2.5. The OLED display is turned off between 0 and 8(am). This can be adjusted (and expanded upon) by modifying updateOledBrightness(). The time check is performed every 5 minutes.