Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Notes: For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.
TDS Sensor Arduino: Complete Water Quality Measurement Guide
Monitoring water quality used to require expensive lab equipment and specialized training. Today, a TDS sensor Arduino setup costing under $15 can measure dissolved solids in your aquarium, hydroponics system, or drinking water with reasonable accuracy.
I’ve deployed TDS monitoring systems in aquaculture facilities and home brewing setups over the past few years. This guide covers the practical knowledge you need to get reliable readings from these sensors, including the temperature compensation and calibration steps that most tutorials skip.
What Is TDS and Why Measure It?
TDS stands for Total Dissolved Solids. It represents the combined concentration of all inorganic and organic substances dissolved in water, including minerals, salts, metals, and ions. TDS is measured in parts per million (ppm) or milligrams per liter (mg/L), which are equivalent units.
When you measure TDS, you’re essentially measuring how “pure” the water is. Pure distilled water has near-zero TDS. Tap water typically ranges from 200-400 ppm. Seawater exceeds 30,000 ppm.
TDS Levels and Water Quality Classifications
TDS Level (ppm)
Classification
Typical Sources
0-50
Very low
Distilled water, RO filtered
50-150
Ideal drinking
Quality filtered water
150-300
Acceptable
Most tap water
300-500
Fair
Hard tap water
500-1000
Poor
Well water, some municipal
>1000
Unsafe
Brackish, contaminated
The EPA sets a secondary standard of 500 ppm as the maximum recommended TDS for drinking water. This isn’t a health-based limit but rather an aesthetic guideline, as high TDS water often tastes metallic or salty.
Common Applications for TDS Monitoring
Water quality monitoring with a TDS sensor Arduino system serves numerous practical purposes:
Aquarium and fish tank maintenance requires stable TDS levels. Most freshwater fish thrive between 100-300 ppm, while marine setups need much higher values.
Hydroponics systems depend on precise nutrient concentrations. Growers use TDS to ensure plants receive optimal mineral levels without over-fertilization.
Reverse osmosis filter performance monitoring shows when membranes need replacement. A functioning RO system should reduce TDS by 90-99%.
Drinking water quality assessment provides peace of mind about tap water or well water safety.
How TDS Sensors Work
TDS sensors don’t directly measure dissolved solids. Instead, they measure electrical conductivity (EC) and convert it to a TDS estimate.
Pure water conducts electricity poorly. As minerals and salts dissolve, they dissociate into ions that carry electrical charge. More dissolved solids means higher conductivity.
The sensor applies a small voltage across two electrodes immersed in the water. By measuring the resulting current, the sensor determines conductivity. An algorithm then converts conductivity to TDS using this relationship:
TDS (ppm) = EC (µS/cm) × 0.5
This conversion factor assumes typical mixed mineral content. Different water sources may require adjusted factors (0.5 to 0.7 range).
Why Temperature Matters
Conductivity changes significantly with temperature. Warmer water conducts electricity better because ions move faster. A 1°C temperature increase causes roughly 2% conductivity increase.
Without temperature compensation, a TDS reading at 35°C could be 20% higher than the same water at 25°C. Quality TDS systems include temperature sensors or manual temperature input to correct for this effect.
Gravity Analog TDS Sensor Specifications
The DFRobot Gravity TDS Sensor is the most common module for Arduino projects. Understanding its specifications helps you work within its limitations.
Parameter
Specification
Input Voltage
3.3V to 5.5V
Output Voltage
0V to 2.3V (analog)
Working Current
3-6 mA
TDS Range
0-1000 ppm
Accuracy
±10% full scale (at 25°C)
Probe Type
2-electrode, waterproof
Maximum Water Temperature
55°C
Signal Type
AC excitation
The AC excitation is crucial for long-term reliability. DC signals cause electrolysis and electrode polarization, rapidly degrading the probe. AC signals reverse polarity continuously, preventing this buildup.
TDS Sensor Module Pinout
Pin
Function
Arduino Connection
+ (VCC)
Power supply
5V or 3.3V
– (GND)
Ground
GND
A (Signal)
Analog output
Any analog pin (A0-A5)
The sensor module includes an interface board that handles signal conditioning. The probe connects to the interface board via a proprietary connector.
TDS Sensor Arduino Wiring Diagram
Connecting the TDS sensor to Arduino requires only three wires for basic operation.
Basic Connections
TDS Module Pin
Arduino Uno Pin
VCC (+)
5V
GND (-)
GND
Signal (A)
A0
For accurate readings, add a DS18B20 temperature sensor:
With Temperature Compensation
Component
Arduino Pin
TDS Signal
A0
DS18B20 Data
D7
DS18B20 VCC
5V
DS18B20 GND
GND
4.7kΩ Pullup
Between Data and VCC
Position the temperature sensor probe close to the TDS probe so both measure the same water temperature.
Basic TDS Sensor Arduino Code
This sketch reads the TDS sensor and displays values on the Serial Monitor:
#define TdsSensorPin A0
#define VREF 5.0 // Arduino ADC reference voltage
#define SCOUNT 30 // Number of samples for filtering
int analogBuffer[SCOUNT];
int analogBufferIndex = 0;
float averageVoltage = 0;
float tdsValue = 0;
float temperature = 25.0; // Default temperature for compensation
void setup() {
Serial.begin(115200);
pinMode(TdsSensorPin, INPUT);
}
void loop() {
static unsigned long analogSampleTimepoint = millis();
Install the OneWire and DallasTemperature libraries through the Arduino Library Manager before compiling.
Calibrating Your TDS Sensor
Factory calibration provides reasonable accuracy for most applications. However, for precise measurements, calibrate against a known standard solution.
Calibration Requirements
You need either a standard calibration solution (1413 µS/cm or 707 ppm) or a calibrated TDS pen meter for reference.
Calibration Procedure
Using the DFRobot GravityTDS library simplifies calibration:
#include <EEPROM.h>
#include “GravityTDS.h”
#define TdsSensorPin A1
GravityTDS gravityTds;
float temperature = 25.0;
float tdsValue = 0;
void setup() {
Serial.begin(115200);
gravityTds.setPin(TdsSensorPin);
gravityTds.setAref(5.0);
gravityTds.setAdcRange(1024);
gravityTds.begin();
Serial.println(“Calibration Commands:”);
Serial.println(“enter – Start calibration mode”);
Serial.println(“cal:XXX – Calibrate to XXX ppm”);
Serial.println(“exit – Save and exit calibration”);
}
void loop() {
gravityTds.setTemperature(temperature);
gravityTds.update();
tdsValue = gravityTds.getTdsValue();
Serial.print(“TDS: “);
Serial.print(tdsValue, 0);
Serial.println(” ppm”);
delay(1000);
}
To calibrate:
Clean and dry the probe
Immerse in calibration solution at 25°C
Wait for stable readings
Type “enter” in Serial Monitor
Type “cal:707” (or your solution’s ppm value)
Type “exit” to save calibration
The calibration coefficient stores in EEPROM and persists across power cycles.
Displaying TDS on LCD or OLED
For standalone operation, add a display:
16×2 LCD with I2C Connection
LCD Module
Arduino Pin
VCC
5V
GND
GND
SDA
A4
SCL
A5
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print(“TDS Meter”);
}
void displayTDS(float tds, float temp) {
lcd.setCursor(0, 0);
lcd.print(“TDS: “);
lcd.print((int)tds);
lcd.print(” ppm “);
lcd.setCursor(0, 1);
lcd.print(“Temp: “);
lcd.print(temp, 1);
lcd.print(“C “);
}
Troubleshooting TDS Sensor Problems
Common issues and solutions:
Readings Always Zero or Very Low
Possible Cause
Solution
Probe not in water
Ensure electrodes submerged
Poor connections
Check wiring and connectors
Wrong pin assignment
Verify analog pin in code
Damaged probe
Test with multimeter
Unstable or Jumping Readings
Possible Cause
Solution
Air bubbles on probe
Gently agitate probe
Probe too close to container edge
Position in center of water
Electrical interference
Add 0.1µF capacitor on signal line
Insufficient sampling
Increase SCOUNT value
Readings Don’t Match Reference Meter
Possible Cause
Solution
No temperature compensation
Add DS18B20 sensor
Calibration drift
Recalibrate with standard solution
Different conversion factors
Adjust the 0.5 multiplier
Contaminated probe
Clean with distilled water
Probe Maintenance Tips
Clean the probe electrodes monthly with distilled water and a soft brush. Never use abrasives or solvents.
Store the probe dry when not in use for extended periods. For continuous monitoring, replace probes annually as electrode degradation affects accuracy over time.
TDS meters measure total dissolved solids but cannot identify what those solids are. A reading of 300 ppm could be harmless calcium or dangerous lead, and the sensor cannot distinguish between them.
High TDS doesn’t necessarily mean unsafe water. Mineral water often has TDS above 500 ppm by design. Conversely, low TDS doesn’t guarantee safety, as biological contamination doesn’t affect conductivity measurements.
For drinking water safety assessment, TDS should be one data point among many, not the sole determinant. Laboratory testing remains necessary for detecting specific contaminants.
Frequently Asked Questions
Can I leave the TDS probe submerged continuously?
Yes, the probe is designed for long-term immersion. However, continuous exposure accelerates electrode wear. For monitoring applications, consider periodic rather than constant measurement. The sensor module and connector must stay dry, only the probe itself is waterproof.
Why do my readings differ from a commercial TDS pen?
Several factors cause discrepancies: different temperature compensation algorithms, different conversion factors (EC to TDS), calibration differences, and measurement timing. Commercial pens often average readings over several seconds, while Arduino readings may be instantaneous. Calibrate both devices against the same reference solution for meaningful comparison.
What’s the difference between TDS and EC measurements?
TDS (Total Dissolved Solids) and EC (Electrical Conductivity) measure related but distinct properties. EC measures how well water conducts electricity, expressed in microsiemens per centimeter (µS/cm). TDS estimates the mass of dissolved solids, expressed in ppm. The conversion TDS = EC × 0.5 is an approximation that assumes typical mixed-mineral content.
How often should I calibrate the sensor?
For casual monitoring, factory calibration suffices for months. For precise applications like hydroponics nutrient management, calibrate monthly or whenever readings seem inconsistent. Always recalibrate after replacing the probe or if the sensor has been stored dry for extended periods.
Can this sensor measure saltwater or pool water?
The standard 0-1000 ppm range sensor cannot accurately measure high-TDS water like pools (1500-3000 ppm) or saltwater (30,000+ ppm). The sensor saturates and gives maximum readings. DFRobot offers higher-range sensors for these applications, or you can dilute samples with distilled water and multiply the result.
Building Practical Water Monitoring Systems
The TDS sensor Arduino combination provides an accessible entry point into water quality monitoring. While not a replacement for laboratory analysis, it offers valuable real-time feedback for aquarium keepers, hydroponic growers, and anyone curious about their water quality.
Start with the basic circuit and code, verify operation with known water samples, then add temperature compensation for improved accuracy. For critical applications, invest time in proper calibration against standard solutions.
The insights gained from continuous monitoring often prove more valuable than occasional spot measurements, revealing trends and changes that single readings miss.
Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Notes: For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.