AirSense, the purifier created by user NEXTBUILDERIO, uses a Waveshare ESP32-S3 to display environmental readings and enable remote monitoring. The project combines sensors, a display, Arduino IoT Cloud, and a web dashboard; air filtration is handled by a Xiaomi Air Purifier 4 Lite.
Hackaday.io lists the components and publishes a wiring diagram and 33 instructions for assembly. This tutorial builds a testable foundation: a web server on the ESP32-S3 with demo values. These are not real measurements, and the example does not control the purifier.
In this project, we’ll use only the ESP32-S3 and a Wi-Fi network. The dashboard will show PM2.5, AQI, temperature, humidity, and pressure, but with fixed test values.
The example’s workflow is simple: the browser requests a page from the ESP32, and the page queries a JSON endpoint. The test data comes from the program itself, not from a sensor.
flowchart LR
A["Browser"] -- "GET /" --> B["ESP32-S3"]
A -- "GET /api" --> B
B -- "Test JSON" --> A1. Connect the ESP32-S3 to Wi-Fi
Install the ESP32 board package in Arduino IDE and select the board that matches your module. This first sketch uses the WiFi and Serial APIs from the Arduino core for ESP32. Replace the example credentials with your network’s credentials before uploading it.
#include <WiFi.h>
const char* ssid = "TU_RED_WIFI";
const char* password = "TU_CONTRASENA";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.print("Conectando");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Direccion IP: ");
Serial.println(WiFi.localIP());
}
void loop() {
delay(1000);
}
Open the serial monitor at 115200 baud and wait for an IP address to appear. If it doesn’t connect, check the network name and password, and confirm that you selected a compatible ESP32-S3 board in the IDE.
2. Publish a JSON endpoint
The next sketch maintains the connection and adds an HTTP server. When you visit the /api route, the microcontroller responds with a JSON object. The values are constants so you can verify the format without connecting sensors.
#include <WiFi.h>
#include <WebServer.h>
const char* ssid = "TU_RED_WIFI";
const char* password = "TU_CONTRASENA";
WebServer server(80);
void handleApi() {
String json = "{\"pm25\":12,\"aqi\":35,";
json += "\"temperatura\":22.5,\"humedad\":45,";
json += "\"presion\":1013}";
server.send(200, "application/json", json);
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
server.on("/api", HTTP_GET, handleApi);
server.begin();
Serial.println(WiFi.localIP());
}
void loop() {
server.handleClient();
}
With the ESP32 and computer on the same network, open http://DIRECCION_IP/api. The response should contain five fields. These are fictitious data: don’t interpret them as air-quality measurements taken by the device.
3. Add a page to view the values
Now the ESP32 will also serve a page at the root route. The browser queries /api every two seconds and updates the text. This complete sketch replaces the previous one: it retains the endpoint and adds the interface.
#include <WiFi.h>
#include <WebServer.h>
const char* ssid = "TU_RED_WIFI";
const char* password = "TU_CONTRASENA";
WebServer server(80);
const char page[] PROGMEM = R"HTML(
<!doctype html>
<html lang="es">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>AirSense de prueba</title>
<h1>Monitor ambiental</h1>
<pre id="datos">Consultando...</pre>
<p>Lecturas simuladas para pruebas.</p>
<script>
async function actualizar() {
const respuesta = await fetch('/api');
const datos = await respuesta.json();
document.getElementById('datos').textContent =
`PM2.5: ${datos.pm25} | AQI: ${datos.aqi}\n` +
`Temperatura: ${datos.temperatura} °C\n` +
`Humedad: ${datos.humedad} %\n` +
`Presión: ${datos.presion} hPa`;
}
actualizar();
setInterval(actualizar, 2000);
</script>
</html>
)HTML";
void handleRoot() {
server.send(200, "text/html; charset=utf-8", page);
}
void handleApi() {
String json = "{\"pm25\":12,\"aqi\":35,";
json += "\"temperatura\":22.5,\"humedad\":45,";
json += "\"presion\":1013}";
server.send(200, "application/json", json);
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
server.on("/", HTTP_GET, handleRoot);
server.on("/api", HTTP_GET, handleApi);
server.begin();
Serial.println(WiFi.localIP());
}
void loop() {
server.handleClient();
} Open the IP address printed in the serial monitor. The page displays the JSON fields and refreshes them periodically. If you see strange characters, check that the JSON response wasn’t malformed while editing it.
4. Separate the test readings
In a real integration, it’s a good idea to isolate data retrieval in a function. That way, you can replace the simulated source with sensor readings without changing the HTTP route or the dashboard. The complete example keeps the same demo values.
#include <WiFi.h>
#include <WebServer.h>
const char* ssid = "TU_RED_WIFI";
const char* password = "TU_CONTRASENA";
WebServer server(80);
struct Lecturas {
int pm25;
int aqi;
float temperatura;
int humedad;
int presion;
};
Lecturas leerDatosDePrueba() {
return {12, 35, 22.5, 45, 1013};
}
String crearJson(const Lecturas& d) {
String json = "{\"pm25\":" + String(d.pm25);
json += ",\"aqi\":" + String(d.aqi);
json += ",\"temperatura\":" + String(d.temperatura, 1);
json += ",\"humedad\":" + String(d.humedad);
json += ",\"presion\":" + String(d.presion) + "}";
return json;
}
void handleApi() {
Lecturas datos = leerDatosDePrueba();
server.send(200, "application/json", crearJson(datos));
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
server.on("/api", HTTP_GET, handleApi);
server.begin();
Serial.println(WiFi.localIP());
}
void loop() {
server.handleClient();
}
This final version provides a clear replacement point: leerDatosDePrueba(). To read the BME680 and AirSense dust sensor, you would need to complete this function with their actual libraries, wiring, and initialization; it isn’t safe to infer those details from the component list alone.
Common issues and limitations of the example
A page that won’t load usually points to an incorrect IP address, the device and browser being on different networks, or the server not having finished starting up. If /api responds but the dashboard doesn’t update, check the browser console and the JSON format.
Don’t mistake this prototype for the complete AirSense: it has no sensor data acquisition, LCD, Arduino IoT Cloud, remote device control, or connection to the filter. The original project uses these elements, but this implementation only demonstrates the local server and a simple dashboard.
Hackaday.io also describes a case designed in Autodesk Fusion 360, a cylindrical filter, and a 150 mm exhaust fan. XDA notes that the creator permits personal, educational, and non-commercial use and requires a commercial license for products intended for sale.
The result of this project is an ESP32-S3 accessible from a browser and an interface that makes it clear when the data is for testing. Before treating the dashboard as an environmental monitor, the next step is to replace the demo function with verified readings from the specific sensors.
Sources: XDA, Hackaday.io, Urgent News, daily.dev