From 6b3576d7e4c5db0f7ae296a0cdbec9d0657d73ce Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sat, 29 Oct 2022 12:42:38 +0200 Subject: [PATCH 1/4] failed test over TDisplay S3 board. (maybe needs LilyGo burned libraries) --- .../advanced_multivariable_s3/platformio.ini | 34 ++++++++ .../advanced_multivariable_s3/src/main.cpp | 82 +++++++++++++++++++ platformio.ini | 25 +++++- prebuild.py | 31 +++++++ 4 files changed, 170 insertions(+), 2 deletions(-) create mode 100644 examples/advanced_multivariable_s3/platformio.ini create mode 100644 examples/advanced_multivariable_s3/src/main.cpp create mode 100755 prebuild.py diff --git a/examples/advanced_multivariable_s3/platformio.ini b/examples/advanced_multivariable_s3/platformio.ini new file mode 100644 index 00000000..df34b985 --- /dev/null +++ b/examples/advanced_multivariable_s3/platformio.ini @@ -0,0 +1,34 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[platformio] +src_dir = . + +[common_env_data] +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +lib_deps = + hpsaturn/CanAirIO Air Quality Sensors Library + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = ${common_env_data.framework} +upload_speed = ${common_env_data.upload_speed} +monitor_speed = ${common_env_data.monitor_speed} +lib_deps = ${common_env_data.lib_deps} + +[env:esp8266] +platform = espressif8266 +board = esp12e +framework = ${common_env_data.framework} +monitor_speed = ${common_env_data.monitor_speed} +lib_deps = ${common_env_data.lib_deps} diff --git a/examples/advanced_multivariable_s3/src/main.cpp b/examples/advanced_multivariable_s3/src/main.cpp new file mode 100644 index 00000000..f4783b1c --- /dev/null +++ b/examples/advanced_multivariable_s3/src/main.cpp @@ -0,0 +1,82 @@ +/** + * @file main.cpp + * @author Antonio Vanegas @hpsaturn + * @date June 2018 - 2022 + * @brief CanAirIO Sensorslib tests + * @license GPL3 + * + * Full documentation: + * https://github.com/kike-canaries/canairio_sensorlib#canairio-air-quality-sensors-library + * + * Full implementation for WiFi and Bluetooth Air Quality fixed and mobile station: + * https://github.com/kike-canaries/canairio_firmware#canairio-firmware + * + * CanAirIO project documentation: + * https://canair.io/docs + */ + +#include +#include + +#define PIN_POWER_ON 15 // T-Display S3 Power pin + +void printSensorsDetected() { + uint16_t sensors_count = sensors.getSensorsRegisteredCount(); + uint16_t units_count = sensors.getUnitsRegisteredCount(); + Serial.println("-->[MAIN] Sensors detected count\t: " + String(sensors_count)); + Serial.println("-->[MAIN] Sensors units count \t: " + String(units_count)); + Serial.print( "-->[MAIN] Sensors devices names\t: "); + int i = 0; + while (sensors.getSensorsRegistered()[i++] != 0) { + Serial.print(sensors.getSensorName((SENSORS)sensors.getSensorsRegistered()[i - 1])); + Serial.print(","); + } + Serial.println(); +} + +void printSensorsValues() { + Serial.println("-->[MAIN] Preview sensor values:"); + UNIT unit = sensors.getNextUnit(); + while(unit != UNIT::NUNIT) { + String uName = sensors.getUnitName(unit); + float uValue = sensors.getUnitValue(unit); + String uSymb = sensors.getUnitSymbol(unit); + Serial.printf("-->[MAIN] %s:\t%02.1f\t%s\n", uName.c_str(), uValue, uSymb.c_str()); + unit = sensors.getNextUnit(); + } +} + +void onSensorDataOk() { + Serial.println("======= E X A M P L E T E S T ========="); + printSensorsDetected(); + printSensorsValues(); +} + +void onSensorDataError(const char * msg){ +} +/****************************************************************************** +* M A I N +******************************************************************************/ + +void setup() { + pinMode(PIN_POWER_ON, OUTPUT); + digitalWrite(PIN_POWER_ON, HIGH); + delay(1000); // Wait on T-Display S3 power on + Serial.begin(115200); + delay(5000); // Wait on T-Display S3 power on + Serial.println("\n== Sensor test setup ==\n"); + Serial.println("-->[SETUP] Detecting sensors.."); + + Wire.begin(43,44); // enable i2c for T-Display S3 board + + sensors.setSampleTime(5); // config sensors sample time interval + sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback + sensors.setDebugMode(true); // [optional] debug mode + sensors.detectI2COnly(true); // disable force to only i2c sensors + sensors.init(); // Auto detection to UART and i2c sensors + delay(500); +} + +void loop() { + sensors.loop(); // read sensor data and showed it +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index d2884b01..abc8ab41 100644 --- a/platformio.ini +++ b/platformio.ini @@ -5,7 +5,7 @@ [platformio] src_dir = ./examples/ -lib_dir = ./ +; lib_dir = ./ [env] framework = arduino @@ -40,10 +40,11 @@ upload_speed = ${env.upload_speed} monitor_speed = ${env.monitor_speed} build_flags = ${env.build_flags} lib_deps = ${env.lib_deps} +extra_scripts = pre:prebuild.py [esp32_common] extends = common -platform = espressif32 +platform = espressif32 @ 5.0.0 board = esp32dev [esp8266_common] @@ -68,8 +69,28 @@ build_src_filter = -<*> + extends = esp32_common build_src_filter = -<*> + +[env:M5STICKCPLUS] +extends = esp32_common +platform = espressif32 @ 4.2.0 +build_src_filter = -<*> + + [env:atmelsam] extends = atmelsam_common build_src_filter = -<*> + +[env:esp32s3] +extends = esp32_common +board = esp32-s3-devkitc-1 +platform = espressif32 @ 5.0.0 +platform_packages = framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#2.0.3 +build_src_filter = -<*> + +lib_deps = + hpsaturn/CanAirIO Air Quality Sensors Library@^0.6.0 + https://github.com/enjoyneering/AHTxx.git#eb21571 + https://github.com/hpsaturn/DHT_nonblocking.git#ec6e5b9 + https://github.com/paulvha/SN-GCJA5.git#f261968 + https://github.com/jcomas/CM1106_UART.git#da0eb4e + + + diff --git a/prebuild.py b/prebuild.py new file mode 100755 index 00000000..cd114568 --- /dev/null +++ b/prebuild.py @@ -0,0 +1,31 @@ +# CanAirIO Project +# Author: @hpsaturn +# pre-build script, setting up build environment + +import os.path +from platformio import util +import shutil +from SCons.Script import DefaultEnvironment + +try: + import configparser +except ImportError: + import ConfigParser as configparser + +# get platformio environment variables +env = DefaultEnvironment() +config = configparser.ConfigParser() +config.read("platformio.ini") + +# get platformio source path +srcdir = env.get("PROJECTSRC_DIR") +flavor = env.get("PIOENV") + +# print ("environment:") +# print (env.Dump()) + +# get runtime credentials and put them to compiler directive +env.Append(BUILD_FLAGS=[ + u'-DFLAVOR=\\"' + flavor + '\\"', + u'-D'+ flavor + '=1' + ]) From 22750db4cabc7b18e524919db131998c7c9ae572 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sun, 29 Jan 2023 13:36:31 +0100 Subject: [PATCH 2/4] upgraded to last esp32c3 branch and fix some issues --- .../advanced_multivariable_s3/platformio.ini | 34 ---------- examples/ttgo_tdisplay_s3/platformio.ini | 66 +++++++++++++++++++ .../src/main.cpp | 0 platformio.ini | 23 +------ prebuild.py | 31 --------- 5 files changed, 67 insertions(+), 87 deletions(-) delete mode 100644 examples/advanced_multivariable_s3/platformio.ini create mode 100644 examples/ttgo_tdisplay_s3/platformio.ini rename examples/{advanced_multivariable_s3 => ttgo_tdisplay_s3}/src/main.cpp (100%) delete mode 100755 prebuild.py diff --git a/examples/advanced_multivariable_s3/platformio.ini b/examples/advanced_multivariable_s3/platformio.ini deleted file mode 100644 index df34b985..00000000 --- a/examples/advanced_multivariable_s3/platformio.ini +++ /dev/null @@ -1,34 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[platformio] -src_dir = . - -[common_env_data] -framework = arduino -upload_speed = 1500000 -monitor_speed = 115200 -lib_deps = - hpsaturn/CanAirIO Air Quality Sensors Library - -[env:esp32dev] -platform = espressif32 -board = esp32dev -framework = ${common_env_data.framework} -upload_speed = ${common_env_data.upload_speed} -monitor_speed = ${common_env_data.monitor_speed} -lib_deps = ${common_env_data.lib_deps} - -[env:esp8266] -platform = espressif8266 -board = esp12e -framework = ${common_env_data.framework} -monitor_speed = ${common_env_data.monitor_speed} -lib_deps = ${common_env_data.lib_deps} diff --git a/examples/ttgo_tdisplay_s3/platformio.ini b/examples/ttgo_tdisplay_s3/platformio.ini new file mode 100644 index 00000000..9ce6f0ab --- /dev/null +++ b/examples/ttgo_tdisplay_s3/platformio.ini @@ -0,0 +1,66 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; CanAirIO Sensors Library +; Author: @hpsaturn +; 20230129 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; Basic multivariable multisensor example for +; TTGO T-Display S3 (LilyGO board). +; +; https://github.com/kike-canaries/canairio_sensorlib + +[platformio] +src_dir = . +lib_dir = ../.. + +[wifi] +ssid = ${sysenv.PIO_WIFI_SSID} +password = ${sysenv.PIO_WIFI_PASSWORD} + +[env] +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +build_flags = + '-DWIFI_SSID="${wifi.ssid}"' + '-DWIFI_PASS="${wifi.password}"' + -D CORE_DEBUG_LEVEL=0 +lib_deps = + adafruit/Adafruit Unified Sensor @ 1.1.7 + adafruit/Adafruit BME280 Library @ 2.2.2 + adafruit/Adafruit BMP280 Library @ 2.6.6 + adafruit/Adafruit BME680 Library @ 2.0.2 + adafruit/Adafruit SHT31 Library @ 2.2.0 + adafruit/Adafruit SCD30 @ 1.0.9 + adafruit/Adafruit BusIO @ 1.14.1 + robtillaart/AM232X @ 0.4.5 + paulvha/sps30 @ 1.4.16 + wifwaf/MH-Z19 @ 1.5.4 + jcomas/S8_UART @ 1.0.1 + sensirion/Sensirion Core @ 0.6.0 + sensirion/Sensirion I2C SCD4x @ 0.3.1 + https://github.com/enjoyneering/AHTxx.git#eb21571 + https://github.com/hpsaturn/DHT_nonblocking.git#ec6e5b9 + https://github.com/paulvha/SN-GCJA5.git#f261968 + https://github.com/jcomas/CM1106_UART.git#da0eb4e + +[env:esp32s3] +framework = ${env.framework} +upload_speed = ${env.upload_speed} +monitor_speed = ${env.monitor_speed} +platform = espressif32 @ 5.0.0 +board = esp32-s3-devkitc-1 +platform_packages = framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#2.0.3 +lib_deps = ${env.lib_deps} +build_flags = + ${env.build_flags} + -DBOARD_HAS_PSRAM + -DARDUINO_USB_MODE=1 + -DARDUINO_USB_CDC_ON_BOOT=1 + +board_build.partitions = default_8MB.csv +board_build.arduino.memory_type = qspi_opi +board_build.flash_size = 8MB +board_build.psram_type = opi + + diff --git a/examples/advanced_multivariable_s3/src/main.cpp b/examples/ttgo_tdisplay_s3/src/main.cpp similarity index 100% rename from examples/advanced_multivariable_s3/src/main.cpp rename to examples/ttgo_tdisplay_s3/src/main.cpp diff --git a/platformio.ini b/platformio.ini index 32e9e18e..062103df 100644 --- a/platformio.ini +++ b/platformio.ini @@ -39,11 +39,10 @@ lib_deps = [common] framework = ${env.framework} -; upload_speed = ${env.upload_speed} +upload_speed = ${env.upload_speed} monitor_speed = ${env.monitor_speed} build_flags = ${env.build_flags} lib_deps = ${env.lib_deps} -extra_scripts = pre:prebuild.py [esp32_common] extends = common @@ -97,28 +96,8 @@ board_build.arduino.memory_type = qspi_opi board_build.flash_size = 8MB board_build.psram_type = opi -[env:M5STICKCPLUS] -extends = esp32_common -platform = espressif32 @ 4.2.0 -build_src_filter = -<*> + - [env:atmelsam] extends = atmelsam_common build_src_filter = -<*> + -[env:esp32s3] -extends = esp32_common -board = esp32-s3-devkitc-1 -platform = espressif32 @ 5.0.0 -platform_packages = framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#2.0.3 -build_src_filter = -<*> + -lib_deps = - hpsaturn/CanAirIO Air Quality Sensors Library@^0.6.0 - https://github.com/enjoyneering/AHTxx.git#eb21571 - https://github.com/hpsaturn/DHT_nonblocking.git#ec6e5b9 - https://github.com/paulvha/SN-GCJA5.git#f261968 - https://github.com/jcomas/CM1106_UART.git#da0eb4e - - - diff --git a/prebuild.py b/prebuild.py deleted file mode 100755 index cd114568..00000000 --- a/prebuild.py +++ /dev/null @@ -1,31 +0,0 @@ -# CanAirIO Project -# Author: @hpsaturn -# pre-build script, setting up build environment - -import os.path -from platformio import util -import shutil -from SCons.Script import DefaultEnvironment - -try: - import configparser -except ImportError: - import ConfigParser as configparser - -# get platformio environment variables -env = DefaultEnvironment() -config = configparser.ConfigParser() -config.read("platformio.ini") - -# get platformio source path -srcdir = env.get("PROJECTSRC_DIR") -flavor = env.get("PIOENV") - -# print ("environment:") -# print (env.Dump()) - -# get runtime credentials and put them to compiler directive -env.Append(BUILD_FLAGS=[ - u'-DFLAVOR=\\"' + flavor + '\\"', - u'-D'+ flavor + '=1' - ]) From 200f0067027681321a9a9488e9a4f41573441d61 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sun, 29 Jan 2023 14:31:58 +0100 Subject: [PATCH 3/4] unified libraries config file for CI tests --- examples/advanced_sensirion/platformio.ini | 22 ++----------------- examples/ttgo_tdisplay_s3/platformio.ini | 20 ++--------------- platformio.ini | 25 ++++------------------ unified-lib-deps.ini | 19 ++++++++++++++++ 4 files changed, 27 insertions(+), 59 deletions(-) create mode 100644 unified-lib-deps.ini diff --git a/examples/advanced_sensirion/platformio.ini b/examples/advanced_sensirion/platformio.ini index c70c80d7..ab502f6a 100644 --- a/examples/advanced_sensirion/platformio.ini +++ b/examples/advanced_sensirion/platformio.ini @@ -11,6 +11,7 @@ [platformio] src_dir = . lib_dir = ../.. +extra_configs = ../../unified-lib-deps.ini [wifi] ssid = ${sysenv.PIO_WIFI_SSID} @@ -24,26 +25,7 @@ build_flags = '-DWIFI_SSID="${wifi.ssid}"' '-DWIFI_PASS="${wifi.password}"' -D CORE_DEBUG_LEVEL=0 -lib_deps = - adafruit/Adafruit Unified Sensor @ 1.1.7 - adafruit/Adafruit BME280 Library @ 2.2.2 - adafruit/Adafruit BMP280 Library @ 2.6.6 - adafruit/Adafruit BME680 Library @ 2.0.2 - adafruit/Adafruit SHT31 Library @ 2.2.0 - adafruit/Adafruit SCD30 @ 1.0.9 - adafruit/Adafruit BusIO @ 1.14.1 - robtillaart/AM232X @ 0.4.5 - paulvha/sps30 @ 1.4.16 - wifwaf/MH-Z19 @ 1.5.4 - jcomas/S8_UART @ 1.0.1 - sensirion/Sensirion Core @ 0.6.0 - sensirion/Sensirion I2C SCD4x @ 0.3.1 - https://github.com/enjoyneering/AHTxx.git#eb21571 - https://github.com/hpsaturn/DHT_nonblocking.git#ec6e5b9 - https://github.com/paulvha/SN-GCJA5.git#f261968 - https://github.com/jcomas/CM1106_UART.git#da0eb4e - - +lib_deps = ${commonlibs.lib_deps} [env:esp32dev] platform = espressif32 diff --git a/examples/ttgo_tdisplay_s3/platformio.ini b/examples/ttgo_tdisplay_s3/platformio.ini index 9ce6f0ab..c3e2693b 100644 --- a/examples/ttgo_tdisplay_s3/platformio.ini +++ b/examples/ttgo_tdisplay_s3/platformio.ini @@ -12,6 +12,7 @@ [platformio] src_dir = . lib_dir = ../.. +extra_configs = ../../unified-lib-deps.ini [wifi] ssid = ${sysenv.PIO_WIFI_SSID} @@ -25,24 +26,7 @@ build_flags = '-DWIFI_SSID="${wifi.ssid}"' '-DWIFI_PASS="${wifi.password}"' -D CORE_DEBUG_LEVEL=0 -lib_deps = - adafruit/Adafruit Unified Sensor @ 1.1.7 - adafruit/Adafruit BME280 Library @ 2.2.2 - adafruit/Adafruit BMP280 Library @ 2.6.6 - adafruit/Adafruit BME680 Library @ 2.0.2 - adafruit/Adafruit SHT31 Library @ 2.2.0 - adafruit/Adafruit SCD30 @ 1.0.9 - adafruit/Adafruit BusIO @ 1.14.1 - robtillaart/AM232X @ 0.4.5 - paulvha/sps30 @ 1.4.16 - wifwaf/MH-Z19 @ 1.5.4 - jcomas/S8_UART @ 1.0.1 - sensirion/Sensirion Core @ 0.6.0 - sensirion/Sensirion I2C SCD4x @ 0.3.1 - https://github.com/enjoyneering/AHTxx.git#eb21571 - https://github.com/hpsaturn/DHT_nonblocking.git#ec6e5b9 - https://github.com/paulvha/SN-GCJA5.git#f261968 - https://github.com/jcomas/CM1106_UART.git#da0eb4e +lib_deps = ${commonlibs.lib_deps} [env:esp32s3] framework = ${env.framework} diff --git a/platformio.ini b/platformio.ini index 062103df..333adb6e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -5,7 +5,8 @@ [platformio] src_dir = ./examples/ -; lib_dir = ./ +lib_dir = ./ +extra_configs = unified-lib-deps.ini [env] framework = arduino @@ -17,25 +18,7 @@ build_flags = ; -D DHT11_ENABLED=1 // Deprecated, please change this old sensor ; -D DHT_SENSOR_TYPE=2 ; -D DHT_SENSOR_PIN=19 -lib_deps = - - adafruit/Adafruit Unified Sensor @ 1.1.7 - adafruit/Adafruit BME280 Library @ 2.2.2 - adafruit/Adafruit BMP280 Library @ 2.6.6 - adafruit/Adafruit BME680 Library @ 2.0.2 - adafruit/Adafruit SHT31 Library @ 2.2.0 - adafruit/Adafruit SCD30 @ 1.0.9 - adafruit/Adafruit BusIO @ 1.14.1 - robtillaart/AM232X @ 0.4.5 - paulvha/sps30 @ 1.4.16 - wifwaf/MH-Z19 @ 1.5.4 - jcomas/S8_UART @ 1.0.1 - sensirion/Sensirion Core @ 0.6.0 - sensirion/Sensirion I2C SCD4x @ 0.3.1 - https://github.com/enjoyneering/AHTxx.git#eb21571 - https://github.com/hpsaturn/DHT_nonblocking.git#ec6e5b9 - https://github.com/paulvha/SN-GCJA5.git#f261968 - https://github.com/jcomas/CM1106_UART.git#da0eb4e +lib_deps = ${commonlibs.lib_deps} [common] framework = ${env.framework} @@ -46,7 +29,7 @@ lib_deps = ${env.lib_deps} [esp32_common] extends = common -platform = espressif32 @ 5.0.0 +platform = espressif32 board = esp32dev [esp8266_common] diff --git a/unified-lib-deps.ini b/unified-lib-deps.ini new file mode 100644 index 00000000..79d5d1eb --- /dev/null +++ b/unified-lib-deps.ini @@ -0,0 +1,19 @@ +[commonlibs] +lib_deps = + adafruit/Adafruit Unified Sensor @ 1.1.7 + adafruit/Adafruit BME280 Library @ 2.2.2 + adafruit/Adafruit BMP280 Library @ 2.6.6 + adafruit/Adafruit BME680 Library @ 2.0.2 + adafruit/Adafruit SHT31 Library @ 2.2.0 + adafruit/Adafruit SCD30 @ 1.0.9 + adafruit/Adafruit BusIO @ 1.14.1 + robtillaart/AM232X @ 0.4.5 + paulvha/sps30 @ 1.4.16 + wifwaf/MH-Z19 @ 1.5.4 + jcomas/S8_UART @ 1.0.1 + sensirion/Sensirion Core @ 0.6.0 + sensirion/Sensirion I2C SCD4x @ 0.3.1 + https://github.com/enjoyneering/AHTxx.git#eb21571 + https://github.com/hpsaturn/DHT_nonblocking.git#ec6e5b9 + https://github.com/paulvha/SN-GCJA5.git#f261968 + https://github.com/jcomas/CM1106_UART.git#da0eb4e \ No newline at end of file From f379ffef248a9082c5bb80b4c276293f91143981 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Sun, 29 Jan 2023 14:36:16 +0100 Subject: [PATCH 4/4] improved CI workflow with complexity from less to more --- .github/workflows/platformio.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/platformio.yml b/.github/workflows/platformio.yml index 598c519b..3b5e9365 100644 --- a/.github/workflows/platformio.yml +++ b/.github/workflows/platformio.yml @@ -27,16 +27,16 @@ jobs: python -m pip install --upgrade pip pip install -U platformio pio pkg update - - name: Submitted library code tests + - name: Basic Arduino IDE example test run: | - pio run - - name: PlatformIO registry test (M5CoreInk example) + cd examples/advanced_sensirion + pio run -s + - name: PlatformIO registry test (M5CoreInk project) run: | git clone https://github.com/hpsaturn/co2_m5coreink.git cd co2_m5coreink - pio run - - name: Arduino IDE example test + pio run -s + - name: All archictures tests run: | - cd examples/advanced_sensirion pio run - +