Particle count detection using Sharp GP2Y1010AU0F
Particle count detection using Sharp GP2Y1010AU0F
Components Needed:
Connections:
Note: The NodeMCU’s analog pin can only read up to 3.3V, while the sensor’s output can
reach 5V, hence the voltage divider.
2. Code for NodeMCU ESP8266
The code uses the Telegram bot API to send dust concentration readings to a mobile phone.
Libraries Needed:
Codes ;
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <ESP8266HTTPClient.h>
// WiFi credentials
// Hardware definitions
#define LED_PIN D2
#define ANALOG_PIN A0
void setup() {
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
// Connect to WiFi
Serial.print("Connecting to WiFi...");
WiFi.begin(ssid, password);
delay(500);
Serial.print(".");
Serial.println("Connected!");
void loop() {
delayMicroseconds(280);
delayMicroseconds(40);
Serial.print(dustConcentration);
Serial.println(" mg/m³");
sendTelegramMessage(dustConcentration);
delay(10000); // Wait for 10 seconds before the next reading
if (WiFi.status() == WL_CONNECTED) {
WiFiClientSecure client;
HTTPClient https;
https.begin(client, url);
if (httpCode > 0) {
} else {
https.end();
} else {
}
3. Setting Up Telegram Bot
Explanation
The NodeMCU controls the LED of the GP2Y1010AU0F, taking a reading after a
280µs delay to measure dust particles accurately.
The voltage reading is converted to dust concentration (approximated in mg/m³).
Every 10 seconds, a message is sent to a predefined Telegram chat containing the dust
concentration reading.