Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » IoT Based TDS Meter using ESP8266 for Water Quality Monitoring
ESP8266 Projects IoT Projects

IoT Based TDS Meter using ESP8266 for Water Quality Monitoring

Mamtaz AlamBy Mamtaz AlamUpdated:May 29, 20234 Comments4 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
IoT Based TDS Meter using ESP8266
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview: IoT Based TDS Meter using ESP8266

In this project, we will learn how to make our own IoT Based TDS Meter using NodeMCU ESP8266 & TDS Sensor for Water Quality Monitoring. The TDS value (Total Dissolved Solids) gives the sum of dissolved solids in water. These solids include for instance salts, minerals, and conductive metals ions. The value is additionally called the conductivity of the water. Because the more such solids or ions are within the water, the higher it conducts electricity. TDS meters typically quantify this conductivity in micro siemens or ppm. The latter stands for parts per million, i.e. the number of solid particles per a million water mixture particles. The value of 40 ppm means from a million particles there are 40 dissolved ions and therefore the rest (= 999 960) are water molecules.

The TDS Sensor can not only measure the Liquid TDS but also the EC (Electrical Conductivity). An electrical conductivity meter (EC meter) measures the electrical conductivity in a solution. It has multiple applications in research and engineering, with common usage in hydroponics, aquaculture, aquaponics, pisciculture, and freshwater systems to monitor the number of nutrients, salts, or impurities in the water.

To make our own IoT based TDS Meter, we will need a TDS Sensor as well as Temperature Sensor which should be Waterproof. For sending the measured TDS, EC & Temperature data, we need an IoT platform. The best free IoT platform is Blynk. The ESP8266 based TDS Meter connects to wifi and continuously sends the data to the Blynk application. Thus you can get a 24×7 report related to your water quality. Thus TDS sensor is the best sensor for Water Quality Monitoring. Apart from all this, you can also add a Ph Sensor and a Turbidity Sensor to learn more about the Water Quality.


Bill of Materials

We need the following components to make an IoT Based TDS Meter. The ESP8266 & TDS Sensor is required along with the Temperature Sensor. All the componets can be purchased online from Amazon. The components purchase link is given below.

S.N.Components QuantityPurchase Links
1Nodemcu ESP8266 Board1Amazon | AliExpress
2TDS Sensor1Amazon | AliExpress
3DS18B20 Sensor1Amazon | AliExpress
4Resistor 4.7K1Amazon | AliExpress
5Connecting Jumper Wires10Amazon | AliExpress
6Breadboard1Amazon | AliExpress




TDS Meter Circuit Diagram & Connections

The connection diagram between NodeMCU ESP8266 & TDS Sensor is given below. The anlog pin of TDS Sensor is connected to A0 of NodeMCU. The VCC pin is connected to 3.3V & GND to GND.

TDS Sensor ESP8266

We already discussed the basics of TDS Sensor and Arduino Interfacing in our previous tutorials. You can follow the basic guide here: Arduino TDS Meter.

The use of the DS18B0 Temperature Sensor is for calibration purposes. This is because the TDS value varies as per change in Temperature, so there is a need for temperature compensation as per the change in liquid temperature. This is done by DS18B20, Waterproof Temperature Sensor.

IoT Based TDS Meter


Blynk Application Setup

The IoT Water Quality Monitoring Project is incomplete without the Blynk Application. Blynk is designed for the Internet of Things. It can control hardware remotely, it can display sensor data, it can store data, visualize it, and do many other cool things.

Download and install the Blynk Application from Google Play Store. IOS users can download from the App Store. Once the installation is completed, open the app & sign-up using your Email id and Password.

Create your UI by dragging dropping and filling up details along with the virtual pin assignment. Once the UI is created, you can ask for the authentication Token by sending the mail. You will need the Authentication Token for the code.




Source Code/Program

The source code or program for IoT Based TDS Meter using TDS Sensor & ESP8266 is given below. You can upload this code to the NodeMCU Board. Before compiling the sketch, you need to add following library to the Arduino IDE.

Download: Blynk Library

From the code part, change the wifi SSID, Password & Blynk Authentication Code.

1
2
3
char auth[] = "******************************";    
char ssid[] = "******************************";                
char pass[] = "******************************";

The complete code is given below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <Blynk.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
 
char auth[] = "fqMvEno5LtFrd_UcIpyyc6U03ehbgeQU";       // You should get Auth Token in the Blynk App.
char ssid[] = "Alexahome";                       // Your WiFi credentials.
char pass[] = "loranthus";
 
int DSPIN = D5; // Dallas Temperature Sensor
namespace pin
{
const byte tds_sensor = A0;   // TDS Sensor
}
namespace device
{
float aref = 3.3;
}
namespace sensor
{
float ec = 0;
unsigned int tds = 0;
float ecCalibration = 1;
}
void setup()
{
  Serial.begin(115200); // Dubugging on hardware Serial 0
  Blynk.begin(auth, ssid, pass);
}
void loop()
{
  Blynk.run();
  double waterTemp = TempRead();
  waterTemp  = waterTemp*0.0625; // conversion accuracy is 0.0625 / LSB
  
  float rawEc = analogRead(pin::tds_sensor) * device::aref / 1024.0; // read the analog value more stable by the median filtering algorithm, and convert to voltage value
  float temperatureCoefficient = 1.0 + 0.02 * (waterTemp - 25.0); // temperature compensation formula: fFinalResult(25^C) = fFinalResult(current)/(1.0+0.02*(fTP-25.0));
  
  sensor::ec = (rawEc / temperatureCoefficient) * sensor::ecCalibration; // temperature and calibration compensation
  sensor::tds = (133.42 * pow(sensor::ec, 3) - 255.86 * sensor::ec * sensor::ec + 857.39 * sensor::ec) * 0.5; //convert voltage value to tds value
  
  Serial.print(F("TDS:")); Serial.println(sensor::tds);
  Serial.print(F("EC:")); Serial.println(sensor::ec, 2);
  Serial.print(F("Temperature:")); Serial.println(waterTemp,2);  
  Serial.print(F(""));
 
  Blynk.virtualWrite(V1, sensor::tds);
  Blynk.virtualWrite(V2, sensor::ec);
  Blynk.virtualWrite(V3, waterTemp);
  delay(1000);
}
 
boolean DS18B20_Init()
{
  pinMode(DSPIN, OUTPUT);
  digitalWrite(DSPIN, HIGH);
  delayMicroseconds(5);
  digitalWrite(DSPIN, LOW);
  delayMicroseconds(750);//480-960
  digitalWrite(DSPIN, HIGH);
  pinMode(DSPIN, INPUT);
  int t = 0;
  while(digitalRead(DSPIN))
  {
    t++;
    if(t > 60) return false;
    delayMicroseconds(1);
  }
  t = 480 - t;
  pinMode(DSPIN, OUTPUT);
  delayMicroseconds(t);
  digitalWrite(DSPIN, HIGH);
  return true;
}
void DS18B20_Write(byte data)
{
  pinMode(DSPIN, OUTPUT);
  for(int i=0; i<8; i++)
  {
    digitalWrite(DSPIN, LOW);
    delayMicroseconds(10);
    if(data & 1) digitalWrite(DSPIN, HIGH);
    else digitalWrite(DSPIN, LOW);
    data >>= 1;
    delayMicroseconds(50);
    digitalWrite(DSPIN, HIGH);
  }
}
byte DS18B20_Read()
{
  pinMode(DSPIN, OUTPUT);
  digitalWrite(DSPIN, HIGH);
  delayMicroseconds(2);
  byte data = 0;
  for(int i=0; i<8; i++)
  {
    digitalWrite(DSPIN, LOW);
    delayMicroseconds(1);
    digitalWrite(DSPIN, HIGH);
    pinMode(DSPIN, INPUT);
    delayMicroseconds(5);
    data >>= 1;
    if(digitalRead(DSPIN)) data |= 0x80;
    delayMicroseconds(55);
    pinMode(DSPIN, OUTPUT);
    digitalWrite(DSPIN, HIGH);
  }
  return data;
}
int TempRead()
{
  if(!DS18B20_Init()) return 0;
   DS18B20_Write (0xCC); // Send skip ROM command
   DS18B20_Write (0x44); // Send reading start conversion command
  if(!DS18B20_Init()) return 0;
   DS18B20_Write (0xCC); // Send skip ROM command
   DS18B20_Write (0xBE); // Read the register, a total of nine bytes, the first two bytes are the conversion value
   int waterTemp = DS18B20_Read (); // Low byte
   waterTemp |= DS18B20_Read () << 8; // High byte
  return waterTemp;
}


IoT Based TDS Meter using ESP8266 for Water Quality Monitoring

After the code is uploaded, the Nodemcu tries connecting to network. Once, it is connected to wifi network, it will start pushing the data to Blynk Server.

You can take different samples of water and check the water TDS Value, EC Value, and also the temperature. Adding salts or any ionic solute can rapidly raise the TDS value.

Iot Water Quality Monitoring ESP8266


The data can be monitored on the Blynk Application Dashboard.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleLight (Lux) Meter using BH1750 Ambient Light Sensor & Arduino
Next Article IoT ESP8266 Lux Meter using BH1750 Light Sensor & Blynk

Related Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

Updated:June 14, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

Updated:June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20261K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
View 4 Comments

4 Comments

  1. Terry on January 7, 2021 11:20 PM

    What board did you pick and its settings?
    I used the generic 8266 as its the only one that worked.
    Though the temp sensor doesn’t. I also have to change the pin from “D5” to “5” and the sketch works for
    EC and TDS but not Temp……..

    Reply
  2. Anwar on November 3, 2021 9:06 AM

    me to, have same problem

    Reply
  3. Aina Safiqa on November 19, 2021 12:53 PM

    hi, i need to do exactly like this project but seems like the tds value does not come out 🙁 can you help

    Reply
  4. Hamzah on October 15, 2024 10:11 PM

    can u make a tutorial videos?

    Reply

CommentsCancel reply

Latest Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 14, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • How to use LDR Sensor Module with Arduino
    How to use LDR Sensor Module with Arduino
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • Silicon Controlled Rectifier (SCR): Construction, Working & Applications
    Silicon Controlled Rectifier (SCR): Construction, Working & Applications
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.