Duy tran / Mbed OS iot_water_monitor_v2

Dependencies:   easy-connect-v16 Watchdog FP MQTTPacket RecordType-v-16 watersenor_and_temp_code

Files at this revision

API Documentation at this revision

Comitter:
DuyLionTran
Date:
Thu Mar 08 13:54:13 2018 +0000
Parent:
44:8a99efffeb8e
Child:
46:f545b8f7f242
Commit message:
* version 2.7.5a 03-08-2018: DS18B20 problem discovered at line 42th ReadSensor.cpp

Changed in this revision

Application/main.cpp Show annotated file Show diff for this revision Revisions of this file
Flash/flash_programming.h Show annotated file Show diff for this revision Revisions of this file
Sensor/ReadSensor.cpp Show annotated file Show diff for this revision Revisions of this file
Sensor/ReadSensor.h Show annotated file Show diff for this revision Revisions of this file
Simple-MQTT/SimpleMQTT.h Show annotated file Show diff for this revision Revisions of this file
--- a/Application/main.cpp	Thu Mar 08 13:16:44 2018 +0000
+++ b/Application/main.cpp	Thu Mar 08 13:54:13 2018 +0000
@@ -9,6 +9,7 @@
   * version 2.6.8 	02-27-2018: developing DO calibration. DS18B20 temperature sensor is added
   * version 2.7 	03-04-2018: DO calibration complete. IWDG is added
   * version 2.7.5 	03-08-2018: DS18B20 & IWDG is being developed
+  * version 2.7.5a	03-08-2018: DS18B20 problem discovered at line 42th ReadSensor.cpp
   */
 
 /***************************************************************
@@ -58,6 +59,7 @@
 IWDG_HandleTypeDef IwdgHandle;
 
 extern float doValue;
+extern float temperature;
 extern bool  isCalibrating;
 
 /***************************************************************
@@ -91,7 +93,7 @@
 void ReadAllFlashValues() {
 	DataStruct.ADC_TEMPVal = 0;
 	DataStruct.ADC_DOVal = 0;
-	DataStruct.SENSOR_TEMPVal = 25.0;
+	DataStruct.SENSOR_TEMPVal = 0;
 	DataStruct.SENSOR_DOVal = 0;
 	DataStruct.RELAY_State_1				= FP_ReadValue(RELAY1_ADDRESS);
 	DataStruct.RELAY_State_2				= FP_ReadValue(RELAY2_ADDRESS);
@@ -112,6 +114,7 @@
 	}
 	SENSOR_GetDOValue();
 	DataStruct.SENSOR_DOVal = doValue;
+	DataStruct.SENSOR_TEMPVal = temperature;
 	if (isCalibrating) {
 		SENSOR_DoCalibration(currentCalibMode);
 		if (currentCalibMode == 3) {
--- a/Flash/flash_programming.h	Thu Mar 08 13:16:44 2018 +0000
+++ b/Flash/flash_programming.h	Thu Mar 08 13:54:13 2018 +0000
@@ -143,10 +143,10 @@
 #define RELAY2_ADDRESS          (RELAY1_ADDRESS     + STEP_ADDRESS)
 #define RELAY3_ADDRESS          (RELAY2_ADDRESS     + STEP_ADDRESS)
 
-#define MODE_ADDRESS            (CONF_BASE_ADDRESS + STEP_ADDRESS)
-#define OXY_THRES_ADDRESS       (MODE_ADDRESS      + STEP_ADDRESS)
-#define TEMP_THRES_ADDRESS      (OXY_THRES_ADDRESS   + STEP_ADDRESS)
-#define UPLOAD_PERIOD_ADDRESS   (TEMP_THRES_ADDRESS   + STEP_ADDRESS)
+#define MODE_ADDRESS            (CONF_BASE_ADDRESS  + STEP_ADDRESS)
+#define OXY_THRES_ADDRESS       (MODE_ADDRESS       + STEP_ADDRESS)
+#define TEMP_THRES_ADDRESS      (OXY_THRES_ADDRESS  + STEP_ADDRESS)
+#define UPLOAD_PERIOD_ADDRESS   (TEMP_THRES_ADDRESS + STEP_ADDRESS)
 
 #define SAT_DO_VOLT_ADDRESS     (CALIB_BASE_ADDRESS + STEP_ADDRESS)
 
--- a/Sensor/ReadSensor.cpp	Thu Mar 08 13:16:44 2018 +0000
+++ b/Sensor/ReadSensor.cpp	Thu Mar 08 13:54:13 2018 +0000
@@ -37,7 +37,9 @@
 bool    isCalibrating           = false;
 
 AnalogIn     DOSensor(SENSOR_1_PIN);
-DS1820       probe(SENSOR_2_PIN);
+
+/* Error often occurs here */
+//DS1820       probe(SENSOR_2_PIN);
 
 int getMedianNum(int bArray[], int iFilterLen) {
     int bTab[iFilterLen];
--- a/Sensor/ReadSensor.h	Thu Mar 08 13:16:44 2018 +0000
+++ b/Sensor/ReadSensor.h	Thu Mar 08 13:54:13 2018 +0000
@@ -2,7 +2,7 @@
 #define __READSENSOR_H__
 
 #define SENSOR_1_PIN  (A5)
-#define SENSOR_2_PIN  (A3)
+#define SENSOR_2_PIN  (A4)
 #define SENSOR_3_PIN  (A3)
 
 #define VREF           5000
--- a/Simple-MQTT/SimpleMQTT.h	Thu Mar 08 13:16:44 2018 +0000
+++ b/Simple-MQTT/SimpleMQTT.h	Thu Mar 08 13:54:13 2018 +0000
@@ -191,12 +191,15 @@
             printf("Command Type: %d, error %d\r\n", CommandType, ret);
             
             switch (CommandType) {
-            	case 0: CE_Calibrate();
+            	case 0: printf("Calibrate\r\n");
+            			CE_Calibrate();
             	break;
             	
-            	case 1:
+            	case 1: printf("Set relay alarm state\r\n");
+            	break;
             	
-            	case 2: int relayState1, relayState2, relayState3;
+            	case 2: printf("Set relay state\r\n");
+            			int relayState1, relayState2, relayState3;
             			KeyIndex      = json.findKeyIndexIn("cmdID", 0);
             			KeyValueIndex = json.findChildIndexOf(KeyIndex, 0);
             			ret = json.tokenIntegerValue(KeyValueIndex, receiveCmdID); 
@@ -221,8 +224,8 @@
             			CE_HandleRelays(relayState1, relayState2, relayState3);
             	break;
             	
-            	case 3: int mode, OxiThres, TempThres, uploadInterval, setRTCTime;
-            	
+            	case 3: printf("Set config values\r\n");
+            			int mode, OxiThres, TempThres, uploadInterval, setRTCTime;
             			KeyIndex      = json.findKeyIndexIn("cmdID", 0);
             			KeyValueIndex = json.findChildIndexOf(KeyIndex, 0);
             			ret = json.tokenIntegerValue(KeyValueIndex, receiveCmdID); 
@@ -255,7 +258,8 @@
             			CE_SetRTCTime(setRTCTime);		
             	break;
             	
-            	case 4: CE_UpdateImmediately();
+            	case 4: printf("Synchronize data\r\n");
+            			CE_UpdateImmediately();
             	break;
             	
             	default: break;