This is the important part of the code:
averageVoltage = getMedianNum(analogBufferTemp,SCOUNT) * (float)VREF/ 1024.0; // read the analog value more stable by the median filtering algorithm, and convert to voltage value float compensationCoefficient=1.0+0.02*(temperature-25.0); //temperature compensation formula: fFinalResult(25^C) = fFinalResult(current)/(1.0+0.02*(fTP-25.0)); float compensationVolatge=averageVoltage/compensationCoefficient; //temperature compensation tdsValue=(133.42*compensationVolatge*compensationVolatge*compensationVolatge - 255.86*compensationVolatge*compensationVolatge + 857.39*compensationVolatge)*0.5; //convert voltage value to tds value
If you just want the temp of a single reading, you can ignore the getMedianNum function and just use the sensor value as your initial averageVoltage.
As before, we know the XOD analog-read already does the /1024 for us, so you just need to perform the rest of the calculations on your analog-read output.
In the compensationCoefficent calculation, temparature=25, so equation reduces to just 1, so compensationVoltage is just averageVoltage
There are square & cube nodes, so we can express the final formula as (using voltage as your analog-read value):
Temp = (133.42 * (voltage^3) - 255.86 * (voltage^2) + 857.39 * voltage) * 0.5
I’m guessing if temperatures you are measuring are not close to 25, then you will need to use a different compensationCoefficient.