An application to read data from a Plantower PMS5003 air quality sensor, written for use with MicroPython on an ESP32 microcontroller. It has a webserver to return the data in JSON format, and /html
can be hit to return a pretty(ish) HTML version.
The sensor data extraction code is based on Adafruit's old Python code from before they turned it into a library.
It requires a file called config.json
at the root of the src
directory, configured with your wifi network name and password, the RX pin that the PMS5003 sensor is connected to, and an API key that protects the POST
and DELETE
endpoints described below. An example file is given in config.example.json.
esp32-air-quality-reader has five HTTP endpoints:
GET /
— Get the current air quality values in JSON format.GET /html
— Get the current air quality values in HTML format.GET /log
— View the log file that's written to when errors occur.DELETE /log
— Clear the log file; this requires theX-API-Key
header to be set with the same value as what you're sending to the endpoint.POST /reset
— Restarts the ESP32; as above, it requires theX-API-Key
header to be set.