Total dissolved solids (TDS) are measured in milligrams per unit volume of water (mg / l) or also referred to as parts per million (ppm). For drinking water, the maximum concentration level established by the EPA (the United States Environmental Protection Agency) is 500 mg / L. So TDS value is used as a reference in knowing the quality of water for drinking, Aquaponics, hydroponics and where the quality of water matters.
So taking this into consideration we are going to build an IOT TDS monitoring device with the help of Arduino with Gravity Analog TDS sensor which is designed for Arduino with simple plug and play use. As TDS is dependent on temperature we use a waterproof temperature sensor bundled with the TDS sensor probe.
Table of Contents
What is TDS?
TDS stands for “Total Dissolved Solids.” It is a measure of the combined content of all inorganic and organic substances present in a liquid in molecular, ionized, or micro-granular suspended form. TDS is commonly used to assess the quality of water, particularly in contexts such as drinking water, wastewater treatment, aquarium maintenance, and industrial processes.
To determine TDS, water is passed through a filter to remove suspended solids, and then the remaining dissolved solids are measured. These dissolved solids can include minerals, salts, metals, ions, and organic compounds. Common constituents of TDS in water include calcium, magnesium, sodium, potassium, chloride, sulfate, bicarbonate, and various trace minerals.
How does a tds reader work?
Total dissolved solids at a technical level are measured in a laboratory but if we are interested in measuring it ourselves, the best option is to use an electronic TDS Meter.
The TDS reader works by measuring Electronic conductivity(EC) of water and calculating it and bringing TDS value. This is measured in PPM (Parts Per Million).
Pure H2O water or distilled water does not conduct electricity, so if a TDS reader is immersed in fully distilled water the result will be “0” or a very low number in the event that there are trace minerals in the Water. It is the charge of electrons that make up the minerals that conducts electricity. In short, a water with more minerals conducts more electricity than a water without minerals.
Making of Arduino TDS Meter
Product Requirements:
- Arduino UNO R3
- Gravity analog TDS sensor
- DS18B20 One-Wire Waterproof Temperature Sensor
- JHD162A 16X2 LCD Display ( to dislay the data on mini LCD screen)
- 10k Potentiometer
- 4.7k Resistor
- ESP8266 (ESP-01 or any compatible) (If you need the data over network on blynk).
Software Requirements:
- Arduino IDE
- GravityTDS.h Library
- OneWire.h
- DallasTemperature.h
- ESP8266WiFi
New Product specs:
Gravity Analog TDS sensor:
This sensor is specially designed to be compatible with arduino for measuring water for drinking, aquaponics and more. it operates between input voltages 3.3v to 5v. So it can be uses with multiple compatible MCU’s available, like Arduino, ESP32, Nodemcu, and more. It outputs an analog voltage from 0 to 2.3v.
As the DC signal can add polarization errors to the value and corrode the probe pins used, this sensor uses an AC signal because of no polarity to get better accuracy and for long term usage of the waterproof TDS Probe. The probe has 2 metallic pins through which the electrical conductivity is calculated.
Technical Specs:
- Input DC – 3.3 to 5v
- Output AC – 0 to 2.3v
- Current – 3 to 6 mA
- TDS Measurement Range: 0 ~ 1000ppm
- TDS Measurement Accuracy: ± 10% F.S. (25 ℃)
- Module Interface: PH2.0-3P
- Electrode probe has 2 metal pins.
- Electrode Interface: XH2.54-2P
Note or warnings:
This electrode probe should be placed in the middle of water placing it near the edges gives wrong values, this probe doesn’t work at temperatures above 55 degree Celsius.
Here we are going to make this project in 3 methods:
- Interfacing with only Arduino and 2 Sensors to watch the readings in Serial monitor.
- Interfacing with Arduino and 2 sensors with LCD display to watch the readings on 16×2 LCD Display.
- Interfacing wirh Arduino and 2 sensors with ESP8266 to watch the readings over wifi with blynk on mobile.
Method1: Results on Serial Monitor
In this method we will interface an Arduino Uno R3 with Gravity TDS sensor and Temperature sensor and monitor the TDS and temperature values on Serial monitor of PC or laptop.
Circuit Diagram:

This is a very simple circuit among the other two just connect the electrode probe with the sensor chip on one side where the other side has 3 pins where one goes to 5v power, second goes to GND, and third goes to Analog pin on arduino A1. And we connect the temperature sensor to digital pin D7 with the help of a 4.7k ohm resistor.
Working:
Upload the below code and connect the components as shown above. then put the TDS and Temperature sensors inside the water glass whose TDS value is to be checked. Then open the serial monitor, and you can see the TDS and temperature values. If you don’t want to use temperature sensor you can add the standard temperature value inside code. So, the TDS value is calculated according to the given temperature.
Code:
#include <EEPROM.h> #include "GravityTDS.h" #include <OneWire.h> #include <DallasTemperature.h> #define ONE_WIRE_BUS 7 // Digitalpin where Temp sensor is connected #define TdsSensorPin A1 // Where Analog pin of TDS sensor is connected to arduino OneWire oneWire(ONE_WIRE_BUS); GravityTDS gravityTds; DallasTemperature sensors(&oneWire); float tdsValue = 0; void setup() { Serial.begin(115200); sensors.begin(); gravityTds.setPin(TdsSensorPin); gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V on Arduino UNO gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC gravityTds.begin(); //initialization } void loop() { sensors.requestTemperatures(); gravityTds.setTemperature(sensors.getTempCByIndex(0)); // grab the temperature from sensor and execute temperature compensation gravityTds.update(); //calculation done here from gravity library tdsValue = gravityTds.getTdsValue(); // then get the TDS value Serial.print("TDS value is:"); Serial.print(tdsValue,0); Serial.println("ppm"); Serial.print("Temperature is: "); Serial.print(sensors.getTempCByIndex(0)); delay(1500); }
This is the advanced code where the temperature compensation calculations are not to be written in the code as all those complex tasks like calibrating the device with electric conductivity (EC) are already written inside the GravityTDS library.
So the output in the serial monitor looks as below:
Always remember to follow the advice’s provided above to get nearly accurate readings. refer above warnings.
Method 2: Values on LCD Display connected to Arduino
In this method we are just going to add the JHD162A 16X2 LCD Display to the arduino so that the value which where displayed in serial monitor in the previous method are displayed on the LCD Display. So you can make use of the device even with out the PC or laptop.
Working:
Same as the method 1 but Arduino sends the output data to the LCD display. To adjust the contrast of the LCD display you can add a potentiometer of 10k.
Circuit Diagram with LCD Display
If you face any issue like no display or black display shown in LCD adjust the potentiometer contrast till the text is visible.
To simplify connections refer: Connect LCD display to Arduino with only two pins I2C adapter
Code:
#include <EEPROM.h> #include "GravityTDS.h" #include <OneWire.h> #include <DallasTemperature.h> #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); #define ONE_WIRE_BUS 7 // Digitalpin where Temp sensor is connected #define TdsSensorPin A1 // Where Analog pin of TDS sensor is connected to arduino OneWire oneWire(ONE_WIRE_BUS); GravityTDS gravityTds; DallasTemperature sensors(&oneWire); float tdsValue = 0; void setup() { Serial.begin(115200); sensors.begin(); lcd.begin(16,2); gravityTds.setPin(TdsSensorPin); gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V on Arduino UNO gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC gravityTds.begin(); //initialization } void loop() { sensors.requestTemperatures(); gravityTds.setTemperature(sensors.getTempCByIndex(0)); // grab the temperature from sensor and execute temperature compensation gravityTds.update(); //calculation done here from gravity library tdsValue = gravityTds.getTdsValue(); // then get the TDS value Serial.print("TDS value is:"); Serial.print(tdsValue,0); Serial.println("ppm"); Serial.print("Temperature is: "); Serial.print(sensors.getTempCByIndex(0)); lcd.setCursor(0, 0); lcd.print("TDS TEMP"); lcd.setCursor(0, 1); lcd.print(tdsValue,0); lcd.print(" PPM"); lcd.setCursor(6, 1); lcd.print(sensors.getTempCByIndex(0)); delay(1500); }
This code essentially reads temperature data from a DS18B20 sensor and TDS data from a Gravity TDS sensor, displaying both values on an LCD screen and sending them to the serial monitor for debugging. The TDS value is compensated based on the temperature reading for more accurate results.
Method 3: Interfacing TDS meter with ESP8266 to get results online with blynk
If you want to implement this TDS meter inside any water purifier or any water flow and monitor the values on your mobile real-time wirelessly this method suit you. In this we are going to add the WiFi functionality to the previous method to send the data to blynk server and fetch the data to your mobile.
Here in this method we are using Node MCU as the main board and connecting the Gravity TDS meter and Temperature sensor to it. As NodeMCU has the Inbuilt WiFi ESP8266 we can use this to ease our project where connecting a WiFi module ESP-01 to Arduino is a very hard and tricky task.
Connect the Node MCU to our sensors as shown in the following schematic diagram.
Circuit diagram:
Connect the above circuit and upload the code into Node MCU.
Before that install all the libraries required
OneWire.h ESP8266WiFi.h BlynkSimpleEsp8266.h DallasTemperature.h EEPROM.h GravityTDS.h
Then upload the below code to the node mcu
Code:
#include <Arduino.h> #include <EEPROM.h> #include "GravityTDS.h" #include <OneWire.h> #include <DallasTemperature.h> #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> #include <SimpleTimer.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "YourAuthToken"; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "YourNetworkName"; char pass[] = "YourPassword"; SimpleTimer timer; #define ONE_WIRE_BUS 7 // Digitalpin where Temp sensor is connected #define TdsSensorPin A0 // Where Analog pin of TDS sensor is connected to A0 of nodemcu OneWire oneWire(ONE_WIRE_BUS); GravityTDS gravityTds; DallasTemperature sensors(&oneWire); float tdsValue = 0; void setup() { Serial.begin(115200); Blynk.begin(auth, ssid, pass); sensors.begin(); gravityTds.setPin(TdsSensorPin); gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V from NodeMCU gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC gravityTds.begin(); //initialization timer.setInterval(1000L,MainFunction); } void loop() { Blynk.run(); timer.run(); // Initiates BlynkTimer } void MainFunction() { sensors.requestTemperatures(); gravityTds.setTemperature(sensors.getTempCByIndex(0)); // grab the temperature from sensor and execute temperature compensation gravityTds.update(); //calculation done here from gravity library tdsValue = gravityTds.getTdsValue(); // then get the TDS value Serial.print("TDS value is:"); Serial.print(tdsValue,0); Serial.println("ppm"); Serial.print("Temperature is: "); Serial.print(sensors.getTempCByIndex(0)); // Sensor Values to Blynk application temperature = sensors.getTempCByIndex(0); Blynk.virtualWrite(V2, temperature); Blynk.virtualWrite(V3, tdsValue); }
We’re here to help! If you have any questions, concerns, or run into any issues while working on this project, please feel free to drop us a comment below. Our friendly community is always ready to assist, and we’ll do our best to guide you through any challenges you might face.
And if you found this project interesting, useful, or just plain fun, why not share it with your friends? Sharing knowledge and cool projects not only benefits your buddies but also spreads the joy of learning and creativity to a wider audience. Your support means a lot to us, and it keeps us motivated to keep bringing you great content.