AirSense was conceived to bridge the gap between complex environmental telemetry and actionable user-facing interfaces. By combining low-power hardware, high-frequency cloud pipelines, and a native mobile application, we created a comprehensive real-time air quality monitoring system.
At the edge of the platform is an ESP32 microcontroller, chosen for its built-in WiFi connectivity and low power states. The hardware layer integrates a suite of high-precision sensors:
Edge Sensors (MQ-135, DHT22)
└── ESP32 Microcontroller (Telemetry Aggregation)
└── WiFi (HTTPS POST / JSON)
└── Firebase Realtime Database
The ESP32 runs a non-blocking execution loop. Every 30 seconds, it samples all analog and digital channels, performs moving average filtering to reduce electrical noise, and pushes the payload to Firebase.
Here is the core C++ loop executing the telemetry transmission:
void sendTelemetry(float temp, float humidity, float pm25, float gasPpm) {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
String url = String(FIREBASE_HOST) + "/telemetry.json?auth=" + FIREBASE_AUTH;
http.begin(url);
http.addHeader("Content-Type", "application/json");
String jsonPayload = "{\"temp\":" + String(temp) +
",\"humidity\":" + String(humidity) +
",\"pm25\":" + String(pm25) +
",\"gasPpm\":" + String(gasPpm) +
",\"timestamp\":{\".sv\":\"timestamp\"}}";
int httpResponseCode = http.POST(jsonPayload);
http.end();
}
}
The native mobile app is built using Kotlin and follows the MVVM (Model-View-ViewModel) architectural pattern. It implements a reactive subscription to the Firebase Database using Coroutines and StateFlow.
We used MPAndroidChart to display real-time and historical graphs. It features:
The AirSense platform proved to be highly reliable, running continuously with a 99.8% database uptime. Edge-side data compression reduced payload sizes, significantly cutting down cellular bandwidth requirements in remote deployments.