Air quality monitoring using ESP8266 and PMS5003 sensor
This project measures particulate matter (PM1.0, PM2.5, PM10) using a PMS5003 sensor connected to an ESP8266.
Data is averaged and sent to ThingSpeak for logging and visualization.
- Board: ESP8266 (NodeMCU or Wemos D1 Mini)
- Sensor: PMS5003 (Particulate Matter Sensor)
- Power supply: 5V (USB or external)
- WiFi: Required for sending data to ThingSpeak
The code is written for the Arduino IDE and uses the following libraries:
ESP8266WiFi.hโ for Wi-Fi connectivityThingSpeak.hโ to send data to ThingSpeakPMS.hโ for reading data from PMS5003 sensor
- Open the project in the Arduino IDE
- Select your ESP8266 board (e.g., NodeMCU 1.0)
- Install dependencies via Library Manager
- Enter your Wi-Fi SSID, password, and ThingSpeak API keys in the code
- Upload the sketch (disconnect PMS5003 during upload)
- Open Serial Monitor to debug and view readings
- The sensor wakes up and stabilizes for 3 minutes
- 10 readings are collected for PM1.0, PM2.5, and PM10
- Averages are calculated
- Data is sent to ThingSpeak using
writeRaw() - The ESP8266 goes to deep sleep for ~24 minutes
Make sure you:
- Create a ThingSpeak channel with three fields (PM1.0, PM2.5, PM10)
- Copy your channel number and write API key into the sketch
Example of data string sent:
api_key=XXXX&field1=12.5&field2=18.3&field3=21.7
The ESP8266 uses ESP.deepSleep() for low-power operation.
This makes the system suitable for battery-powered deployments.
If you find it useful, give it a โญ !
Feel free to fork it or open issues for feedback and suggestions.
