From 0185624965535ccf75cb6d461d197f80d817fc77 Mon Sep 17 00:00:00 2001 From: Manon MALIQUE <manon.malique@irit.fr> Date: Fri, 8 Mar 2024 10:41:45 +0100 Subject: [PATCH] Modification pour tests --- arduinoIDE_esp32_boards/boards.local.txt | 10 +++++- .../libraries/neocampus/neocampus_utils.cpp | 8 ++--- .../libraries/neocampus_drivers/SHT3x.cpp | 19 +++++++---- .../neocampus_drivers/generic_driver.cpp | 5 ++- .../neocampus_drivers/generic_driver.h | 11 +++---- .../neocampus_modules/airquality.cpp | 21 +++++++----- .../libraries/neocampus_modules/airquality.h | 11 ++----- neosensor/libraries/neocampus_modules/base.h | 11 +------ .../libraries/neocampus_modules/humidity.cpp | 33 +++++++++++-------- .../libraries/neocampus_modules/humidity.h | 8 ++--- .../neocampus_modules/luminosity.cpp | 23 ++++++++----- .../libraries/neocampus_modules/luminosity.h | 8 +---- .../neocampus_modules/temperature.cpp | 21 +++++++----- .../libraries/neocampus_modules/temperature.h | 7 +--- .../neocampus_modules/typeModule.cpp | 3 +- tests/CalibrationSensor/CalibrationSensor.ino | 3 +- 16 files changed, 101 insertions(+), 101 deletions(-) diff --git a/arduinoIDE_esp32_boards/boards.local.txt b/arduinoIDE_esp32_boards/boards.local.txt index 8b9fa28b..58e81202 100644 --- a/arduinoIDE_esp32_boards/boards.local.txt +++ b/arduinoIDE_esp32_boards/boards.local.txt @@ -36,7 +36,9 @@ neOSensor.build.flash_mode=dio neOSensor.build.flash_size=4MB neOSensor.build.flash_freq=80m neOSensor.build.boot=dio -neOSensor.build.partitions=default +# [feb.24] disabling default to enable choices +#neOSensor.build.partitions=default + # onboard LED2 (except on ESP32 38pins we don't use) # DISABLE_SSL: flag to disable SSL comms. # DISABLE_ADC_CAL: flag to disable esp32 ADC advanced calibration @@ -56,6 +58,12 @@ neOSensor.menu.UploadSpeed.115200.upload.speed=115200 # FLASH partitioning neOSensor.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) neOSensor.menu.PartitionScheme.default.build.partitions=default +# [feb.24] additional FLASH partitioning options +neOSensor.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS) +neOSensor.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs +neOSensor.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080 +neOSensor.menu.PartitionScheme.defaultffat.build.partitions=default_ffat +neOSensor.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS) # Core debug neOSensor.menu.DebugLevel.none=None diff --git a/neosensor/libraries/neocampus/neocampus_utils.cpp b/neosensor/libraries/neocampus/neocampus_utils.cpp index dec57533..92529efb 100644 --- a/neosensor/libraries/neocampus/neocampus_utils.cpp +++ b/neosensor/libraries/neocampus/neocampus_utils.cpp @@ -115,7 +115,7 @@ bool checkCLEARswitch( uint8_t sw_pin ) { //Manon // --- CALIBRATION switch management ------------------------------------------------ -/* check incr switch and decr switch for CALIBRATION procedure + /* check incr switch and decr switch for CALIBRATION procedure * if decr_sw_pin == -1 OR incr_sw_pin-->== -1 check disabled */ bool checkCALIBRATIONswitch(uint8_t decr_sw_pin, uint8_t incr_sw_pin) { @@ -147,10 +147,10 @@ bool checkCALIBRATIONswitch(uint8_t decr_sw_pin, uint8_t incr_sw_pin) { delay(500); // sleep for 500ms (allowing ESP to manage internals) } - /* okay, delay for + and - switch acquisition is now over. + /* okay, delay for + and - switch acquisition is now over. * If we need to calibrate things, we want to wait for sw_pin * LOW (i.e user stopped to press switch) - */ + */ if( _res==true ) { log_info(F("\n[CALIBRATION] activate CALIBRATION procedure ...")); log_debug(F("\n[CALIBRATION] release SWITCH for calibration to start ...")); @@ -162,7 +162,7 @@ bool checkCALIBRATIONswitch(uint8_t decr_sw_pin, uint8_t incr_sw_pin) { return _res; } -//Fin Manon + // ---------------------------------------------------------------------------- // --- WiFi setup ------------------------------------------------------------- diff --git a/neosensor/libraries/neocampus_drivers/SHT3x.cpp b/neosensor/libraries/neocampus_drivers/SHT3x.cpp index c0a16aea..2f2fe6ad 100644 --- a/neosensor/libraries/neocampus_drivers/SHT3x.cpp +++ b/neosensor/libraries/neocampus_drivers/SHT3x.cpp @@ -216,7 +216,6 @@ boolean SHT3x::acquire( float *pval ) log_debug(F("\n[SHT3x] corrected temperature for i2c=0x"));log_debug(_i2caddr,HEX);log_flush(); } #endif - return true; } @@ -284,7 +283,8 @@ boolean SHT3x::getTemp( float *pval ) // temp = (stemp * 175.0f) / 65535.0f - 45.0f; // 100.0 x _tmp = (17500 x _tmp) / (16384 x 4) - 4500 _tmp = ((4375 * _tmp) >> 14) - 4500; - *pval = (float)_tmp / 100.0f; + *pval = ((float)_tmp / 100.0f)-2.0; //Manon + log_debug(F("JE SUIS DANS SHT3x!"));log_flush(); return true; } @@ -310,7 +310,8 @@ void SHT3x::sw_reset( uint8_t adr ) { * multiple (useless) access for same things. */ bool SHT3x::_readSensor( uint16_t *pval ) { - + log_debug(F(millis()));log_flush(); + log_debug(F(_lastMsRead));log_flush(); // do we need to acquire fresh sensors values ? if( (millis() - _lastMsRead ) >= (unsigned long)(SHT3X_SENSOR_CACHE_MS) ) { @@ -374,7 +375,7 @@ bool SHT3x::_readSensor( uint16_t *pval ) { _lastMsRead = millis(); } else { - log_debug(F("\n[SHT3x] using cached value for ")); + log_debug(F("\n[SHT3x] using cache value for ")); if( _measureType == sht3xMeasureType_t::temperature ) { log_debug(F("TEMP sensor!")); } @@ -385,8 +386,14 @@ bool SHT3x::_readSensor( uint16_t *pval ) { } // send back pointer to proper value - if( _measureType == sht3xMeasureType_t::temperature ) *pval = _t_sensor; - else *pval = _rh_sensor; + if( _measureType == sht3xMeasureType_t::temperature ) { + *pval = ((float)(int32_t)_t_sensor / 100.0f)-2.0; + //manon + log_debug(F("COUCOU"));log_flush(); + + }else{ + *pval = _rh_sensor; + } return true; } diff --git a/neosensor/libraries/neocampus_drivers/generic_driver.cpp b/neosensor/libraries/neocampus_drivers/generic_driver.cpp index 33559266..39d2c9dc 100644 --- a/neosensor/libraries/neocampus_drivers/generic_driver.cpp +++ b/neosensor/libraries/neocampus_drivers/generic_driver.cpp @@ -73,7 +73,7 @@ void generic_driver::powerOFF( void ) { * used for continuous integration for example * */ -void generic_driver::process( uint16_t coolDown, uint8_t decimals ) { +void generic_driver::process( uint16_t coolDown, uint8_t decimals ) { // same time ref for all unsigned long _curTime = millis(); @@ -85,7 +85,7 @@ void generic_driver::process( uint16_t coolDown, uint8_t decimals ) { float val; if( acquire(&val)==false ) return; // data was not ready _lastMsRead = _curTime; - + // round acquired value decimals = ( decimals > _MAX_DATA_DECIMALS ? _MAX_DATA_DECIMALS : decimals ); if( decimals==0 ) { @@ -152,7 +152,6 @@ bool generic_driver::getTrigger( void ) { * get official value that has gone through the whole integration process */ float generic_driver::getValue( uint8_t *idx ) { - // regular case or first value required if( !idx or *idx==0 ) return value; diff --git a/neosensor/libraries/neocampus_drivers/generic_driver.h b/neosensor/libraries/neocampus_drivers/generic_driver.h index 61d9d5df..7cc3e62f 100644 --- a/neosensor/libraries/neocampus_drivers/generic_driver.h +++ b/neosensor/libraries/neocampus_drivers/generic_driver.h @@ -112,15 +112,12 @@ class generic_driver { float valueSent; // official value that has been sent unsigned long _lastMsSent; // (ms) time the official value has been sent - - //Manon - float a; // Calibration ax+b - //Manon - float b; // Calibration ax+b - //Manon - //float setA(enum_t typeModule); //je ne sais pas du tout si c'est juste ou pas //Manon + //float setA(enum_t typeModule); //float setB(enum_t typeModule); + //Manon + float _a = 1.0; // Calibration ax+b + float _b = -2.0; // Calibration ax+b }; #endif /* _GENERIC_DRIVER_H_ */ diff --git a/neosensor/libraries/neocampus_modules/airquality.cpp b/neosensor/libraries/neocampus_modules/airquality.cpp index ab2c2671..a2b505c0 100644 --- a/neosensor/libraries/neocampus_modules/airquality.cpp +++ b/neosensor/libraries/neocampus_modules/airquality.cpp @@ -30,6 +30,9 @@ #include "airquality.h" +//Manon +//#include "neocampus_utils.h" + /* * Definitons @@ -448,15 +451,17 @@ void airquality::_process_sensors( void ) { * Check for +/- switch status: * if both active then calibrate the current sensor */ + #if 0 #ifdef DECR_SW #ifdef INCR_SW - if( checkCALIBRATIONswitch(DECR_SW, INCR_SW) == true ) { + //if( checkCALIBRATIONswitch(DECR_SW, INCR_SW) == true ) { // CALIBRATION of the sensor - log_debug(F("[Calibration] Deviation value ="));log_debug(calibrate(cur_sensor),FLOAT_RESOLUTION); log_flush(); - } + //log_debug(F("[airquality][Calibration] Deviation value = "));log_debug(calibrate(cur_sensor),FLOAT_RESOLUTION); log_flush(); + //} #endif #endif - //Fin Manon + #endif + /* * update shared JSON with ALL sensors that may have changed ! @@ -634,13 +639,13 @@ boolean airquality::_loadConfig( JsonObject root ) { //Manon /* ------------------------------------------------------------------------------ * Protected methods - */ -/* + * + * * Update the value of a and b of the sensor */ float airquality::calibrate(uint8_t _sensor) { - /* not implemented yet */ - std::cout << "[Calibration] AirQuality sensor detected" << std::endl; + // not implemented yet + log_debug(F("[airquality][Calibration] method calibrate : AirQuality sensor detected")); return 0; } diff --git a/neosensor/libraries/neocampus_modules/airquality.h b/neosensor/libraries/neocampus_modules/airquality.h index ae061dab..5077b9d6 100644 --- a/neosensor/libraries/neocampus_modules/airquality.h +++ b/neosensor/libraries/neocampus_modules/airquality.h @@ -27,8 +27,6 @@ #include "pm_serial.h" // particule meters with serial link: includes PMSx003, SDS011, sensirion SPS30 ... #include "SCD4x.h" // Sensirion SCD4X CO2 sensor including temp + hygro - - /* * Definitions */ @@ -85,18 +83,13 @@ class airquality : public base { void _process_sensors( void ); // sensors internal processing (optional) void _constructor( void ); // low-level constructor - //Manon - /* - * private attributes - */ - typeModule typeM = AIRQUALITY ; - + //Manon protected: - //Manon /* * protected methods */ float calibrate(uint8_t _sensor); + }; diff --git a/neosensor/libraries/neocampus_modules/base.h b/neosensor/libraries/neocampus_modules/base.h index 611bcee7..27417fb4 100644 --- a/neosensor/libraries/neocampus_modules/base.h +++ b/neosensor/libraries/neocampus_modules/base.h @@ -34,9 +34,6 @@ #include "PubSubClient.h" // MQTT client with some definitions from neocampus.h #include "sensocampus.h" -//Manon -#include "typeModule.cpp" -#include "generic_driver.h" /* * Global, shared stuffs @@ -119,13 +116,7 @@ class base { senso *_sensoClient; WiFiClient _wifiClient; PubSubClient mqttClient; - - //Manon - protected: - /* - * protected attributes - */ - typeModule typeM; + }; diff --git a/neosensor/libraries/neocampus_modules/humidity.cpp b/neosensor/libraries/neocampus_modules/humidity.cpp index 870b4702..618a5e97 100644 --- a/neosensor/libraries/neocampus_modules/humidity.cpp +++ b/neosensor/libraries/neocampus_modules/humidity.cpp @@ -29,6 +29,8 @@ #include "humidity.h" +//Manon +//#include "neocampus_utils.h" /* * Definitions @@ -313,15 +315,18 @@ void humidity::_process_sensors( void ) { * Check for +/- switch status: * if both active then calibrate the current sensor */ - //#ifdef DECR_SW - // #ifdef INCR_SW - // if( checkCALIBRATIONswitch(DECR_SW, INCR_SW) == true ) { - // // CALIBRATION of the sensor - // log_debug(F("[Calibration] Deviation value ="));log_debug(calibrate(cur_sensor),FLOAT_RESOLUTION); log_flush(); - // } - // #endif - //#endif - //Fin Manon + #if 0 + #ifdef DECR_SW + #ifdef INCR_SW + log_debug(F("\n[humidity][calibration] TEST :)")); log_flush(); + //if( checkCALIBRATIONswitch(DECR_SW, INCR_SW) == true ) { + // CALIBRATION of the sensor + //log_debug(F("[airquality][Calibration] Deviation value = "));log_debug(calibrate(cur_sensor),FLOAT_RESOLUTION); log_flush(); + //} + #endif + #endif + #endif + // new data ready to get sent ==> activate module's trigger log_debug(F("\n[humidity][")); log_debug(_sensor[cur_sensor]->subID()); @@ -516,12 +521,12 @@ bool humidity::saveConfig( void ) { //Manon /* ------------------------------------------------------------------------------ * Protected methods - */ -/* + * + * * Update the value of a and b of the sensor */ float humidity::calibrate(uint8_t _sensor) { - /* not implemented yet */ - std::cout << "[Calibration] Humidity sensor detected" << std::endl; + // not implemented yet + log_debug(F("[humidity][Calibration] method calibrate : Humidity sensor detected")); return 0; -} \ No newline at end of file +} diff --git a/neosensor/libraries/neocampus_modules/humidity.h b/neosensor/libraries/neocampus_modules/humidity.h index e75d516c..4ff750f5 100644 --- a/neosensor/libraries/neocampus_modules/humidity.h +++ b/neosensor/libraries/neocampus_modules/humidity.h @@ -87,17 +87,13 @@ class humidity : public base { void _process_sensors( void ); // sensors internal processing (optional) void _constructor( void ); // low-level constructor - //Manon - /* - * private attributes - */ - typeModule typeM = HUMIDITY; + //Manon protected: - //Manon /* * protected methods */ float calibrate(uint8_t _sensor); + }; diff --git a/neosensor/libraries/neocampus_modules/luminosity.cpp b/neosensor/libraries/neocampus_modules/luminosity.cpp index 5f1158f5..202d247d 100644 --- a/neosensor/libraries/neocampus_modules/luminosity.cpp +++ b/neosensor/libraries/neocampus_modules/luminosity.cpp @@ -30,6 +30,8 @@ #include "luminosity.h" +//Manon +//#include "neocampus_utils.h" /* * Definitons @@ -292,20 +294,23 @@ void luminosity::_process_sensors( void ) { _sensor[cur_sensor]->process( _freq ); if( _sensor[cur_sensor]->getTrigger()!=true ) continue; -//Manon + //Manon /* * Check for +/- switch status: * if both active then calibrate the current sensor */ + #if 0 #ifdef DECR_SW #ifdef INCR_SW - if( checkCALIBRATIONswitch(DECR_SW, INCR_SW) == true ) { + log_debug(F("\n[luminosity][calibration] TEST :)")); log_flush(); + //if( checkCALIBRATIONswitch(DECR_SW, INCR_SW) == true ) { // CALIBRATION of the sensor - log_debug(F("[Calibration] Deviation value luminosity="));log_debug(calibrate(cur_sensor),FLOAT_RESOLUTION); log_flush(); - } + //log_debug(F("[airquality][Calibration] Deviation value luminosity= "));log_debug(calibrate(cur_sensor),FLOAT_RESOLUTION); log_flush(); + //} #endif #endif - //Fin Manon + #endif + // new data ready to get sent ==> activate module's trigger log_debug(F("\n[luminosity][")); log_debug(_sensor[cur_sensor]->subID()); @@ -501,12 +506,12 @@ bool luminosity::saveConfig( void ) { //Manon /* ------------------------------------------------------------------------------ * Protected methods - */ -/* + * + * * Update the value of a and b of the sensor */ float luminosity::calibrate(uint8_t _sensor) { - /* not implemented yet */ - std::cout << "[Calibration] Luminosity sensor detected" << std::endl; + // not implemented yet + log_debug(F("[luminosity][Calibration] method calibrate : Luminosity sensor detected")); return 0; } \ No newline at end of file diff --git a/neosensor/libraries/neocampus_modules/luminosity.h b/neosensor/libraries/neocampus_modules/luminosity.h index b72be91f..b75f0f2b 100644 --- a/neosensor/libraries/neocampus_modules/luminosity.h +++ b/neosensor/libraries/neocampus_modules/luminosity.h @@ -90,18 +90,12 @@ class luminosity : public base { void _process_sensors( void ); // sensors internal processing (optional) void _constructor( void ); // low-level constructor - //Manon - /* - * private attributes - */ - typeModule typeM = LUMINOSITY; + //Manon protected: - //Manon /* * protected methods */ float calibrate(uint8_t _sensor); - }; diff --git a/neosensor/libraries/neocampus_modules/temperature.cpp b/neosensor/libraries/neocampus_modules/temperature.cpp index 2e1743fb..08d58657 100644 --- a/neosensor/libraries/neocampus_modules/temperature.cpp +++ b/neosensor/libraries/neocampus_modules/temperature.cpp @@ -34,6 +34,8 @@ #include "temperature.h" +//Manon +//#include "neocampus_utils.h" /* * Definitions @@ -334,16 +336,19 @@ void temperature::_process_sensors( void ) { * Check for +/- switch status: * if both active then calibrate the current sensor */ + #if 0 #ifdef DECR_SW #ifdef INCR_SW - log_debug(F("\n[temperature][calibration] L'appui simultanné sur les deux boutons +/- fonctionne :)")); log_flush(); + log_debug(F("\n[temperature][calibration] TEST :)")); log_flush(); //if( checkCALIBRATIONswitch(DECR_SW, INCR_SW) == true ) { + //log_debug(F("\n[temperature][calibration] L'appui simultanné sur les deux boutons +/- fonctionne :)")); log_flush(); // CALIBRATION of the sensor - // log_debug(F("\n[Calibration] Deviation value ="));log_debug(calibrate(cur_sensor),FLOAT_RESOLUTION); log_flush(); + //log_debug(F("\n[Calibration] Deviation value ="));log_debug(calibrate(cur_sensor),FLOAT_RESOLUTION); log_flush(); //} #endif #endif - //Fin Manon + #endif + // new data ready to get sent ==> activate module's trigger log_debug(F("\n[temperature][")); log_debug(_sensor[cur_sensor]->subID()); @@ -540,12 +545,12 @@ bool temperature::saveConfig( void ) { //Manon /* ------------------------------------------------------------------------------ * Protected methods - */ -/* + * + * * Update the value of a and b of the sensor */ float temperature::calibrate(uint8_t _sensor) { - /* not implemented yet */ - std::cout << "[Calibration] Temperature sensor detected" << std::endl; + // not implemented yet + log_debug(F("[temperature][Calibration] method calibrate : Temperature sensor detected")); return 0; -} \ No newline at end of file +} diff --git a/neosensor/libraries/neocampus_modules/temperature.h b/neosensor/libraries/neocampus_modules/temperature.h index d26d59f4..52e1b0c4 100644 --- a/neosensor/libraries/neocampus_modules/temperature.h +++ b/neosensor/libraries/neocampus_modules/temperature.h @@ -91,13 +91,8 @@ class temperature : public base { void _process_sensors( void ); // sensors internal processing (optional) void _constructor( void ); // low-level constructor - //Manon - /* - * private attributes - */ - typeModule typeM = TEMPERATURE; + //Manon protected: - //Manon /* * protected methods */ diff --git a/neosensor/libraries/neocampus_modules/typeModule.cpp b/neosensor/libraries/neocampus_modules/typeModule.cpp index 28ea1dc3..088e997a 100644 --- a/neosensor/libraries/neocampus_modules/typeModule.cpp +++ b/neosensor/libraries/neocampus_modules/typeModule.cpp @@ -1,8 +1,7 @@ -#include <iostream> //Manon enum typeModule { TEMPERATURE, HUMIDITY, AIRQUALITY, LUMINOSITY -}; \ No newline at end of file +}; diff --git a/tests/CalibrationSensor/CalibrationSensor.ino b/tests/CalibrationSensor/CalibrationSensor.ino index 02f36b52..f0eedce8 100644 --- a/tests/CalibrationSensor/CalibrationSensor.ino +++ b/tests/CalibrationSensor/CalibrationSensor.ino @@ -1,4 +1,4 @@ - +#if 0 /* * CalibrationSensor * @@ -125,3 +125,4 @@ void loop() {} +#end \ No newline at end of file -- GitLab