Temperatur- und Feuchte-Station
BME280 plus OLED: Temperatur, Luftfeuchte und Druck auf dem Display, einer Webseite und in Home Assistant.
Liest PM1.0 / PM2.5 / PM10 und bewertet die Luftqualität. Nützlich in Rauch- und Staubzeiten.
Level: Fortgeschritten Board: ESP32 DevKit V1 (WROOM-32) Klima
Der PMS5003-Lüfter braucht 5 V; die Datenpins haben 3,3-V-Logik.
Teile-Set kaufen · Geschätzte Summe: €18.86
Andere Länder: Bestellen Sie diese Teile über die Links unten bei AliExpress.
Einige Links sind Affiliate-Links: Wir erhalten ggf. eine Provision, für dich entstehen keine Mehrkosten.
| Modul | Modul-Pin | ESP32-Pin | Hinweis |
|---|---|---|---|
| PMS5003 VCC / GND | 5V / GND | ||
| PMS5003 TX | UART | GPIO16 (RX2) | |
| PMS5003 RX | UART | GPIO17 (TX2) | optional |
#include <WiFi.h>
const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASS = "YOUR_PASSWORD";
bool connectWiFi(uint32_t timeoutMs = 20000) {
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS);
uint32_t t0 = millis();
while (WiFi.status() != WL_CONNECTED && millis() - t0 < timeoutMs) {
delay(250);
Serial.print(".");
}
Serial.println();
if (WiFi.status() == WL_CONNECTED) {
Serial.print("IP: ");
Serial.println(WiFi.localIP());
return true;
}
return false;
}
#include <WebServer.h>
WebServer server(80);
String buildJson(); // implemented in the project below
String num(float v, int d = 1) { return isnan(v) ? String("null") : String(v, d); }
const char PAGE_HTML[] PROGMEM = R"rawliteral(
<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>ESP32</title>
<style>body{font-family:system-ui;background:#0b0f14;color:#e6edf3;margin:20px}table{border-collapse:collapse}td{padding:6px 14px;border-bottom:1px solid #223}button,input{font-size:16px;padding:8px 14px;margin:4px;border-radius:6px;border:1px solid #345;background:#16202b;color:#e6edf3}</style>
</head><body><h2>ESP32</h2><table id="t"></table>
<script>
function load(){fetch('/json').then(r=>r.json()).then(d=>{let h='';for(const k in d){h+='<tr><td>'+k+'</td><td>'+d[k]+'</td></tr>';}document.getElementById('t').innerHTML=h;});}
load();setInterval(load,2000);
</script></body></html>
)rawliteral";
void startWeb() {
server.on("/", []() { server.send_P(200, "text/html", PAGE_HTML); });
server.on("/json", []() { server.send(200, "application/json", buildJson()); });
server.begin();
}
int pm1 = -1, pm25 = -1, pm10 = -1;
bool readPMS() {
static uint8_t b[32]; int n = 0; uint32_t t0 = millis();
while (millis() - t0 < 2000) {
if (!Serial2.available()) continue;
uint8_t c = Serial2.read();
if (n == 0 && c != 0x42) continue;
if (n == 1 && c != 0x4D) { n = 0; continue; }
b[n++] = c;
if (n == 32) {
uint16_t sum = 0; for (int i = 0; i < 30; i++) sum += b[i];
if (sum != (uint16_t)(b[30] << 8 | b[31])) return false;
pm1 = b[10] << 8 | b[11]; pm25 = b[12] << 8 | b[13]; pm10 = b[14] << 8 | b[15];
return true;
}
}
return false;
}
String buildJson() { return String("{\"PM1\":") + pm1 + ",\"PM2_5\":" + pm25 + ",\"PM10\":" + pm10 + "}"; }
void setup() {
Serial.begin(115200);
Serial2.begin(9600, SERIAL_8N1, 16, 17);
connectWiFi();
startWeb();
}
void loop() {
server.handleClient();
static uint32_t t = 0;
if (millis() - t > 3000) { t = millis(); readPMS(); }
}Fertige Firmware im Browser flashen Fehler in den KI-Doktor einfügen
BME280 plus OLED: Temperatur, Luftfeuchte und Druck auf dem Display, einer Webseite und in Home Assistant.
Zwei Fühler oben und unten im Schrank mit Router, Switch und NAS und ein Alarm, bevor die Geräte im Sommer überhitzen.
MH-Z19B-CO2-Messgerät mit OLED und Lüftungswarnung, praktisch für Schlafzimmer und Büros.
Kommentare
Noch keine Kommentare. Teilen Sie Ihre Erfahrung oder stellen Sie eine Frage.