AirGradient’s sensor set up is a good base and reasonably affordable. This Arduino sketch allows you to integrate with a locally run InfluxDB instance or MQTT. This also allows you to easy integrate with Home Assistant. This was loosely based off of AirGradient’s original example. A couple additional features are also included.
Note: InfluxDB isn't required, there is a config option that will allow you to disable it.
- Assemble the AirGradient device - Instructions here
- Install Arduino - Download here
- Download this repository - Click the green “Code” button and then “Download ZIP”
- Unzip the folder, navigate to the AirQualityMonitor and copy the example config file. Paste it into the same directory and rename it
DeviceConfig
Add ESP8266 platform information.
- Open the Arduino sketch file. Then open the Preferences menu, and add
http://arduino.esp8266.com/stable/package_esp8266com_index.json
to Additional Board Manager URLs Image - Open the Board Manager and search for and install:
esp8266
byESP8266 community
Image - Load the board preferences by navigating to Tool -> Board: -> ESP8266 Boards, then select
LOLIN(WEMOS) D1 R2 & mini
Image
Add the required libraries.
- Open library manager, search for and install:
AirGradient Air Quality Sensor
Image
If only using sensors, with no connectivity skip to step two
- Search for and install:
ESP8266 and ESP32 OLED driver for SSD1306 displays
by ThingPulse Image
Only needed if you enable Influxdb
- Search for and install:
ESP8266 Influxdb
by Tobias Schürg, InfluxData Image
Only needed if you enable MQTT
- Search for and install:
home-assistant-integration
by Dawid Chyrzynski Image You will be asked if you would like to install dependencies, select Install all Image
Navigate to DeviceConfig.hpp tab and enable any features you would like to use. Then fill out their corresponding credentials.
Once customization is complete, plug the device (esp8266) into your computer then click upload. Optionally, if you want to monitor what the device is doing, you can open Serial Monitor
- Removed captive portal. Wi-Fi credentials are now defined in the config file
- Data can now be sent to influxDB
- Added the ability to display Fahrenheit on display, celsius is still reported to the database
- Added a calibration offset for temperature, the calibration value is subtracted from the reading
- Added the ability to update the database and display independently
- Added the ability to control the timings of all features independently
- Added MQTT, with Home Assistant Auto-Discovery
- Added ability to easily enable/disable Wi-Fi, MQTT and influxDB