Temperatur-, Feuchte- und Druckstation

BME280 mit OLED, lokaler Webseite und JSON-API. Saubere Basis für jede Klimaüberwachung.

Level: Einsteiger Board: ESP32 DevKit V1 (WROOM-32) Klima

⚠ Sicherheit

Nur USB-Versorgung; nichts hier berührt das Netz.

Das brauchst du

Teile-Set kaufen · Geschätzte Summe: €10.12

ESP32 DevKit V1 (30 pin, WROOM-32) × 1
€3.68
Kaufen bei AliExpress Kaufen bei Amazon.de
BME280 I2C module (3.3V) × 1
€2.76
Kaufen bei AliExpress Kaufen bei Amazon.de
OLED 0.96" 128x64 I2C SSD1306 × 1
€2.30
Kaufen bei AliExpress Kaufen bei Amazon.de
Dupont jumper wires (M-F, M-M) × 1
€1.38
Kaufen bei AliExpress Kaufen bei Amazon.de
🇺🇦 Ukraine🌍 Andere Länder

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.

Verdrahtung

ModulModul-PinESP32-PinHinweis
BME280 SDA / SCLI2CGPIO21 / GPIO22address 0x76 or 0x77
OLED SDA / SCLI2CGPIO21 / GPIO22address 0x3C
VCC / GND3V3 / GND

Bibliotheken

Arduino IDE → Werkzeuge → Bibliotheken verwalten, dann installieren:

  • Adafruit BME280
  • Adafruit SSD1306
  • Adafruit GFX

Code

temp-humidity-station.ino
#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 <Wire.h>
#include <Adafruit_BME280.h>
#include <Adafruit_SSD1306.h>
Adafruit_BME280 bme;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
float t = NAN, h = NAN, p = NAN;
#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();
}
String buildJson() { return String("{\"temp\":") + num(t) + ",\"hum\":" + num(h, 0) + ",\"hPa\":" + num(p, 0) + "}"; }
void setup() {
  Serial.begin(115200);
  Wire.begin(21, 22);
  if (!bme.begin(0x76) && !bme.begin(0x77)) Serial.println("BME280 not found");
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  connectWiFi();
  startWeb();
}
void loop() {
  server.handleClient();
  static uint32_t tm = 0;
  if (millis() - tm > 2000) {
    tm = millis(); t = bme.readTemperature(); h = bme.readHumidity(); p = bme.readPressure() / 100.0;
    oled.clearDisplay(); oled.setTextColor(WHITE); oled.setTextSize(2);
    oled.setCursor(0, 0);  oled.print(t, 1); oled.print(" C");
    oled.setCursor(0, 24); oled.print(h, 0); oled.print(" %");
    oled.setCursor(0, 48); oled.print(p, 0); oled.print(" hPa");
    oled.display();
  }
}

Fertige Firmware im Browser flashen Fehler in den KI-Doktor einfügen

Bautipps

  • BME280 vom ESP32-Chip fernhalten: Eigenerwärmung addiert 1–3 °C.
  • Adresse 0x76 oder 0x77 je nach Modul.

← ← Alle Projekte

Ähnliche Ideen

CO2-Monitor

MH-Z19B-CO2-Messgerät mit OLED und Lüftungswarnung, praktisch für Schlafzimmer und Büros.

  • Board ESP32 DevKit V1 (WROOM-32)
  • Level ●●○ Fortgeschritten
  • Bauzeit 1–2 Std.
Teile / Set auswählen

Feinstaub-Monitor PM2.5

PMS5003-Partikelsensor plus BME280: PM1 / PM2.5 / PM10, Temperatur und Feuchte auf einer Webseite.

  • Board ESP32 DevKit V1 (WROOM-32)
  • Level ●●○ Fortgeschritten
  • Bauzeit 1–2 Std.
Teile / Set auswählen

Kommentare

Noch keine Kommentare. Teilen Sie Ihre Erfahrung oder stellen Sie eine Frage.

Kommentare werden moderiert.