TDS/EC sensor interfacing with arduino

Hello,

When I am Interfacing TDS/EC Sensor to Arduino ,I am getting some TDS value.

But When compare to arduino TDS values and TDS Meter values ,both are not matching

Here the my code and Circuit diagram of TDS sensor is:

/*
Water Conductivity Monitor
Sketch for an Arduino gadget that measures the electrical
conductivity of water.
/
const float ArduinoVoltage = 5.00; // CHANGE THIS FOR 3.3v Arduinos
const float ArduinoResolution = ArduinoVoltage / 1024;
const float resistorValue = 10000.0;
int threshold = 3;
int inputPin = A0;
int ouputPin = A5;
float temp;
int tempPin=A2;
void setup()
{
Serial.begin(9600);
pinMode(ouputPin, OUTPUT);
pinMode(inputPin, INPUT);
pinMode(tempPin,INPUT);
}
void loop()
{
int analogValue=0;
int oldAnalogValue=1000;
float returnVoltage=0.0;
float resistance=0.0;
double Siemens;
float TDS=0.0;
temp=analogRead(tempPin);
temp=temp
0.48828125;
Serial.print("Temperature:");
Serial.print(temp);
Serial.print("'C");
Serial.println();
delay(500);
while(((oldAnalogValue-analogValue)>threshold) || (oldAnalogValue<50))
{
oldAnalogValue = analogValue;
digitalWrite( ouputPin, HIGH );
delay(10); // allow ringing to stop
analogValue = analogRead( inputPin );
digitalWrite( ouputPin, LOW );
}
Serial.print("Return voltage = ");
returnVoltage = analogValue *ArduinoResolution;
Serial.print(returnVoltage);

Serial.println(" volts");
Serial.print("That works out to a resistance of ");
resistance = ((5.00 * resistorValue) / returnVoltage) - resistorValue;
Serial.print(resistance);
Serial.println(" Ohms.");
Serial.print("Which works out to a conductivity of ");
Siemens = 1.0/(resistance/1000000);
if(150<=Siemens & Siemens<=800)
Siemens=Siemens+120;
else if(801<=Siemens | Siemens>=1900)
Siemens=Siemens+300;
Serial.print(Siemens);
Serial.println(" microSiemens.");
Serial.print("Total Dissolved Solids are on the order of ");
TDS = 500 * (Siemens/1000);
Serial.print(TDS);
Serial.println(" PPM.");
if (returnVoltage>4.9) Serial.println("Are you sure this isn't metal?");
delay(2000);
Serial.println("");
}

and above test results are:

Arduino Serial monitor TDS Meter

Test-1 330 320
Test-2 420 408
Test-3 550 700
Test-4 1200 1550
Test-5 1300 1720

How to calibrate TDS/EC Sensor Exactely like tds sensor.

tds.jpg

Above all Test Results in microSiemens.........

@pothina_bala,
when posting code, please use markup. See attached image.
TIA
Jesse

arduino_markup.png

can you explain the following statements in the code
while(((oldAnalogValue-analogValue)>threshold) || (oldAnalogValue<50))
and also
if(150<=Siemens & Siemens<=800)
Siemens=Siemens+120;
else if(801<=Siemens | Siemens>=1900)
Siemens=Siemens+300;

pothina_bala:
Hello,

When I am Interfacing TDS/EC Sensor to Arduino ,I am getting some TDS value.

But When compare to arduino TDS values and TDS Meter values ,both are not matching
...

const float ArduinoVoltage = 5.00; // CHANGE THIS FOR 3.3v Arduinos

Unless you have latest version Yun Release 5, not matching is normal.

sonnyyu:
Arduino Yun 5v pin/USB port doesnt provide 5 volt.

Arduino Yun 5v pin doesnt give me 5v. - #6 by sonnyyu - Arduino Yún - Arduino Forum

4.48 volt at 5v pin will cause some shield fail, and low voltage at USB port cause a lot of USB device fail.

Arduino Yun release 5 is fixed 5v pin/USB port problem, provide exactly 5 volt which I saw the demo at maker faire nyc yesterday.

mihir_chate:
can you explain the following statements in the code
while(((oldAnalogValue-analogValue)>threshold) || (oldAnalogValue<50))
and also
if(150<=Siemens & Siemens<=800)
Siemens=Siemens+120;
else if(801<=Siemens | Siemens>=1900)
Siemens=Siemens+300;

while(((oldAnalogValue-analogValue)>threshold) || (oldAnalogValue<50))

Keep mesure until both "threshold of this mesure and last mesure <= 3" Or "oldAnalogValue<50" meet.

 if(150<=Siemens & Siemens<=800)
 Siemens=Siemens+120;
 else if(801<=Siemens ||  Siemens>=1900)
 Siemens=Siemens+300;

for calibrate Siemens value here using an other conductivity meter.


Environmental Monitoring with Arduino

Use Yún Release 5 please.

Can you please mention the link from where you have bought TDS sensor?

Can i get the sensor name?
Actually i require for making one of my project, it will be great help! :slight_smile:

Can you tell me where the TDS sensor is purchased

sonnyyu:

while(((oldAnalogValue-analogValue)>threshold) || (oldAnalogValue<50))

Keep mesure until both "threshold of this mesure and last mesure <= 3" Or "oldAnalogValue<50" meet.

 if(150<=Siemens & Siemens<=800)

Siemens=Siemens+120;
else if(801<=Siemens ||  Siemens>=1900)
Siemens=Siemens+300;




for calibrate Siemens value here using an other conductivity meter.

https://github.com/ejgertz/EMWA/blob/master/chapter-5/WaterConductivity
[
Environmental Monitoring with Arduino](http://www.amazon.com/Environmental-Monitoring-Arduino-Building-Devices/dp/1449310567/)

**Use Yún Release 5 please.**

can you please share the sensor as well? for this same code? i want to make a water conductivity controller via arduino all i need is a code with water conductivity sensor.

I had a similar requirement and if anyone is still looking for a TDS meter, I used this TDS meter that can be interfaced directly with arduino over here (Arduino Analog TDS(Total Dissolved Solids) Sensor/Meter water quality ppm + Code | eBay). Works quite well.

Which sensor was used in in your project, Can you please specify can i connect to using the ESP8266 to utilize the wifi functionality, I found an article here TDS Meter with TDS Sensor and Arduino for water quality monitoring in Realtime – Circuit Schools where they added nodemcu but im not able to find the sensor they used. Could someone get a link for the sensor.