Tds sensor equation

sensor::tds = (133.42 * pow(sensor::ec, 3) - 255.86 * sensor::ec * sensor::ec + 857.39 * sensor::ec) * 0.5; //convert voltage value to tds value

where does this value come from? 133.42 and 857.39

can anyone help me to find a journal that have this equation

A look at the data sheet of the sensor and the library used might actually help.

2 Likes

Someone used a curve fitting procedure to convert output voltage measurements to TDS units, based on measurements with a couple of TDS standard solutions.

The formula used is one of several standard approaches to sensor calibration. See this general tutorial.

2 Likes

actually this equation come from the tds water quality project. but I dont understand how this formula being derive.

 tdsValue=(133.42*compensationVolatge*compensationVolatge*compensationVolatge - 255.86*compensationVolatge*compensationVolatge + 857.39*compensationVolatge)*0.5; //convert voltage value to tds value

They are an example of "magic" numbers, ie values used in a sketch with no explanation of their origin or meaning.

If such numbers are used then it is much better to assign them to variables with meaningful names so that there is a fighting chance of understanding what is going on but that was not done in this case

1 Like

Explained in reply #3.

2 Likes

could you help provide the link of the journal that derive this equation. thank you

Take a search engine of your choice and ask the WWW for the am phrase
to collect some data to be sorted out to get the needed information.

1 Like

yes true, I think every formula must have a reference to prove that the equation is correct

If the equation fits the curve and allows you to make accurate measurements, it is correct.

2 Likes

I have ask Chatgpt about this matter but no answer:

does this equation comes from a journal paper? and which journal paper underline this equation?

I don't have access to specific journal papers or proprietary databases to check the origin of this equation. It's possible that this equation is not from a widely recognized journal paper, or it may be part of proprietary information associated with a particular sensor or device.

No, it is a standard equation used to fit curves. Consult a data analysis textbook.

The general equation is called "power law".

You should calibrate your own sensor, as you see fit. See the tutorial in post #3.

2 Likes

I have the same concern

1 Like

oh ok, thank you

yes, me too

I understand how to do the calibration, but I want to know what does these number stand for?

133.42 , 255.86 and 857.39

The numbers are simply the result of the curve fitting procedure. They result in a curve that fits the data.

The numbers have no meaning by themselves, unless the equation itself represents a physical law or a reasonable mathematical model for explaining the behavior of the system being measured.

Correction: this is not a "power law" curve fit. It is a cubic polynomial curve fit:

(133.42 * pow(sensor::ec, 3) - 255.86 * sensor::ec * sensor::ec + 857.39 * sensor::ec) * 0.5; //convert voltage value to tds value


TDS = a*x^3 + b*x^2 + c*x

Where did you find that code?

1 Like
tdsValue=(133.42*compensationVolatge*compensationVolatge*compensationVolatge - 255.86*compensationVolatge*compensationVolatge + 857.39*compensationVolatge)*0.5;

from: Analog TDS Sensor Meter for Arduino / ESP32 / Raspberry Pi - DFRobot Wiki

These so-called "TDS sensors" don't actually measure TDS at all - what they measure is the conductivity of the water.

You then assume* that there is some relationship between this conductivity measurement, and TDS

So, as has already been explained, you determine that relationship empirically (ie, by experiment) by taking readings from a number of samples of known TDS.

This gives you a set of sensor reading at a set of known TDS value - you apply standard Curve-Fitting techniques to that data to get your formula:

You can do this yourself in spreadsheet apps - eg, Excel:

* It isn't a very good assumption, because not all the solids that might be dissolved in water will affect its conductivity.

1 Like