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 - + 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 new file mode 100644 index 00000000..c3e2693b --- /dev/null +++ b/examples/ttgo_tdisplay_s3/platformio.ini @@ -0,0 +1,50 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; 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 = ../.. +extra_configs = ../../unified-lib-deps.ini + +[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 = ${commonlibs.lib_deps} + +[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/ttgo_tdisplay_s3/src/main.cpp b/examples/ttgo_tdisplay_s3/src/main.cpp new file mode 100644 index 00000000..f4783b1c --- /dev/null +++ b/examples/ttgo_tdisplay_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 0fb9b2ed..333adb6e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -6,6 +6,7 @@ [platformio] src_dir = ./examples/ lib_dir = ./ +extra_configs = unified-lib-deps.ini [env] framework = arduino @@ -17,29 +18,11 @@ 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} -; 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} 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