Soil Measurements for pH and moisture
Dependencies: AD7124
Fork of CN0398 by
For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all
Diff: CN0398.cpp
- Revision:
- 2:f1b9c875e725
- Parent:
- 0:d6b384fb3c16
--- a/CN0398.cpp Mon Oct 24 15:41:18 2016 +0000 +++ b/CN0398.cpp Mon Oct 24 16:03:50 2016 +0000 @@ -15,10 +15,11 @@ CN0398::CN0398(PinName cs, PinName adp7118enable) : ad7124(cs), ADP7118Enable(adp7118enable), offset_voltage(default_offset_voltage) { - calibration_ph[0][0] = default_calibration_ph[0][0]; - calibration_ph[0][1] = default_calibration_ph[0][1]; - calibration_ph[1][0] = default_calibration_ph[1][0]; - calibration_ph[1][1] = default_calibration_ph[1][1]; + use_nernst = false; + calibration_ph[0][0] = 4;//default_calibration_ph[0][0]; + calibration_ph[0][1] = 0.169534;//default_calibration_ph[0][1]; + calibration_ph[1][0] = 10;//default_calibration_ph[1][0]; + calibration_ph[1][1] = -0.134135;//default_calibration_ph[1][1]; solution0 = 0; solution1 = 0; } @@ -96,12 +97,12 @@ temperature = PT100_RESISTANCE_TO_TEMP(resistance); #else -#define A (3.9083*pow(10,-3)) -#define B (-5.775*pow(10,-7)) +#define A (3.9083*pow(10.0,-3.0)) +#define B (-5.775*pow(10.0,-7.0)) /*if(resistance < 100.0) temperature = -242.02 + 2.228 * resistance + (2.5859 * pow(10, -3)) * pow(resistance, 2) - (48260 * pow(10, -6)) * pow(resistance, 3) - (2.8183 * pow(10, -3)) * pow(resistance, 4) + (1.5243 * pow(10, -10)) * pow(resistance, 5); else*/ - temperature = ((-A + sqrt(double(pow(A, 2) - 4 * B * (1 - resistance / 100.0))) ) / (2 * B)); + temperature = ((-A + sqrt(double(pow(A, 2.0) - 4 * B * (1 - resistance / 100.0))) ) / (2 * B)); #endif #endif return temperature;