💧 Smart Water Management System (Serial Bluetooth Terminal)
This version will:
-
Show water level in mobile app
-
Work in AUTO + MANUAL mode
-
Allow motor ON/OFF from phone
-
Send warning when tank FULL
-
Protect motor from dry run
No WiFi required ✅
No internet required ✅
📦 Components Used
-
ESP32
-
Water Level Sensor (Analog)
-
Single Channel Relay
-
DC Water Pump
-
Android phone with Serial Bluetooth Terminal app
Recommended App:
👉 Serial Bluetooth Terminal by Kai Morich
🔌 Connections
1️⃣ Water Level Sensor
| Sensor | ESP32 |
|---|---|
| VCC | 3.3V |
| GND | GND |
| AO | GPIO 34 |
2️⃣ Relay Module
| Relay | ESP32 |
|---|---|
| VCC | 5V |
| GND | GND |
| IN | GPIO 26 |
⚠ Relay is Active LOW
LOW → Motor ON
HIGH → Motor OFF
💻 COMPLETE BLUETOOTH CODE (AUTO + MANUAL)
Copy & paste into Arduino IDE:
#include <BluetoothSerial.h>
BluetoothSerial SerialBT;
#define WATER_SENSOR 34
#define RELAY_PIN 26
int waterValue = 0;
bool autoMode = true;
bool motorState = false;
int lowLevel = 1000;
int fullLevel = 3000;
void setup() {
Serial.begin(115200);
SerialBT.begin("Smart_Water_System");
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, HIGH); // Motor OFF
Serial.println("Bluetooth Water Management Started");
}
void loop() {
waterValue = analogRead(WATER_SENSOR);
// Send water value to Bluetooth app
SerialBT.print("Water Level: ");
SerialBT.println(waterValue);
// Check Bluetooth Commands
if (SerialBT.available()) {
String command = SerialBT.readStringUntil('\n');
command.trim();
if (command.equalsIgnoreCase("AUTO")) {
autoMode = true;
SerialBT.println("Switched to AUTO Mode");
}
else if (command.equalsIgnoreCase("MANUAL")) {
autoMode = false;
SerialBT.println("Switched to MANUAL Mode");
}
else if (command.equalsIgnoreCase("ON") && !autoMode) {
turnMotorOn();
}
else if (command.equalsIgnoreCase("OFF") && !autoMode) {
turnMotorOff();
}
else {
SerialBT.println("Invalid Command!");
}
}
// AUTO MODE LOGIC
if (autoMode) {
if (waterValue < lowLevel && !motorState) {
SerialBT.println("Water LOW -> Motor ON");
turnMotorOn();
}
if (waterValue > fullLevel && motorState) {
SerialBT.println("Tank FULL -> Motor OFF");
turnMotorOff();
SerialBT.println("WARNING: Tank Full!");
}
}
delay(2000);
}
void turnMotorOn() {
digitalWrite(RELAY_PIN, LOW);
motorState = true;
SerialBT.println("Motor is ON");
}
void turnMotorOff() {
digitalWrite(RELAY_PIN, HIGH);
motorState = false;
SerialBT.println("Motor is OFF");
}
🧠 CODE EXPLANATION (Clear Understanding)
1️⃣ Enable Bluetooth
SerialBT.begin(“Smart_Water_System”);
This creates Bluetooth device named:
👉 Smart_Water_System
Mobile will detect this name.
2️⃣ Read Water Sensor
Reads analog value (0–4095).
3️⃣ Send Data to Mobile
SerialBT.println(waterValue);
App shows real-time water level.
4️⃣ Mode Control Logic
AUTO → Sensor controls motor
MANUAL → User controls motor
5️⃣ Bluetooth Commands
| Command | Function |
|---|---|
| AUTO | Enable auto mode |
| MANUAL | Enable manual mode |
| ON | Motor ON (Manual only) |
| OFF | Motor OFF (Manual only) |
6️⃣ Auto Mode Logic
If water LOW → Motor ON
If FULL → Motor OFF + Warning
7️⃣ Relay Logic
Relay Active LOW
LOW = Motor ON
📱 How To Use Mobile App
-
Upload code
-
Turn ON Bluetooth
-
Open Serial Bluetooth Terminal
-
Connect to:
Smart_Water_System -
Type commands:
MANUAL
ON
OFF
📟 Example Output in App
Water LOW -> Motor ON
Motor is ON
Water Level: 3200
Tank FULL -> Motor OFF
Motor is OFF
WARNING: Tank Full!
🎯 What Students Learn
-
Bluetooth communication
-
Analog sensor reading
-
Relay motor control
-
Auto + Manual logic
-
Wireless embedded control
-
Real-world automation
🚀 Next Professional Upgrade
Shiv 👑 You can now upgrade to:
-
📊 Water level percentage calculation
-
📱 Custom Android app
-
🌐 WiFi Dashboard version
-
☁ Blynk IoT version
-
📈 Graph plotting
-
🔔 Buzzer alert