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 » TDS Sensor & Arduino Interfacing for Water Quality Monitoring
Arduino Projects

TDS Sensor & Arduino Interfacing for Water Quality Monitoring

Mamtaz AlamBy Mamtaz AlamUpdated:August 21, 20229 Comments7 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
TDS Sensor Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

In this tutorial, we will learn how to interface Gravity Analog TDS Sensor with Arduino and design a simple TDS Meter.


Overview

TDS (Total Dissolved Solids) indicates how many milligrams of soluble solids are dissolved in one liter of water. In general, the higher the TDS value, the more soluble solids are dissolved in water, and the less clean the water is. Therefore, the TDS value can be used as one reference point for reflecting the cleanliness of the water. This can be applied to domestic water, hydroponic and other fields of water quality testing and monitoring.

So, in this project, we will interface Gravity Analog TDS Sensor with Arduino Microcontroller and read the value in 16×2 LCD Display. Since TDS Value depends upon the temperature. So will also add DS18B20 Waterproof Temperature Sensor to measure Water Temperature. The measured temperature is used with TDS Sensor to compensate for the reading with high calibration and high accuracy. The code, circuit diagram, and all other procedure is given below.

In order to know more about water quality, you can add Ph Sensor, Turbidity Sensor & DO Sensor to this circuit as well.


Bill of Materials

Following are the components required for making this project. All the components can be easily purchased from Amazon. The components purchased link is given.

S.N.Components QuantityPurchase Links
1Arduino UNO Board1Amazon | AliExpress
2TDS Sensor1Amazon | AliExpress
3DS18B20 Temperature Sensor1Amazon | AliExpress
416x2 LCD Display1Amazon | AliExpress
5Potentiometer 10K1Amazon | AliExpress
6Resistor 4.7K1Amazon | AliExpress
7Connecting Wires10Amazon | AliExpress
8Breadboard1Amazon | AliExpress



What is “TDS”?

TDS is an abbreviation for Total Dissolved Solids in a liquid, including organic and inorganic substances in a molecular, ionic, or micro-granular suspended form. TDS is generally expressed in parts per million (ppm) or as milligrams per liter (mg/L). TDS is directly related to the quality of water i.e., the lower a TDS figure, the purer the water. As an example, reverse osmosis purified water will have a TDS between 0 and 10, whereas tap water will vary between 20 and 300, depending on where you live in the world.

The materials that constitute dissolved solids in water include materials such as minerals, salts, anionic and cationic substances. They can also include pollutants such as heavy metals, and other substances such as organic materials that may have leaked into your water supply system.

What is a TDS meter and how does it work?

A TDS meter is basically an electrical charge (EC) meter whereby two electrodes equally spaced apart are inserted into water and used to measure charge. The result is interpreted by the TDS meter and converted into a ppm figure.

TDS Sensor Working

If the water contains no soluble materials and is pure, it will not conduct a charge and will, therefore, have a 0 ppm figure. Conversely, if the water is full of dissolved materials, it will conduct a charge, with the resulting ppm figure being proportional to the number of dissolved solids. This is because all dissolved solids have an electrical charge, which allows conduction of electrical charge between the electrodes.

What can a TDS meter be used for?

As well as measuring the TDS of our drinking water supplies, a TDS meter can be used for measuring:
1. Fish tanks and aquariums

Fish require a specific TDS and pH similar to the natural environment in which they live. Freshwater fish require less than 400ppm, with some other freshwater fish requiring less. Saltwater fish require TDS readings of between 5000 and 50000ppm.

2. Hydroponics

A TDS meter is a useful aid for quickly measuring the nutrient concentration of a hydroponic solution.

3. Pools and spas

A low TDS reading can help prevent maintenance issues, skin irritation, and algal blooms.

4. Colloidal silver

There are many consumers of colloidal silver today using a TDS meter to measure their colloidal silver concentration in parts per million (ppm). The TDS meter gives a relatively accurate measurement.




Gravity Analog TDS Sensor

Gravity Analog TDS Sensor is an Arduino-compatible TDS sensor/Meter Kit for measuring TDS value of the water. It can be applied to domestic water, hydroponic and other fields of water quality testing. This product supports 3.3 ~ 5.5V wide voltage input, and 0 ~ 2.3V analog voltage output, which makes it compatible with 5V or 3.3V control systems or boards.

TDS Sensor

The excitation source is an AC signal, which can effectively prevent the probe from polarization and prolong the life of the probe, meanwhile, it can help increase the stability of the output signal. The TDS probe is waterproof, it can be immersed in water for long time measurement.

Specification

1. Input Voltage: 3.3 ~ 5.5V
2. Output Voltage: 0 ~ 2.3V
3. Working Current: 3 ~ 6mA
4. TDS Measurement Range: 0 ~ 1000ppm
5. TDS Measurement Accuracy: ± 10% FS (25 ℃)
6. TDS probe with Number of Needle: 2

Attention & Things to Remember

The probe can not to be used in water above 55 degrees centigrade.
The probe can not be too close to the edge of the container, otherwise, it will affect the reading.
The head and the cable of the probe are waterproof, but the connector and the signal transmitter board are not waterproof.


Interfacing Gravity Analog TDS Sensor with Arduino

Now let us learn how to interface TDS Sensor with Arduino. The circuit diagram is given below.

Interfacing Gravity Analog TDS Sensor with Arduino

The connection of TDS Sensor with Arduino is fairly simple. Connect the VCC to Arduino 5V & GND to GND. Connect its Analog pin to any analog pin of Arduino. In my case, I used Analog pin A1 of Arduino.


Source Code/Program

Here is a simple code for Interfacing TDS Sensor with Arduino. You need a library for it.

Download Gravity TDS Sensor Library



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
#include <EEPROM.h>
#include "GravityTDS.h"
 
#define TdsSensorPin A1
GravityTDS gravityTds;
 
float temperature = 25,tdsValue = 0;
 
void setup()
{
    Serial.begin(115200);
    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()
{
    //temperature = readTemperature();  //add your temperature sensor and read it
    gravityTds.setTemperature(temperature);  // set the temperature and execute temperature compensation
    gravityTds.update();  //sample and calculate
    tdsValue = gravityTds.getTdsValue();  // then get the value
    Serial.print(tdsValue,0);
    Serial.println("ppm");
    delay(1000);
}

Once the code is uploaded, you can simply put the TDS probe in water and check the reading in Serial Monitor.


Interfacing Gravity Analog TDS Sensor with Arduino & LCD Display

Now let us add an extra LCD Display & interface TDS Sensor with Arduino. We will display the TDS Value in LCD Display. The circuit diagram is given below.

TDS Sensor LCD Display Arduino


Source Code/Program with LCD Display

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
#include <EEPROM.h>
#include "GravityTDS.h"
#include <LiquidCrystal.h>
 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 
#define TdsSensorPin A1
GravityTDS gravityTds;
 
float temperature = 25,tdsValue = 0;
 
void setup()
{
    Serial.begin(115200);
    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()
{
    //temperature = readTemperature();  //add your temperature sensor and read it
    gravityTds.setTemperature(temperature);  // set the temperature and execute temperature compensation
    gravityTds.update();  //sample and calculate
    tdsValue = gravityTds.getTdsValue();  // then get the value
    Serial.print(tdsValue,0);
    Serial.println("ppm");
    lcd.setCursor(0, 0);
    lcd.print("TDS Value:");
    lcd.setCursor(0, 1);
    lcd.print(tdsValue,0);
    lcd.print(" PPM");
    delay(1000);
    lcd.clear();
}

Once the code is uploaded you can now measure the TDS of water and display in 16×2 LCD Display.



Temperature Compensated TDS Sensor with Arduino

The above two codes are valid only if the temperature of the water is 25 degrees Celcius. If there is an increase or decrease in temperature the reading will be false as Conductivity changes as per temperature.

So, in order to fix this issue we need to include the temperature coefficient in the code. This sensor doesn’t have any temperature sensor. So we need to add an external temperature sensor. The DS18B20 Waterproof Temperature Sensor is a suitable option for that because of the easy interface and high accuracy. Hence the new circuit diagram becomes something like the below.

TDS Sensor DS18B20 Temperature Arduino

Connect the output pin of DS18B20 Waterproof Temperature sensor to any digital pin. In my case, I used Digital Pin 7 of Arduino. Pull the Output pin via 4.7K resistor to 5V Supply as shown in the image above.



Source Code/Program with Temperature Compensation

Here is the source code for TDS Sensor with temperature compensation. We need two extra library for this code as DS18B20 requires one wire and Dallas library. So download it from below and add it to the libray folder.

Download OneWire Library

Download Dallas Library

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
#include <EEPROM.h>
#include "GravityTDS.h"
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 
#define ONE_WIRE_BUS 7
#define TdsSensorPin A1
 
OneWire oneWire(ONE_WIRE_BUS);
GravityTDS gravityTds;
 
DallasTemperature sensors(&oneWire);
 
float tdsValue = 0;
 
void setup()
{
    Serial.begin(115200);
    lcd.begin(16,2);
    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));  // set the temperature and execute temperature compensation
    gravityTds.update();  //sample and calculate
    tdsValue = gravityTds.getTdsValue();  // then get the value
    
    Serial.print(tdsValue,0);
    Serial.println("ppm");
    Serial.print("Temperature is: ");
    Serial.print(sensors.getTempCByIndex(0));
    
    lcd.setCursor(0, 0);
    lcd.print("TDS: ");
    lcd.print(tdsValue,0);
    lcd.print(" PPM");
 
    lcd.setCursor(0, 1);
    lcd.print("Temp: ");
    lcd.print(sensors.getTempCByIndex(0));
    lcd.print(" C");
    
    delay(1500);
    lcd.clear();
}

Now once the code is uploaded you can read the precise and correct value of TDS in PPM along with Temperature.

This is the reading when both the sensor are placed in air.

When some soluble ion solute like salt is added the conductivity of solution increases and hence we can get the value of TDS higher. In the image below I have added 2 spoon of salt and stired it. The value of TDS increased immediately.


Video Tutorial

TDS Meter using TDS & Temperature Sensor with Arduino || Measure Water Quality in PPM
Watch this video on YouTube.

If you want to monitor the Water Quality Parameters like TDS, EC & Temperature, you can follow the projects here: IoT Based TDS Meter using ESP8266.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleSend SIM800/900 GSM/GPRS Data to Thingspeak with STM32
Next Article Wifi & Voice Controlled Home Automation Using NodeMCU & Android

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
View 9 Comments

9 Comments

  1. Paul on May 7, 2020 5:44 AM

    Ec read not corrected ….how to

    Reply
  2. Zakir Shah on October 13, 2020 9:14 AM

    Can I read sensor value in my Android app instead of lcd display ?

    Reply
  3. Angela on November 29, 2020 7:22 PM

    the library you share in link is invalid

    Reply
  4. Miles on September 23, 2021 9:22 PM

    Hello, I want to learn about Microcontroller programming and all. Kindly put me through

    Reply
  5. aulio on December 6, 2022 12:40 AM

    hi, can the sensor read salinity for seawater?

    Reply
  6. Robert on December 26, 2022 5:37 AM

    Thanks for your teaching, tried to download gravity TDS in Arduino Ide.no such file.where can I get it

    Reply
  7. Hemma on July 29, 2023 10:50 AM

    Why a temperature sensor is needed also why a 4.7k resistor is needed to pull out the output

    Reply
    • Admin on July 29, 2023 11:19 AM

      TDS Value changes with temperature. You need temperature sensor to detect the temperature changes and to do a temperature compensation in order to measure correct TDS value. And 4.7K resistor is required by DS18B20 temperature sensor for pull-up resistance or a parasitic power.

      Reply
  8. Manohar K on February 24, 2026 8:00 AM

    Is potentiometer is must

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 16, 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
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use ADS1115 16-Bit ADC Module with Arduino
    How to use ADS1115 16-Bit ADC Module with Arduino
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • Interfacing PN532 NFC RFID Module with Arduino
    Interfacing PN532 NFC RFID Module with Arduino
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
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.