Level: Profi Board: ESP32 DevKit V1 (WROOM-32) Wasser & Garten
⚠ Sicherheit Netzspannung kann tödlich sein. Zertifizierte isolierte Module im Gehäuse, Sicherung und FI-Schutzschalter im Stromkreis, vor der Verdrahtung spannungsfrei schalten, im Zweifel eine Elektrofachkraft fragen. Landesvorschriften beachten.
Das brauchst du Teile-Set kaufen · Geschätzte Summe: €25.76
ESP32 DevKit V1 (30 pin, WROOM-32) × 1
€3.68
Water pressure transducer 0.5-4.5 V (G1/4, 0-1.2 MPa) × 1
€5.52
Relay module 1-channel 5V (opto-isolated) × 1
€1.38
DIN contactor 25A with 230V coil × 1
€11.04
Inline fuse holder + fuses × 1
€1.38
Plastic project enclosure × 1
€2.76
Einige Links sind Affiliate-Links: Wir erhalten ggf. eine Provision, für dich entstehen keine Mehrkosten.
Code pump-protect.ino Kopieren .ino herunterladen
#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 <WiFiClientSecure.h>
#include <HTTPClient.h>
const char* TG_TOKEN = "123456:ABC-YOUR-BOT-TOKEN"; // from @BotFather
const char* TG_CHAT = "YOUR_CHAT_ID";
// Keep the text free of double quotes and line breaks (it is inserted into JSON).
bool telegramSend(const String& text) {
if (WiFi.status() != WL_CONNECTED) return false;
WiFiClientSecure client;
client.setInsecure(); // simple; pin the certificate for production
HTTPClient http;
String url = String("https://api.telegram.org/bot") + TG_TOKEN + "/sendMessage";
if (!http.begin(client, url)) return false;
http.addHeader("Content-Type", "application/json");
String body = String("{\"chat_id\":\"") + TG_CHAT + "\",\"text\":\"" + text + "\"}";
int code = http.POST(body);
http.end();
return code == 200;
}
#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();
}
const int PIN_P = 34, PIN_RELAY = 26;
const float BAR_FULL = 12.0; // 1.2 MPa transducer = 12 bar at 4.5 V
const float P_ON = 2.0, P_OFF = 3.5; // switch-on / switch-off pressure, bar
const float MIN_RISE = 0.3; // required pressure rise within CHECK_MS
const uint32_t CHECK_MS = 20000, MAX_RUN_MS = 600000;
bool pumpOn = false, lockout = false; float bar = 0, barAtStart = 0; uint32_t startMs = 0;
float readBar() {
long s = 0; for (int i = 0; i < 32; i++) { s += analogRead(PIN_P); delay(2); }
float vAdc = (s / 32.0) * 3.3 / 4095.0, vSensor = vAdc * 1.5; // divider 10k/20k
return max(0.0f, (vSensor - 0.5f) / 4.0f * BAR_FULL);
}
void setPump(bool on) { pumpOn = on; digitalWrite(PIN_RELAY, on ? HIGH : LOW); if (on) { startMs = millis(); barAtStart = bar; } }
String buildJson() { return String("{\"bar\":") + num(bar, 2) + ",\"pump\":" + (pumpOn ? 1 : 0) + ",\"lockout\":" + (lockout ? 1 : 0) + "}"; }
void setup() {
Serial.begin(115200); pinMode(PIN_RELAY, OUTPUT); analogReadResolution(12);
connectWiFi(); startWeb();
server.on("/reset", []() { lockout = false; server.send(200, "text/plain", "lockout cleared"); });
}
void loop() {
server.handleClient(); bar = readBar();
if (!lockout) {
if (!pumpOn && bar < P_ON) setPump(true);
if (pumpOn && bar > P_OFF) setPump(false);
if (pumpOn && millis() - startMs > CHECK_MS && bar - barAtStart < MIN_RISE) { setPump(false); lockout = true; telegramSend("Pump stopped: dry run or burst pipe suspected"); }
if (pumpOn && millis() - startMs > MAX_RUN_MS) { setPump(false); lockout = true; telegramSend("Pump stopped: maximum run time exceeded"); }
}
delay(200);
}Fertige Firmware im Browser flashen Fehler in den KI-Doktor einfügen
Bautipps Parallel einen mechanischen Druckschalter oder ein Überdruckventil als zweite Schutzlinie einbauen. Die Druckskala gegen ein mechanisches Manometer kalibrieren. ← ← Alle Projekte
Ähnliche Ideen ⛔ Hohes Risiko 230 V Netzspannung kann tödlich sein. Arbeiten Sie spannungsfrei, nutzen Sie zertifizierte isolierte Module im Gehäuse, sichern Sie die Leitung ab und fragen Sie im Zweifel eine Elektrofachkraft.
Temperatur- und Rauchsensor im Gehäuse mit Alarm, Nachricht und optionaler Stromabschaltung des Druckers.
⛔ Hohes Risiko 230 V Netzspannung kann tödlich sein. Arbeiten Sie spannungsfrei, nutzen Sie zertifizierte isolierte Module im Gehäuse, sichern Sie die Leitung ab und fragen Sie im Zweifel eine Elektrofachkraft.
Überwacht den Strom von Wechselrichter / Akku und schaltet per Relais unwichtige Verbraucher ab, wenn der Akku leer wird.
⛔ Hohes Risiko 230 V Netzspannung kann tödlich sein. Arbeiten Sie spannungsfrei, nutzen Sie zertifizierte isolierte Module im Gehäuse, sichern Sie die Leitung ab und fragen Sie im Zweifel eine Elektrofachkraft.
Startet und stoppt einen Generator per Relais, zählt Betriebsstunden, überwacht die Last mit einer Stromzange und warnt vor Kohlenmonoxid.
Kommentare
Noch keine Kommentare. Teilen Sie Ihre Erfahrung oder stellen Sie eine Frage.