Go Down

Topic: TDS/EC sensor interfacing with arduino (Read 24366 times) previous topic - next topic

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

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.

pothina_bala

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

jessemonroy650

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

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;

sonnyyu

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
...
Code: [Select]
const float ArduinoVoltage = 5.00; // CHANGE THIS FOR 3.3v Arduinos

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

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

http://forum.arduino.cc/index.php?topic=209836.msg1542386#msg1542386

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.

sonnyyu

#5
Sep 30, 2015, 03:37 pm Last Edit: Sep 30, 2015, 03:55 pm by sonnyyu
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;
Code: [Select]
while(((oldAnalogValue-analogValue)>threshold) || (oldAnalogValue<50))

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

Code: [Select]
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


Use Yún Release 5 please.



HeySammy

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

im_anithp

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

Pham

Can you tell me where the TDS sensor is purchased


internetmonster

Code: [Select]
while(((oldAnalogValue-analogValue)>threshold) || (oldAnalogValue<50))

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

Code: [Select]
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


Use Yún Release 5 please.



https://github.com/ejgertz/EMWA/blob/master/chapter-5/WaterConductivity
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.

lori_carmrs

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 (https://www.ebay.com/itm/254255270042). Works quite well.

Go Up