diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 15bbb0e..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,34 +0,0 @@ -# stages: -# - build -# - test - -# variables: -# PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" -# PLATFORMIO_CACHE_DIR: "$CI_PROJECT_DIR/.cache/platformio" -# ARDUINO_ENV: "megaADK" - -# cache: -# paths: -# - .cache/pip -# - .cache/platformio -# key: "$CI_COMMIT_REF_SLUG" - -# pio_build: -# image: python:latest -# stage: build - -# before_script: -# - pip install -U platformio - -# script: -# - "pio run -e $ARDUINO_ENV" - -# pio_test: -# image: python:latest -# stage: test - -# before_script: -# - pip install -U platformio - -# script: -# - pio test -e $ARDUINO_ENV --without-uploading \ No newline at end of file diff --git a/README.md b/README.md index a599101..105e527 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,27 @@ Verify that platformio has successfully opened the project. Plug the arduino to your PC and check. Run project tests graphically or with `pio test`. Upload the project on the arduino. -Check [RTC update](#rtc-update). +Check [RTC update](#rtc-update). +Make a [Sensor calibration](#sensor-calibration). +Check that **serial_com** is well defined as false (boolean flag used to signal measurement or communication phases). Connect your arduino near of a windows and let him take action. After some time you can bring back the measure from the arduino to your PC. Collect data with [Gather](#gather-measures). +### Sensor calibration +This part aim to optain the measurement range with the lower and the upper threashold of your sensor. +After the electrical mounting, place **print_min_max_res()** in the main loop function from the **SensorManager** object (compile and upload in the arduino). + +Make a scale range by putting place photo sensors in the dark, for exemple with a box (darkest as possible). +Then illuminate photo sensors with the direct lightin sun or a lamp (prefere the brightess as possible). +Once the previous steps are done, write arduino min max serial printed data by print_min_max_res() into min_res and max_res for each sensor. +The soft will normalise your data for compresse them in uint_8 type (smaller information to store). +**TODO:** Improve this description parts + ### RTC update Before build the project, uncoment the `-D DEBUG` line in platform.ini. -Once build-upload done, check the output on the serial port. +Set the [communcation phase](#set-communication-phase) +Once previous steps are done, check the output on the serial port. If the date is wrong, execute the [update time](exec/time.py) file with `python3 time.py `. The code permit a schedule change (winter or summer padding). @@ -41,7 +54,26 @@ You can change the value in the [main file](main.cpp) or simply disable it. ### Gather measures After a measure time. -Connect the arduino to your PC, execute the [download](exec/download_csv.py) file with `python3 download_csv.py` to create a csv from collected data. +Set the [communcation phase](#set-communication-phase) + +Once the upload done, execute the [download](exec/download_csv.py) file with `python3 download_csv.py` to create a csv from collected data. The download action remove whole arduino memory. +### Set communication phase +Connect the arduino to your PC, set **serial_com** boolean to **True**, before uploading make you sure you don't upload when a writing datameasure phase to avoid corrupted data. + + +# Known limitations +## Data structure +- Issue: Storage structure work with **uint_8** measure type but not with other type (First template function doesn't compile and work properly). + +## Nomadic system +- Improvement: Hardward and software are adapted to capture data with plugged into a standard electrical outlet, can be adapted for work with battery and power management. + +## CI pipeline gitlab +- Issue: failed for now, need to find how the serial port of the vm communicate with the pipeline interface + +## Calibration phase +- Improvement: Add an assisted phase to earn upper and lower threshold values to write in the code for the normalisation and storage. + [CI]: https://gitlab.com/Luci_/arduino-photometrics/badges/main/pipeline.svg \ No newline at end of file diff --git a/lib/storage/storage_interface.cpp b/lib/storage/storage_interface.cpp index f43e142..3219dff 100644 --- a/lib/storage/storage_interface.cpp +++ b/lib/storage/storage_interface.cpp @@ -521,8 +521,7 @@ void Storage_interface::upload_csv(){ } Serial.println(close_transfert); - // TODO uncomment after upload csv done and must conform to the tests - // clear_eeprom(); + clear_eeprom(); } diff --git a/platformio.ini b/platformio.ini index a54011f..e498064 100755 --- a/platformio.ini +++ b/platformio.ini @@ -17,11 +17,8 @@ test_framework = unity build_flags = -std=gnu++17 -I lib/ - -D DEBUG + ; -D DEBUG lib_deps = northernwidget/DS3231@^1.1.2 rocketscream/Low-Power@^1.81 - ; arduino-libraries/Ethernet - ; robtillaart/CRC -lib_ldf_mode = deep+ -extra_scripts = pre:test_init.py \ No newline at end of file +lib_ldf_mode = deep+ \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 76d8902..9ee0b0b 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,7 @@ int32_t max_res [nbPhotoSensor] = {2062273, 5554006, 784809, 4755895, 1939035, 2 bool winter = true, timestamping = true, photo_sensor = true, temp_sensor = true, awake = true; // Communication flag, force the arduino to listen the serial port -bool serial_com = true; +bool serial_com = false; // Deep sleep time based on northernwidget/DS3231 lib @@ -47,9 +47,7 @@ void setup() { #endif s_manager.setup(nbPhotoSensor, analogPin); - // sto_intrf.clear_eeprom(); sto_intrf.add_last_package(timestamping, true, photo_sensor, temp_sensor, schedule, nbPhotoSensor, nbTempSensor, photo_sensor_size, temp_sensor_size); - // sto_intrf.clear_eeprom(); alarm_timer(); @@ -71,9 +69,7 @@ void setup() { pinMode(alarm_pin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(alarm_pin), elapsed_time, FALLING); } -#ifdef DEBUG pinMode(LED_BUILTIN, OUTPUT); -#endif } void loop() { @@ -87,8 +83,7 @@ void loop() { state = ~state; digitalWrite(LED_BUILTIN, state); - while(Serial.available() || serial_com){ - // sto_intrf.upload_csv(); + while(serial_com){ if (Serial.available()) { char commande = Serial.read(); if (commande == 'T') { @@ -100,14 +95,14 @@ void loop() { epoch += 3600; } Clock.setEpoch(epoch); - #ifdef DEBUG +#ifdef DEBUG Serial.print("RTC mis à jour avec epoch: "); Serial.println(epoch); - #endif +#endif } while (Serial.available()) Serial.read(); // clean buffer - #ifdef DEBUG +#ifdef DEBUG // Just for verification of DS3231 Data // check now the data from ESP8266 and DS3231 // get year @@ -131,7 +126,7 @@ void loop() { Serial.print(" - weekday "); Serial.print(Clock.getDoW(), DEC); Serial.println(); - #endif +#endif }else if (commande == 'D'){ sto_intrf.upload_csv(); } diff --git a/test_init.py b/test_init.py deleted file mode 100644 index d6788d8..0000000 --- a/test_init.py +++ /dev/null @@ -1,12 +0,0 @@ -# test_init.py - -Import("env") -test_env_name = env["PIOENV"] - -# Injecte manuellement les chemins d'inclusion nécessaires (Unity et votre config) -env.Append( - CPPPATH=[ - "test", - ".pio/libdeps/" + test_env_name + "/Unity/src" - ] -) \ No newline at end of file