Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: easy-connect-v16 Watchdog FP MQTTPacket RecordType-v-16 watersenor_and_temp_code
Revision 39:a5ee98bd0050, committed 2018-02-21
- Comitter:
- DuyLionTran
- Date:
- Wed Feb 21 03:41:23 2018 +0000
- Parent:
- 38:64e3e9acb49c
- Child:
- 40:4356c209c58d
- Commit message:
- * version 2.6.5 02-21-2017: developing calibration. Sensor read is completely ok
Changed in this revision
--- a/Application/CommandExecution.cpp Mon Feb 19 14:18:22 2018 +0000
+++ b/Application/CommandExecution.cpp Wed Feb 21 03:41:23 2018 +0000
@@ -1,4 +1,5 @@
#include "CommandExecution.h"
+#include "ReadSensor.h"
#include "mbed.h"
DigitalOut relay1(RELAY_1_PIN);
@@ -14,4 +15,8 @@
void CE_SetRTCTime(uint32_t CurrentEpochTime) {
printf("New local time value set\r\n");
set_time(CurrentEpochTime);
+}
+
+void CE_Calibrate() {
+ SENSOR_DoCalibration();
}
\ No newline at end of file
--- a/Application/CommandExecution.h Mon Feb 19 14:18:22 2018 +0000 +++ b/Application/CommandExecution.h Wed Feb 21 03:41:23 2018 +0000 @@ -9,5 +9,6 @@ void CE_HandleRelays(int Relay1State, int Relat2State, int Relat3State); void CE_SetRTCTime(uint32_t CurrentEpochTime); +void CE_Calibrate(); #endif /* __COMMANDEXECUTION_H__ */ \ No newline at end of file
--- a/Application/main.cpp Mon Feb 19 14:18:22 2018 +0000 +++ b/Application/main.cpp Wed Feb 21 03:41:23 2018 +0000 @@ -5,6 +5,7 @@ * version 2.5 02-14-2017: 3rd relay and remote time setting are added * version 2.6 02-14-2017: DO Sensor added, calibration is still on the way * version 2.6.3 02-19-2017: developing calibration. the average voltage is ok + * version 2.6.5 02-21-2017: developing calibration. Sensor read is completely ok */ /***************************************************************
--- a/Sensor/ReadSensor.cpp Mon Feb 19 14:18:22 2018 +0000
+++ b/Sensor/ReadSensor.cpp Wed Feb 21 03:41:23 2018 +0000
@@ -69,17 +69,17 @@
averageVoltage = getMedianNum(analogBufferTemp, SCOUNT) * (float)VREF/1024.0;
printf("Average voltage %.2f\r\n", averageVoltage);
/* calculate the do value, doValue = Voltage / SaturationDoVoltage * SaturationDoValue(with temperature compensation) */
- doValue = (SaturationValueTab[0] + (int)(SaturationDoTemperature + 0.5)) * averageVoltage / (float)(SaturationDoVoltage*10.0);
+ doValue = (SaturationValueTab[(int)(SaturationDoTemperature + 0.5)] * averageVoltage) / (float)(SaturationDoVoltage);
float a = 1;
printf("SaturationDoVoltage %.2f; DO Value %.2f mg/L\r\n", SaturationDoVoltage, doValue/a);
}
-void SENSOR_Calib() {
+void SENSOR_DoCalibration() {
}
void SENSOR_ReadDoCharacteristicValues() {
- FP_WriteConfigValues(1508);
+ FP_WriteConfigValues(1255);
uint32_t int_SaturationDoVoltage = FP_ReadValue(SAT_DO_VOLT_ADDRESS);
printf("Read SaturationDoVoltage %d\r\n", int_SaturationDoVoltage);
SaturationDoVoltage = (float)int_SaturationDoVoltage;
--- a/Sensor/ReadSensor.h Mon Feb 19 14:18:22 2018 +0000 +++ b/Sensor/ReadSensor.h Wed Feb 21 03:41:23 2018 +0000 @@ -8,7 +8,7 @@ #define VREF 5000 #define SCOUNT 30 /* sum of sample point */ -void SENSOR_Calib(); +void SENSOR_DoCalibration(); void SENSOR_AnalogRead(); void SENSOR_GetDOValue(); void SENSOR_ReadDoCharacteristicValues();
--- a/Simple-MQTT/SimpleMQTT.h Mon Feb 19 14:18:22 2018 +0000
+++ b/Simple-MQTT/SimpleMQTT.h Wed Feb 21 03:41:23 2018 +0000
@@ -39,6 +39,12 @@
RELAY_STATE,
CONFIG_VALUE
} UploadType;
+
+typedef enum {
+ CONTROL_CMD = 0,
+ READ_CMD,
+ SETUP_CMD
+} CommandType;
struct UploadValue {
float ADC_PHVal;
@@ -166,7 +172,7 @@
msg[0]='\0';
strncat (msg, (char*)msgMQTT.message.payload, msgMQTT.message.payloadlen);
printf ("--->>> MQTT_SubscribeCallback msg: %s\n\r", msg);
- //{"type":"3","deviceId":"string"}
+ /* {"type":"3","deviceId":"string"} */
Json json(msg, msgMQTT.message.payloadlen);
if (!json.isValidJson()) {
printf("Invalid JSON: %s", msg);
@@ -185,6 +191,9 @@
printf("Command Type: %d, error %d\r\n", CommandType, ret);
switch (CommandType) {
+ case CONTROL_CMD: CE_Calibrate();
+ break;
+
case 3: int relayState1, relayState2, relayState3;
KeyIndex = json.findKeyIndexIn("cmdID", 0);
KeyValueIndex = json.findChildIndexOf(KeyIndex, 0);
--- a/mbed-os.lib Mon Feb 19 14:18:22 2018 +0000 +++ b/mbed-os.lib Wed Feb 21 03:41:23 2018 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#2b4ff78ab0a52ef1dc3f2998908453c595e2b2c0 +https://github.com/ARMmbed/mbed-os/#569159b784f70feaa32ce226aaca896fb83452f7