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
Revision 2:f1b9c875e725, committed 2016-10-24
- Comitter:
- adisuciu
- Date:
- Mon Oct 24 16:03:50 2016 +0000
- Parent:
- 1:712abd52fa0a
- Child:
- 3:7072863079d5
- Commit message:
- Fixes for mbed compiler
Changed in this revision
--- a/AD7124.lib Mon Oct 24 15:41:18 2016 +0000 +++ b/AD7124.lib Mon Oct 24 16:03:50 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/AnalogDevices/code/AD7124/#f32d3fb1d3e2 +http://mbed.org/teams/AnalogDevices/code/AD7124/#4a4194a5a8ed
--- 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;
--- a/CN0398.h Mon Oct 24 15:41:18 2016 +0000
+++ b/CN0398.h Mon Oct 24 16:03:50 2016 +0000
@@ -223,13 +223,15 @@
AD7124 ad7124;
DigitalOut ADP7118Enable;
- bool use_nernst = false;
+ bool use_nernst;
const float default_offset_voltage = 0;
const uint16_t SENSOR_SETTLING_TIME = 400; /*in ms*/
float offset_voltage;
- float default_calibration_ph[2][2] = {{4, 0.169534}, {10, -0.134135}};
+ float default_calibration_ph[2][2]; //= {{4, 0.169534}, {10, -0.134135}};
float calibration_ph[2][2];
uint8_t solution0, solution1;
};
+
+
#endif

CN0398