Know when the water is back before you stand at the tap
In many buildings water is supplied on a schedule, and the pressure on upper floors falls long before it disappears. A pressure sensor on the inlet turns that into data: you receive "water gone" and "water is back", with times, and after a few weeks you see the pattern.
Build and use it
A 0.5 to 4.5 V transducer with a G1/4 thread fits a tee on the inlet. Reduce its output with a 10 k and 20 k divider for the ADC and add a small capacitor. Seal the thread with PTFE tape and check for leaks under pressure before you leave it.
Treat pressure below about 0.3 bar as no water, and use a delay to ignore short dips.
When the pressure starts to fall, the message can remind you to fill the bath and the kettles.
The ESP32-C3 sleeps most of the time but the sensor needs 5 V, so a small mains adapter is a better source than a cell.
Components
ESP32-C3 SuperMini
Water pressure transducer 0.5-4.5 V (G1/4, 0-1.2 MPa)
Resistor kit 1/4W (1k, 2k, 4.7k, 10k, 22k, 100k)
USB charger 5V 2A
Wiring
Module
Module pin
ESP32 pin
Note
Pressure sensor + / GND
5V / GND
0.5-4.5 V output type
Pressure sensor OUT via 10k/20k divider
analog
GPIO3 (ADC1)
4.5 V becomes 3.0 V
Code
#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;
}
const int PIN_P = 3;
const float BAR_FULL = 6.0; // 0-0.6 MPa transducer; use 12.0 for 1.2 MPa
const float LOW_BAR = 0.3;
const uint32_t CONFIRM_MS = 60000;
bool waterOff = false; uint32_t changeMs = 0, offSince = 0;
float readBar() {
long s = 0; for (int i = 0; i < 32; i++) { s += analogRead(PIN_P); delay(2); }
float vSensor = (s / 32.0) * 3.3 / 4095.0 * 1.5;
return max(0.0f, (vSensor - 0.5f) / 4.0f * BAR_FULL);
}
void setup() { Serial.begin(115200); analogReadResolution(12); connectWiFi(); }
void loop() {
if (WiFi.status() != WL_CONNECTED) connectWiFi(8000);
bool low = readBar() < LOW_BAR;
if (low != waterOff) {
if (changeMs == 0) changeMs = millis();
if (millis() - changeMs > CONFIRM_MS) {
waterOff = low; changeMs = 0;
if (waterOff) { offSince = millis(); telegramSend("Water supply is OFF"); }
else telegramSend(String("Water is back after ") + (millis() - offSince) / 60000 + " min");
}
} else changeMs = 0;
delay(2000);
}
Build tips
Install the sensor on a tee after the shutoff valve and use a transducer rated for your pressure.
Set CONFIRM_MS higher if pressure dips briefly during normal use.
Other countries: order these parts on AliExpress with the links below.
Some links are affiliate links: we may earn a commission at no extra cost to you.
Related ideas
⛔ High risk
Mains 220–230 V can kill. Work with the power off, use certified isolated modules in an enclosure, fuse the line, and ask a qualified electrician if you are not sure.
Comments
No comments yet. Share your experience or ask a question.