iot_water_monitor_v2
Dependencies: easy-connect-v16 Watchdog FP MQTTPacket RecordType-v-16 watersenor_and_temp_code
Revision 40:4356c209c58d, committed 2018-02-27
- Comitter:
- DuyLionTran
- Date:
- Tue Feb 27 14:51:18 2018 +0000
- Parent:
- 39:a5ee98bd0050
- Child:
- 41:6aed398adcc4
- Commit message:
- * version 2.6.8 02-27-2017: developing DO calibration. DS18B20 temperature sensor is added
Changed in this revision
--- a/Application/main.cpp Wed Feb 21 03:41:23 2018 +0000 +++ b/Application/main.cpp Tue Feb 27 14:51:18 2018 +0000 @@ -6,6 +6,7 @@ * 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 + * version 2.6.8 02-27-2017: developing DO calibration. DS18B20 temperature sensor is added */ /*************************************************************** @@ -48,18 +49,23 @@ ***************************************************************/ static Serial pc(SERIAL_TX, SERIAL_RX); -DigitalOut myled(LED1); +//DigitalOut myled(LED1); +DigitalOut myled(A6); DigitalOut espEn(D2); DigitalOut espRs(D7); Timer UploadTimer; Timer ReadAnalogTimer; + Ticker DisplayDO; /*************************************************************** * Unity function definitions ***************************************************************/ void ReadAllFlashValues(); void ProcessDOVal(); +void enableESP(); + +void BinkLEDStart(); /*************************************************************** * Unity function declarations ***************************************************************/ @@ -85,16 +91,39 @@ SENSOR_GetDOValue(); DataStruct.SENSOR_DOVal = doValue; } + +void enableESP() { + espEn = 1; + espRs = 1; + printf("ESP enabled\r\n"); +} + +void BinkLEDStart() { + myled = 0; + wait(0.2); + myled = 1; + wait(0.2); + myled = 0; + wait(0.2); + myled = 1; + wait(0.2); + myled = 0; + wait(0.2); + myled = 1; + wait(0.2); + myled = 0; +} /*************************************************************** * Main ***************************************************************/ int main() { pc.baud(115200); + enableESP(); UploadTimer.start(); ReadAnalogTimer.start(); DisplayDO.attach(&ProcessDOVal, PROCESS_DO_VALUE_S); - espEn = 1; - espRs = 1; + BinkLEDStart(); + lastRead = 0; pc.printf("\r\nX-NUCLEO-IDW01M1 mbed Application\r\n"); pc.printf("\r\nconnecting to AP\r\n"); @@ -117,8 +146,7 @@ ReadAllFlashValues(); SENSOR_ReadDoCharacteristicValues(); - myled=1; - + myled = 1; while (true) { time_t seconds = time(NULL); if ((uint32_t)(ReadAnalogTimer.read_ms() - lastReadAnalog) > READ_ANALOG_MS) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DS1820.lib Tue Feb 27 14:51:18 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/Sissors/code/DS1820/#236eb8f8e73a
--- a/Sensor/ReadSensor.cpp Wed Feb 21 03:41:23 2018 +0000 +++ b/Sensor/ReadSensor.cpp Tue Feb 27 14:51:18 2018 +0000 @@ -1,4 +1,5 @@ #include "mbed.h" +#include "DS1820.h" #include "ReadSensor.h" #include "flash_programming.h" @@ -21,9 +22,10 @@ int analogBufferIndex = 0; int copyIndex = 0; float SaturationDoVoltage; /* mV */ -float SaturationDoTemperature = 25.0; /* ^C */ +float SaturationDoTemperature = 27.0; /* ^C */ float averageVoltage; AnalogIn DOSensor(SENSOR_1_PIN); +DS1820 probe(SENSOR_2_PIN); int getMedianNum(int bArray[], int iFilterLen) { int bTab[iFilterLen];
--- a/Simple-MQTT/SimpleMQTT.h Wed Feb 21 03:41:23 2018 +0000 +++ b/Simple-MQTT/SimpleMQTT.h Tue Feb 27 14:51:18 2018 +0000 @@ -388,7 +388,7 @@ } strftime(timeBuf, 50, "%Y/%m/%d %H:%M:%S", localtime(&inputTime)); - sprintf(buf, "{\"type\":2,\"deviceId\":\"PROEVN\",\"time\":\"%s\",\"cmdId\":%d,\"DO\":%.2f}", + sprintf(buf, "{\"type\":2,\"deviceId\":\"PROEVN\",\"time\":\"%s\",\"cmdId\":%d,\"DO(ppm)\":%.2f}", timeBuf, commandID, DOVal); message.qos = MQTT::QOS0; message.retained = false;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jsonString.md Tue Feb 27 14:51:18 2018 +0000 @@ -0,0 +1,1 @@ +# PACKET JSON DETAILS \ No newline at end of file
--- a/mbed_app.json Wed Feb 21 03:41:23 2018 +0000 +++ b/mbed_app.json Tue Feb 27 14:51:18 2018 +0000 @@ -17,10 +17,10 @@ "value": "D0" }, "esp8266-ssid": { - "value": "\"GreenLantern\"" + "value": "\"KH\"" }, "esp8266-password": { - "value": "\"deAlembert\"" + "value": "\"kh123456\"" }, "esp8266-debug": { "value": true