diff --git a/Arduino/BTCDieselHeater/BTCDieselHeater.ino b/Arduino/BTCDieselHeater/BTCDieselHeater.ino index e7e5ce5..7ab59c8 100644 --- a/Arduino/BTCDieselHeater/BTCDieselHeater.ino +++ b/Arduino/BTCDieselHeater/BTCDieselHeater.ino @@ -116,8 +116,8 @@ #define RX_DATA_TIMOUT 50 const int FirmwareRevision = 22; -const int FirmwareSubRevision = 1; -const char* FirmwareDate = "27 Apr 2019"; +const int FirmwareSubRevision = 2; +const char* FirmwareDate = "9 May 2019"; #ifdef ESP32 @@ -145,6 +145,7 @@ void manageCyclicMode(); // DS18B20 temperature sensor support OneWire ds(15); // on pin 5 (a 4.7K resistor is necessary) DallasTemperature TempSensor(&ds); +DeviceAddress tempSensorAddress; long lastTemperatureTime; // used to moderate DS18B20 access float fFilteredTemperature = -100; // -100: force direct update uopn first pass const float fAlpha = 0.95; // exponential mean alpha @@ -360,6 +361,11 @@ void setup() { DebugPort.println(msg); } } + memset(tempSensorAddress, 0, 8); + if(numberOfDevices) + TempSensor.getAddress(tempSensorAddress, 0); + + TempSensor.setWaitForConversion(false); TempSensor.requestTemperatures(); lastTemperatureTime = millis(); @@ -778,7 +784,7 @@ void loop() tDelta = timenow - lastTemperatureTime; if(tDelta > TEMPERATURE_INTERVAL) { // maintain a minimum holdoff period lastTemperatureTime += TEMPERATURE_INTERVAL; // reset time to observe temeprature - fTemperature = TempSensor.getTempCByIndex(0); // read sensor + fTemperature = TempSensor.getTempC(tempSensorAddress); // read sensor // DebugPort.print("DS18B20 = "); DebugPort.println(fTemperature); // initialise filtered temperature upon very first pass if(fTemperature > -80) { // avoid disconnected sensor readings being integrated diff --git a/Arduino/BTCDieselHeater/src/Utility/BTC_JSON.cpp b/Arduino/BTCDieselHeater/src/Utility/BTC_JSON.cpp index d706882..04e3092 100644 --- a/Arduino/BTCDieselHeater/src/Utility/BTC_JSON.cpp +++ b/Arduino/BTCDieselHeater/src/Utility/BTC_JSON.cpp @@ -269,8 +269,8 @@ void updateJSONclients(bool report) if (report) { DebugPort.print("JSON send: "); DebugPort.println(jsonStr); } - getBluetoothClient().send( jsonStr ); sendWebServerString( jsonStr ); + getBluetoothClient().send( jsonStr ); } } // update extended params @@ -279,21 +279,28 @@ void updateJSONclients(bool report) if (report) { DebugPort.print("JSON send: "); DebugPort.println(jsonStr); } - getBluetoothClient().send( jsonStr ); sendWebServerString( jsonStr ); + getBluetoothClient().send( jsonStr ); } } // update timer parameters bool bNewTimerInfo = false; for(int tmr=0; tmr<14; tmr++) { + unsigned long tStart = millis(); if(makeJSONTimerString(tmr, jsonStr, sizeof(jsonStr))) { + unsigned long tJSON = millis() - tStart; if (report) { DebugPort.print("JSON send: "); DebugPort.println(jsonStr); } - getBluetoothClient().send( jsonStr ); + tStart = millis(); sendWebServerString( jsonStr ); + unsigned long tWF = millis() - tStart; + tStart = millis(); + getBluetoothClient().send( jsonStr ); + unsigned long tBT = millis() - tStart; bNewTimerInfo = true; + DebugPort.print("JSON times : "); DebugPort.print(tJSON); DebugPort.print(",");DebugPort.print(tBT); DebugPort.print(",");DebugPort.println(tWF); } } // request timer refesh upon clients @@ -309,8 +316,8 @@ void updateJSONclients(bool report) root.printTo(jsonStr, 800); DebugPort.print("JSON send: "); DebugPort.println(jsonStr); - getBluetoothClient().send( jsonStr ); sendWebServerString( jsonStr ); + getBluetoothClient().send( jsonStr ); } } diff --git a/Arduino/BTCDieselHeater/src/WiFi/BTCWebServer.cpp b/Arduino/BTCDieselHeater/src/WiFi/BTCWebServer.cpp index 54e0a71..b089072 100644 --- a/Arduino/BTCDieselHeater/src/WiFi/BTCWebServer.cpp +++ b/Arduino/BTCDieselHeater/src/WiFi/BTCWebServer.cpp @@ -192,9 +192,14 @@ bool isWebServerClientChange() bool sendWebServerString(const char* Str) { + unsigned long tStart = millis(); if(webSocket.connectedClients()) { + unsigned long tCon = millis() - tStart; + tStart = millis(); bTxWebData = true; // OLED tx data animation flag webSocket.broadcastTXT(Str); + unsigned long tWeb = millis() - tStart; +// DebugPort.print("Websend times : "); DebugPort.print(tCon); DebugPort.print(","); DebugPort.println(tWeb); return true; } return false;