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.
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
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.
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
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.