diff --git a/neosensor/libraries/neocampus/advertisedDeviceCallbacks.cpp b/neosensor/libraries/neocampus/advertisedDeviceCallbacks.cpp index d7cf1e66f2ca5c30a50cc39e8f03b9833c66cf8f..c35cdd78bf6c243f514dffc038696716a8f9b2c8 100644 --- a/neosensor/libraries/neocampus/advertisedDeviceCallbacks.cpp +++ b/neosensor/libraries/neocampus/advertisedDeviceCallbacks.cpp @@ -7,11 +7,8 @@ // ***** getTemperature ***** float advertisedDeviceCallbacks::getTemperature(BLEAdvertisedDevice device) { uint8_t temp_lb = (uint8_t) device.getManufacturerData().c_str()[1]; // temperature lower byte - log_debug(F("temp_lb :")); log_debug(temp_lb); uint8_t temp_hb = (uint8_t)(device.getManufacturerData().c_str()[2]); // temperature higher byte - log_debug(F("\ntemp_hb :")); log_debug(temp_hb); int16_t temperature = (int16_t)((uint16_t)(temp_hb)<<8) + (uint16_t)temp_lb; - log_debug(F("\ntemperature :")); log_debug(temperature);log_flush(); return ((float)(temperature)/10); } @@ -20,13 +17,14 @@ float advertisedDeviceCallbacks::getTemperature(BLEAdvertisedDevice device) { //Display the BLE Device data void advertisedDeviceCallbacks::onResult(BLEAdvertisedDevice device) { if (device.getName() == "TP358 (5551)") { - log_debug(F("\nReference temperature : ")); + log_debug(F("\n[CALIBRATION][advertisedDeviceCallbacks] Reference temperature : ")); valBLE=getTemperature(device); log_debug(valBLE); log_flush(); _gotcalibrationvalue = true; }else{ - log_debug(device.getName()); + log_debug(F("\n[CALIBRATION][advertisedDeviceCallbacks] This device is not a ThermoPro TP358 (5551) : ")); + log_debug(device.getName());log_flush(); } } diff --git a/neosensor/libraries/neocampus/neocampus_utils.cpp b/neosensor/libraries/neocampus/neocampus_utils.cpp index 900ee54e8013c87278a3fdee539139fd404b9dc8..d3135a2de665a101070f11975df8053acc4427d1 100644 --- a/neosensor/libraries/neocampus/neocampus_utils.cpp +++ b/neosensor/libraries/neocampus/neocampus_utils.cpp @@ -116,7 +116,7 @@ bool checkCLEARswitch( uint8_t sw_pin ) { // --- CALIBRATION switch management ------------------------------------------------ /* check incr switch and decr switch for CALIBRATION procedure - * if decr_sw_pin == -1 OR incr_sw_pin-->== -1 check disabled + * if decr_sw_pin == -1 OR incr_sw_pin == -1 --> check disabled */ bool checkCALIBRATIONswitch(uint8_t decr_sw_pin, uint8_t incr_sw_pin) { diff --git a/neosensor/libraries/neocampus/neocampus_utils.h b/neosensor/libraries/neocampus/neocampus_utils.h index 264418a16136417fa41fa80dcf71beba4bf970e5..1e887b52416fd98da23772439b08f680311b77ba 100644 --- a/neosensor/libraries/neocampus/neocampus_utils.h +++ b/neosensor/libraries/neocampus/neocampus_utils.h @@ -40,7 +40,7 @@ extern bool _need2reboot; extern bool _need2calibrate; // value of the BLE device extern float valBLE; - +// got calibration flag extern bool _gotcalibrationvalue; diff --git a/neosensor/libraries/neocampus_drivers/SHT3x.cpp b/neosensor/libraries/neocampus_drivers/SHT3x.cpp index 49874e8ac527b3ca3f99781284b64854eb194181..56fbd05d73d429e21df63279387d9c351b2eeb64 100644 --- a/neosensor/libraries/neocampus_drivers/SHT3x.cpp +++ b/neosensor/libraries/neocampus_drivers/SHT3x.cpp @@ -285,17 +285,15 @@ boolean SHT3x::getTemp( float *pval ) // 100.0 x _tmp = (17500 x _tmp) / (16384 x 4) - 4500 _tmp = ((4375 * _tmp) >> 14) - 4500; *pval = ((float)_tmp / 100.0f); - log_debug(F("[SHT3x] Need to calibrate ?\n"));log_debug(_need2calibrate);log_flush(); if ((not _need2reboot) && _need2calibrate && _gotcalibrationvalue){ - log_debug(_gotcalibrationvalue); - log_debug(F("[SHT3x] Let's calibrate !\n"));log_debug(_need2calibrate);log_flush(); auto result = calibrate(pval, _a, _b); // updating of (a,b) _a = std::get<0>(result); _b = std::get<1>(result); - }else{ - log_debug(F("[SHT3x] No need to calibrate :'(\n"));log_debug(_need2calibrate);log_flush(); } - // calibration + if((not _need2reboot) && _need2calibrate && (not _gotcalibrationvalue)){ + log_debug(F("\n[CALIBRATION][SHT3x] No reference value detected. Calibration canceled !"));log_flush(); + } + // correction of the value *pval = *pval * _a; *pval = *pval + _b; return true; diff --git a/neosensor/libraries/neocampus_drivers/SHT3x.h b/neosensor/libraries/neocampus_drivers/SHT3x.h index 53110f7524b4173f47ed683bfb69fefad8a5488a..ccb81443afbf4222bf783d32b4ee6385b68195f1 100644 --- a/neosensor/libraries/neocampus_drivers/SHT3x.h +++ b/neosensor/libraries/neocampus_drivers/SHT3x.h @@ -155,7 +155,7 @@ class SHT3x : public generic_driver { #endif /* SHT3X_CRC_LOOKUP_TABLE */ float _a = 1.0; //coefficient for calibration - float _b = (-2.0); //coefficient for calibration + float _b = 0; //coefficient for calibration }; #endif /* _SHT3X_H_ */ diff --git a/neosensor/libraries/neocampus_drivers/generic_driver.cpp b/neosensor/libraries/neocampus_drivers/generic_driver.cpp index 08291832c9b32ec5f786d119ded41c60c723892e..e1eaa88e35852808df7b5b8c35a60f14ad1717eb 100644 --- a/neosensor/libraries/neocampus_drivers/generic_driver.cpp +++ b/neosensor/libraries/neocampus_drivers/generic_driver.cpp @@ -172,9 +172,9 @@ void generic_driver::setDataSent( void ) { */ std::tuple<float, float> generic_driver::calibrate(float* pval, float a, float b){ //TO-DO : Add an extern global variable -> ThermoPro sensor value : valBLE to replace the one below - log_debug(F("[generic_drivers] BLE Value :"));log_debug(valBLE);log_debug(F("/n"));log_flush(); + log_debug(F("\n[CALIBRATION][generic_drivers] BLE Value :"));log_debug(valBLE);log_flush(); b= valBLE-*pval; - log_debug(F("[generic_drivers] b :"));log_debug(b);log_debug(F("/n"));log_flush(); + log_debug(F("\n[CALIBRATION][generic_drivers] b :"));log_debug(b);log_debug(F("\n"));log_flush(); // calibration is done so no need to do it again _need2calibrate=false; return std::make_tuple(a, b); diff --git a/neosensor/neosensor.ino b/neosensor/neosensor.ino index 0f37b800e63636232a1a65a5db749022d3c8b252..88ff188cf21dcebe00d4769a4f1b4ed6d093c62a 100644 --- a/neosensor/neosensor.ino +++ b/neosensor/neosensor.ino @@ -795,7 +795,7 @@ void startScanBLE() { } // ***** scan Complete Call Back ***** static void scanCompleteCB(BLEScanResults scanResults) { // Callback invoked when scanning has completed - log_debug(F("scan completed"));log_flush(); + log_debug(F("\nScan completed"));log_flush(); } // --- SETUP -------------------------------------------------------------------