Course Content
IoT Engineering Course using ESP32 with 12 Real-World Projects

💧 Water Quality Monitoring System

(ESP32 + Analog TDS Sensor + Bluetooth)

In this lesson, we upgrade the Serial Monitor version to Bluetooth control and monitoring.

This version allows:

  • 📱 Real-time TDS value on mobile

  • 📊 Water quality classification

  • 🔄 Wireless communication

  • 📡 No WiFi required

Internet ❌
Router ❌
Bluetooth ✔


📦 Components Used

  • ESP32

  • Analog TDS Sensor Module

  • TDS Probe

  • Android Phone

  • Serial Bluetooth Terminal App

Recommended App:
👉 Serial Bluetooth Terminal (Android)


🔌 Pin Configuration

TDS Module Pin ESP32
VCC 3.3V
GND GND
AO GPIO 34

GPIO 34 = Analog Input Pin


💻 COMPLETE CODE

(Bluetooth + TDS Monitoring)

Copy & paste into Arduino IDE:

#include <BluetoothSerial.h>

BluetoothSerial SerialBT;

#define TDS_PIN 34

float voltage = 0;
float tdsValue = 0;

void setup() {
Serial.begin(115200);
SerialBT.begin("Water_Quality_BT");

SerialBT.println("=== Water Quality Monitoring ===");
}

void loop() {

int adcValue = analogRead(TDS_PIN);

voltage = adcValue * (3.3 / 4095.0);

tdsValue = (133.42 * voltage * voltage * voltage
- 255.86 * voltage * voltage
+ 857.39 * voltage) * 0.5;

SerialBT.print("TDS Value: ");
SerialBT.print(tdsValue);
SerialBT.print(" ppm");

// Water Quality Classification
if (tdsValue < 50) {
SerialBT.println(" | Very Pure Water");
}
else if (tdsValue < 150) {
SerialBT.println(" | Excellent Water");
}
else if (tdsValue < 300) {
SerialBT.println(" | Good Water");
}
else if (tdsValue < 500) {
SerialBT.println(" | Fair Water");
}
else {
SerialBT.println(" | Poor / Unsafe Water");
}

delay(2000);
}

🧠 Code Explanation


1️⃣ Enable Bluetooth

 
 
#include <BluetoothSerial.h>
BluetoothSerial SerialBT;
SerialBT.begin(“Water_Quality_BT”);
 

Creates Bluetooth device named:

 
 
Water_Quality_BT
 

Your phone will detect this name.


2️⃣ Read Analog Value

 
 
int adcValue = analogRead(TDS_PIN);
 

Reads analog signal from TDS module.

Range:
0 – 4095


3️⃣ Convert ADC to Voltage

 
 
voltage = adcValue * (3.3 / 4095.0);
 

Converts ADC value to voltage.


4️⃣ Convert Voltage to TDS

 
 
tdsValue = (133.42 * V³ – 255.86 * V² + 857.39 * V) * 0.5;
 

Polynomial formula converts voltage to PPM.


5️⃣ Water Quality Classification

Based on TDS value:

TDS (ppm) Quality
< 50 Very Pure
50–150 Excellent
150–300 Good
300–500 Fair
> 500 Poor

The app shows both TDS value and quality.


📱 How To Use Bluetooth App

Step 1
Upload code

Step 2
Turn ON Bluetooth

Step 3
Open Serial Bluetooth Terminal

Step 4
Connect to:

 
 
Water_Quality_BT
 

Step 5
View live TDS value on screen


📟 Example Output in Mobile App

 
 
TDS Value: 120 ppm | Excellent Water
TDS Value: 340 ppm | Fair Water
TDS Value: 620 ppm | Poor / Unsafe Water
 

🎯 What Students Learn

  • Bluetooth communication

  • Analog sensor reading

  • Voltage to PPM conversion

  • Water quality classification

  • Wireless environmental monitoring


📌 Lesson Summary

In this lesson, students built a:

💧 Bluetooth-Based Water Quality Monitoring System

The system:

✔ Reads TDS sensor
✔ Converts voltage to PPM
✔ Classifies water quality
✔ Sends data wirelessly to mobile

Scroll to Top