About magic numbers in the DFRobot pH library

userHead takkaO 2022-11-04 20:56:41 1461 Views2 Replies

I measure pH value using SEN0169-V2 and the library provided by DFRobot (https://github.com/DFRobot/DFRobot_PH).

The measurement itself is working fine, but I cannot understand the calibration code in the library.

 

I think the code derives the equation of a line through two points (y=ax+b), but what do the two magic numbers used here (1500 and 3.0) mean?

 

float slope = (7.0-4.0)/((this->_neutralVoltage-1500.0)/3.0 - (this->_acidVoltage-1500.0)/3.0); 

float intercept =  7.0 - slope*(this->_neutralVoltage-1500.0)/3.0;

 

Is 1500 an offset? Why is it divided by 3.0?

 

 

If anyone knows, please teach me.

Thank you.

2022-11-11 23:46:42

Hi, The data were obtained through software fitting of a large number of samples.

userHeadPic Winster
takkaO wrote:

Thanks for the reply.

 

I am sorry, but I am not understanding.Are you saying that the equation in the Arduino library is different from the equation for the coefficients of a linear equation (in the attached image)?Do these magic numbers have no meaning, just convenient numbers?

 

2022-11-14 20:45:34
1 Replies