0

In finding the pH value of a liquid/Soil, what is the range of Offset voltage value that I can use in my code?

Using / calibrating pH sensor module

I considered the above link as a reference. But I didn't come to know the range of Offset Value...

Here is the logic below to find the value of pH right...

avgValue = 0;
for (int i=2;i<8;i++)       // take the average value of 6 center sample
avgValue+=buf[i]; 

float phValue = (float)avgValue*5.0/1024/6; // convert the analog into millivolt
phValue=3.5*phValue+Offset;

What is the range of Offset value can I use in the above/my code?

Thanks in Advance

  • I think you would need to test it by testing known value solutions with your sensor. It is probably going to be different between different instances of the sensor so each will need calibrating in this way. – Code Gorilla May 19 '16 at 12:13
  • I tested it for water of pH 7.0. It's showing a value of 10.5 units. So, I considered -3.5v as an offset value..While considering offset value as -3.5v, I got a doubt that is there any limited range for an offset value to consider – Shiva Teja May 19 '16 at 12:25
  • It is doubtful any ADC / sensor combination is exactly linear, of the correct magnitude, slope and w/o noise. How precise / accurate your application needs to be should dictate your efforts. My next steps would be to plot know acid and bases to resolve these questions. – st2000 May 19 '16 at 13:42
  • I don't think you mean -3.5v, because the voltage range you are measuring is 0-5v. At the moment all you know is when the variable phValue = 10.5 then the pH of the liquid is 7.0. Like st2000 says you now need to pad out your calibration table what does pH 1 make your device read? pH = 2 ? etc. Then you will get a table that says when the sensor reads 3.9 it means pH = 1, when it read 5.2 it means pH=2, when it reads 4.9 it means about pH 1.8. – Code Gorilla May 20 '16 at 12:04
  • Something you may also want to consider is what happens if one reading is massively different to the other 5 readings. It probably indicates a sensor fault for that reading, but it will move your answer towards pH=1. I don't think you should be dividing by 1024. This division will loose some precision in your reading and therefore it will make you calibration table less accurate. – Code Gorilla May 20 '16 at 12:09
1

When converting real world sensor measurements into usable data there are several issues to consider:

  1. Noise from any number of sources such as (unavoidable?) long cables and power supplies to name two. Consider using exponential averaging to minimize the effects of noise. If the noise if predictable consider sampling only when the noise is absent.

  2. Slope of the data is important when converting to known scales. For example the slop of the resistance of a thermistor verses heat may not have the same slope as the temperature in Celsius verses heat. Simply multiply by the appropriate constant to correct for slope error.

  3. After you correct for slope the values may still not be correct. When all values are equally less or more then the expected values an offset is required. Simply add or subtract the appropriate constant to correct for offset error.

  4. Linearity is often corrected using lookup tables. Linearity is a measure of how closely the sensor tracks the physical value being measured. For example, after slope and offset corrections, a thermistor measurement may appeared curved when compared to the actual temperature in Celsius. For this final correction the sensor measured value is used to index into a lookup table which returns a correction value. Interpolation is used to control the size of the lookup table when space is a consideration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.