From 6da72010a3cd7a37673c4d7907ed23f48213b38c Mon Sep 17 00:00:00 2001 From: Mario Mariete <11509521+melkati@users.noreply.github.com> Date: Fri, 16 Feb 2024 12:00:17 +0100 Subject: [PATCH 01/19] =?UTF-8?q?Fix=20CO2scd30Init()=20function.=20Do=20n?= =?UTF-8?q?ot=20multiply=20scd30.getTemperatureOffset()=20by=20100=20(it?= =?UTF-8?q?=C2=B4s=20already=20in=20hundreths=20of=20a=20degree=20C)=20to?= =?UTF-8?q?=20avoid=20setting=20temperature=20offset=20on=20each=20sensor?= =?UTF-8?q?=20init.=20Do=20sensorRegister(SENSORS::SSCD30)=20prior=20to=20?= =?UTF-8?q?seeting=20offsets.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Sensors.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index d76287bb..b3c7d932 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1586,6 +1586,8 @@ void Sensors::CO2scd30Init() { #endif delay(10); + sensorRegister(SENSORS::SSCD30); + DEBUG("-->[SLIB] SCD30 Temp offset\t:", String(scd30.getTemperatureOffset()).c_str()); DEBUG("-->[SLIB] SCD30 Altitude offset\t:", String(scd30.getAltitudeOffset()).c_str()); @@ -1595,11 +1597,10 @@ void Sensors::CO2scd30Init() { delay(10); } - if (uint16_t((scd30.getTemperatureOffset() * 100)) != (uint16_t(toffset * 100))) { + if (uint16_t((scd30.getTemperatureOffset())) != (uint16_t(toffset * 100))) { setSCD30TempOffset(toffset); delay(10); } - sensorRegister(SENSORS::SSCD30); } /// set SCD30 temperature compensation From 8511eac0b6e2fdbac28f3ebd84d4918c26dc6238 Mon Sep 17 00:00:00 2001 From: Mario Mariete <11509521+melkati@users.noreply.github.com> Date: Fri, 16 Feb 2024 12:19:38 +0100 Subject: [PATCH 02/19] Add debug statement for SCD30 temperature offset in CO2scd30Init() --- src/Sensors.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index b3c7d932..5d932cf9 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1598,6 +1598,7 @@ void Sensors::CO2scd30Init() { } if (uint16_t((scd30.getTemperatureOffset())) != (uint16_t(toffset * 100))) { + DEBUG("-->[SLIB] SCD30 Temp offset to\t:", String(toffset).c_str()); setSCD30TempOffset(toffset); delay(10); } From 4ad57844e7d6b4419461b4cd951dda671436ad3a Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Mon, 19 Feb 2024 10:46:46 +0100 Subject: [PATCH 03/19] added basic example that test the last version in Pio registry --- .github/workflows/platformio.yml | 10 +++++++--- examples/m5atom/platformio.ini | 4 +--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/platformio.yml b/.github/workflows/platformio.yml index c8ade514..dbf401ad 100644 --- a/.github/workflows/platformio.yml +++ b/.github/workflows/platformio.yml @@ -34,12 +34,16 @@ jobs: - name: Basic Arduino IDE example test run: | cd examples/advanced_sensirion - pio run -s - - name: PlatformIO registry test (M5CoreInk project) + pio run + - name: PlatformIO registry backward (M5CoreInk project) run: | git clone https://github.com/hpsaturn/co2_m5coreink.git cd co2_m5coreink - pio run -s + pio run + - name: PlatformIO registry lastest (M5Atom project) + run: | + cd m5atom + pio run - name: All archictures tests run: | pio run diff --git a/examples/m5atom/platformio.ini b/examples/m5atom/platformio.ini index cdd8b02a..a5430515 100644 --- a/examples/m5atom/platformio.ini +++ b/examples/m5atom/platformio.ini @@ -10,8 +10,6 @@ [platformio] src_dir = . -lib_dir = ../.. -extra_configs = ../../unified-lib-deps.ini [env:esp32dev] platform = espressif32 @@ -23,6 +21,6 @@ build_flags = -D CORE_DEBUG_LEVEL=0 -D M5ATOM lib_deps = + hpsaturn/CanAirIO Air Quality Sensors Library @ 0.7.4 fastled/FastLED@^3.5.0 m5stack/M5Atom@^0.0.7 - ${commonlibs.lib_deps} \ No newline at end of file From fbc7da21d80058116c875c09088d19552895033a Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Mon, 19 Feb 2024 11:21:48 +0100 Subject: [PATCH 04/19] fixed path issue on CI test --- .github/workflows/platformio.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/platformio.yml b/.github/workflows/platformio.yml index dbf401ad..3ba1e533 100644 --- a/.github/workflows/platformio.yml +++ b/.github/workflows/platformio.yml @@ -42,7 +42,7 @@ jobs: pio run - name: PlatformIO registry lastest (M5Atom project) run: | - cd m5atom + cd examples/m5atom pio run - name: All archictures tests run: | From 42329340867bc088a6653f97509f18c757cef30d Mon Sep 17 00:00:00 2001 From: Mario Mariete <11509521+melkati@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:45:47 +0100 Subject: [PATCH 05/19] Do sensorRegister(SENSORS::SSCD4x) prior to seeting offsets. --- src/Sensors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 5d932cf9..8984061b 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1629,6 +1629,7 @@ void Sensors::CO2scd4xInit() { scd4x.begin(Wire); error = scd4x.stopPeriodicMeasurement(); if (error) return; + sensorRegister(SENSORS::SSCD4X); scd4x.getTemperatureOffset(tTemperatureOffset); scd4x.getSensorAltitude(tSensorAltitude); DEBUG("-->[SLIB] SCD4x Temp offset\t:", String(tTemperatureOffset).c_str()); @@ -1644,7 +1645,6 @@ void Sensors::CO2scd4xInit() { } error = scd4x.startPeriodicMeasurement(); if (error) DEBUG("[W][SLIB] SCD4x periodic measure\t: starting error:", String(error).c_str()); - sensorRegister(SENSORS::SSCD4X); } /// set SCD4x temperature compensation From 048230530a2057ed968c1d8d5afcadaebb3a4f5e Mon Sep 17 00:00:00 2001 From: Mario Mariete <11509521+melkati@users.noreply.github.com> Date: Tue, 20 Feb 2024 11:05:12 +0100 Subject: [PATCH 06/19] Add temperature offset getter for Sensirion sensors --- src/Sensors.cpp | 37 +++++++++++++++++++++++++++++++++++-- src/Sensors.hpp | 2 ++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 8984061b..4a5bae36 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -355,7 +355,6 @@ void Sensors::tempRegister(bool isCO2temp) { /** * @brief Set temperature offset for all temperature sensors - * @param offset temperature offset in °C (default 0). * * Positive value for offset to be subtracetd to the temperature. */ @@ -366,6 +365,18 @@ void Sensors::setTempOffset(float offset) { setsen5xTempOffset(toffset); } +/** + * @brief Get temperature offset for Sensirion sensors (from internal sensor in SCD4x and SCD30) + * @param offset temperature offset in °C (default 0). + * @return float with the temperature offset. + * Positive value for offset to be subtracetd to the temperature. + */ +float getTempOffset() { + float toffset; + toffset = getSCD30TempOffset(toffset * 100); + toffset = getSCD4xTempOffset(toffset); +} + /// get Gas resistance value of BMP680 sensor float Sensors::getGas() { return gas; } @@ -1612,6 +1623,16 @@ void Sensors::setSCD30TempOffset(float offset) { } } +/// get SCD30 temperature compensation +float Sensors::getSCD30TempOffset() { + float offset = 0.0; + if (isSensorRegistered(SENSORS::SSCD30)) { + offset = scd30.getTemperatureOffset() / 100.0; + Serial.println("-->[SLIB] SCD30 get temp offset\t: " + String(offset)); + } + return offset; +} + /// set SCD30 altitude compensation void Sensors::setSCD30AltitudeOffset(float offset) { if (isSensorRegistered(SENSORS::SSCD30)) { @@ -1640,7 +1661,7 @@ void Sensors::CO2scd4xInit() { offsetDifference = abs((toffset * 100) - (tTemperatureOffset * 100)); if (offsetDifference > 0.5) { // Accounts for SCD4x conversion rounding errors in temperature offset - Serial.println("-->[SLIB] SCD4x new offset\t: Temp offset to" + String(toffset)); + Serial.println("-->[SLIB] SCD4x new offset\t: Temp offset to " + String(toffset)); setSCD4xTempOffset(toffset); } error = scd4x.startPeriodicMeasurement(); @@ -1658,6 +1679,18 @@ void Sensors::setSCD4xTempOffset(float offset) { } } +/// get SCD4x temperature compensation +float Sensors::getSCD4xTempOffset() { + float offset = 0.0; + if (isSensorRegistered(SENSORS::SSCD4X)) { + scd4x.stopPeriodicMeasurement(); + delay(510); + scd4x.getTemperatureOffset(offset); + scd4x.startPeriodicMeasurement(); + Serial.println("-->[SLIB] SCD4x get temperature offset\t: " + String(offset)); + } +} + /// set SCD4x altitude compensation void Sensors::setSCD4xAltitudeOffset(float offset) { if (isSensorRegistered(SENSORS::SSCD4X)) { diff --git a/src/Sensors.hpp b/src/Sensors.hpp index cb048029..c044febf 100644 --- a/src/Sensors.hpp +++ b/src/Sensors.hpp @@ -306,6 +306,8 @@ class Sensors { void setTempOffset(float offset); + float getTempOffset(); + void setCO2AltitudeOffset(float altitude); void setSeaLevelPressure(float hpa); From c18bd12003ec12dee9aa34227f1f9ca1c7d90b66 Mon Sep 17 00:00:00 2001 From: Mario Mariete <11509521+melkati@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:32:04 +0100 Subject: [PATCH 07/19] Fix temperature offset getters for SCD4x and SCD30 sensors --- src/Sensors.cpp | 27 +++++++++++++++++++++------ src/Sensors.hpp | 2 ++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 4a5bae36..3992ac4a 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -373,8 +373,9 @@ void Sensors::setTempOffset(float offset) { */ float getTempOffset() { float toffset; - toffset = getSCD30TempOffset(toffset * 100); - toffset = getSCD4xTempOffset(toffset); + toffset = getSCD30TempOffset(); + toffset = getSCD4xTempOffset(); + return toffset; } /// get Gas resistance value of BMP680 sensor @@ -1682,13 +1683,27 @@ void Sensors::setSCD4xTempOffset(float offset) { /// get SCD4x temperature compensation float Sensors::getSCD4xTempOffset() { float offset = 0.0; + uint16_t error; if (isSensorRegistered(SENSORS::SSCD4X)) { scd4x.stopPeriodicMeasurement(); - delay(510); - scd4x.getTemperatureOffset(offset); - scd4x.startPeriodicMeasurement(); - Serial.println("-->[SLIB] SCD4x get temperature offset\t: " + String(offset)); + if (error) { + DEBUG("[SLIB] SCD4x stopPeriodicMeasurement()\t: error:", String(error).c_str()); + return 0.0; + } else { + DEBUG("[SLIB] SCD4x stopPeriodicMeasurement()\t: done!"); + } + error = scd4x.getTemperatureOffset(offset); + if (error) { + DEBUG("[SLIB] SCD4x get temp offset\t: error:", String(error).c_str()); + return 0.0; + } + error = scd4x.startPeriodicMeasurement(); + if (error) { + DEBUG("[SLIB] SCD4x startPeriodicMeasurement()\t: error:", String(error).c_str()); + return 0.0; + } } + return offset; } /// set SCD4x altitude compensation diff --git a/src/Sensors.hpp b/src/Sensors.hpp index c044febf..8b78ed58 100644 --- a/src/Sensors.hpp +++ b/src/Sensors.hpp @@ -421,6 +421,7 @@ class Sensors { void CO2scd30Init(); void CO2scd30Read(); void setSCD30TempOffset(float offset); + float getSCD30TempOffset(); void setSCD30AltitudeOffset(float offset); void CO2correctionAlt(); float hpaCalculation(float altitude); @@ -428,6 +429,7 @@ class Sensors { void CO2scd4xInit(); void CO2scd4xRead(); void setSCD4xTempOffset(float offset); + float getSCD4xTempOffset(); void setSCD4xAltitudeOffset(float offset); void sen5xInit(); From 93180ee6148d59443ef6e1ac68b605e98df27b13 Mon Sep 17 00:00:00 2001 From: Mario Mariete <11509521+melkati@users.noreply.github.com> Date: Tue, 20 Feb 2024 15:04:19 +0100 Subject: [PATCH 08/19] Fix getTempOffset function declaration in Sensors class --- src/Sensors.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 3992ac4a..33099845 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -367,11 +367,10 @@ void Sensors::setTempOffset(float offset) { /** * @brief Get temperature offset for Sensirion sensors (from internal sensor in SCD4x and SCD30) - * @param offset temperature offset in °C (default 0). * @return float with the temperature offset. * Positive value for offset to be subtracetd to the temperature. */ -float getTempOffset() { +float Sensors::getTempOffset() { float toffset; toffset = getSCD30TempOffset(); toffset = getSCD4xTempOffset(); From 6d188f921afe3e8fad68051f1029759675eafa99 Mon Sep 17 00:00:00 2001 From: Mario Mariete <11509521+melkati@users.noreply.github.com> Date: Wed, 21 Feb 2024 06:45:17 +0100 Subject: [PATCH 09/19] Refactor getTempOffset function to check if sensor is registered --- src/Sensors.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 33099845..65f91946 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -371,9 +371,13 @@ void Sensors::setTempOffset(float offset) { * Positive value for offset to be subtracetd to the temperature. */ float Sensors::getTempOffset() { - float toffset; - toffset = getSCD30TempOffset(); - toffset = getSCD4xTempOffset(); + float toffset = 0.0; + if (isSensorRegistered(SENSORS::SSCD30)) { + toffset = getSCD30TempOffset(); + } + if (isSensorRegistered(SENSORS::SSCD4X)) { + toffset = getSCD4xTempOffset(); + } return toffset; } From cbb19df2534d65fa66a476bb32a9494af9609a2b Mon Sep 17 00:00:00 2001 From: Mario Mariete <11509521+melkati@users.noreply.github.com> Date: Tue, 27 Feb 2024 07:00:50 +0100 Subject: [PATCH 10/19] Add internal temperature offset initialization and retrieval methods --- src/Sensors.cpp | 15 +++++++++++++++ src/Sensors.hpp | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 65f91946..5bed7daf 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -353,6 +353,21 @@ void Sensors::tempRegister(bool isCO2temp) { } } +/** + * @brief Initialize internal temperature offset to be used on startup + * + * Positive value for offset to be subtracetd to the temperature. + * Mush be called before the initialization of the sensors. + */ +void Sensors::initTOffset(float offset) { toffset = offset; } + +/** + * @brief Get sensorlib actual internal temperature offset + * @return float with the temperature offset. + * Positive value for offset to be subtracetd to the temperature. + */ +float Sensors::getTOffset() { return toffset; } + /** * @brief Set temperature offset for all temperature sensors * diff --git a/src/Sensors.hpp b/src/Sensors.hpp index 8b78ed58..be2ce711 100644 --- a/src/Sensors.hpp +++ b/src/Sensors.hpp @@ -304,6 +304,10 @@ class Sensors { float getGeigerMicroSievertHour(void); + void initTOffset(float offset); + + float getTOffset(); + void setTempOffset(float offset); float getTempOffset(); From 97c0d11783e42298b8460a0a92a66154f50d8877 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Thu, 7 Mar 2024 12:46:39 -0500 Subject: [PATCH 11/19] added basic and initial support for M5AirQ SCD40 sensor --- examples/m5airq/platformio.ini | 31 ++++++++++++ examples/m5airq/src/main.cpp | 86 ++++++++++++++++++++++++++++++++++ src/Sensors.cpp | 9 +++- src/Sensors.hpp | 8 ++++ 4 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 examples/m5airq/platformio.ini create mode 100644 examples/m5airq/src/main.cpp diff --git a/examples/m5airq/platformio.ini b/examples/m5airq/platformio.ini new file mode 100644 index 00000000..9024a223 --- /dev/null +++ b/examples/m5airq/platformio.ini @@ -0,0 +1,31 @@ +; 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 = . +lib_dir = ../.. +extra_configs = ../../unified-lib-deps.ini + +[env] +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +build_flags = + -D CORE_DEBUG_LEVEL=0 + -D ARDUINO_USB_CDC_ON_BOOT=1 + -D ARDUINO_ESP32_DEV=1 + -D M5AIRQ=1 +lib_deps = ${commonlibs.lib_deps} + +[env:m5airq] +extends = env +platform = espressif32 +board = esp32-s3-devkitc-1 +board_build.filesystem = littlefs diff --git a/examples/m5airq/src/main.cpp b/examples/m5airq/src/main.cpp new file mode 100644 index 00000000..0dc8e70a --- /dev/null +++ b/examples/m5airq/src/main.cpp @@ -0,0 +1,86 @@ +/** + * @file main.cpp + * @author Antonio Vanegas @hpsaturn + * @date June 2018 - 2024 + * @brief CanAirIO M5AirQ test + * @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 MAIN_HW_EN_PIN 10 // M5AirQ sensor hardware enable + +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 powerEnableSensors() { + Serial.println("-->[POWR] == enable sensors =="); + pinMode(MAIN_HW_EN_PIN, OUTPUT); + digitalWrite(MAIN_HW_EN_PIN, HIGH); // step-up on +} + +void setup() { + Serial.begin(115200); + delay(2000); // Only for debugging + powerEnableSensors(); // M5AirQ enable sensors + delay(100); + Serial.println("\n== Sensor test setup ==\n"); + Serial.println("-->[SETUP] Detecting sensors.."); + + sensors.setSampleTime(10); // config sensors sample time interval + sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback + sensors.setDebugMode(false); // [optional] debug mode + sensors.detectI2COnly(false); // not force to only i2c sensors + sensors.setTemperatureUnit(TEMPUNIT::CELSIUS); // comment for Celsius or set Fahrenheit + sensors.init(); // Auto detection (UART and i2c sensors) + delay(1000); +} + +void loop() { + sensors.loop(); // read sensor data and showed it +} diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 5bed7daf..7e2d65b9 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1956,8 +1956,15 @@ void Sensors::startI2C() { #ifdef M5ATOM enableWire1(); #endif +#ifdef M5AIRQ + Serial.println("-->[SLIB] M5AIRQ I2C enable"); + pinMode(GROVE_SDA, OUTPUT); + pinMode(GROVE_SCL, OUTPUT); + Wire.begin(I2C1_SDA_PIN, I2C1_SCL_PIN); + // enableWire1(); +#endif #if not defined(M5STICKCPLUS) && not defined(M5COREINK) && not defined(M5ATOM) && \ - not defined(ESP32C3) + not defined(ESP32C3) && not defined(M5AIRQ) Wire.begin(); #endif #ifdef ESP32C3 diff --git a/src/Sensors.hpp b/src/Sensors.hpp index be2ce711..30b3a5a5 100644 --- a/src/Sensors.hpp +++ b/src/Sensors.hpp @@ -81,6 +81,14 @@ #define EXT_I2C_SDA 32 #define EXT_I2C_SCL 33 +#ifdef M5AIRQ +#define GROVE_SDA 13 +#define GROVE_SCL 15 + +#define I2C1_SDA_PIN 11 +#define I2C1_SCL_PIN 12 +#endif + // Read UART sensor retry. #define SENSOR_RETRY 1000 // Max Serial characters From e0fa841c8d118b8cb981c4036368c7030a6f8423 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Thu, 7 Mar 2024 13:27:32 -0500 Subject: [PATCH 12/19] removed Wire initialization. The user should do that. Please check! --- src/Sensors.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 7e2d65b9..5a4e60af 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1738,11 +1738,7 @@ void Sensors::setSCD4xAltitudeOffset(float offset) { /// Panasonic SEN5X sensor init void Sensors::sen5xInit() { sensorAnnounce(SENSORS::SSEN5X); -#ifndef Wire1 sen5x.begin(Wire); -#else - sen5x.begin(Wire1); -#endif uint16_t error; error = sen5x.deviceReset(); if (error) return; @@ -1956,17 +1952,6 @@ void Sensors::startI2C() { #ifdef M5ATOM enableWire1(); #endif -#ifdef M5AIRQ - Serial.println("-->[SLIB] M5AIRQ I2C enable"); - pinMode(GROVE_SDA, OUTPUT); - pinMode(GROVE_SCL, OUTPUT); - Wire.begin(I2C1_SDA_PIN, I2C1_SCL_PIN); - // enableWire1(); -#endif -#if not defined(M5STICKCPLUS) && not defined(M5COREINK) && not defined(M5ATOM) && \ - not defined(ESP32C3) && not defined(M5AIRQ) - Wire.begin(); -#endif #ifdef ESP32C3 Wire.begin(19, 18); #endif From ba50613994ed69aa710d4c46088fcdd8bfb8ed43 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Thu, 7 Mar 2024 13:28:00 -0500 Subject: [PATCH 13/19] fixed SEN5X init issue (bad pin level choosed) --- examples/m5airq/platformio.ini | 8 +++++--- examples/m5airq/src/main.cpp | 25 +++++++++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/examples/m5airq/platformio.ini b/examples/m5airq/platformio.ini index 9024a223..5a7a8512 100644 --- a/examples/m5airq/platformio.ini +++ b/examples/m5airq/platformio.ini @@ -21,11 +21,13 @@ build_flags = -D CORE_DEBUG_LEVEL=0 -D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_ESP32_DEV=1 - -D M5AIRQ=1 -lib_deps = ${commonlibs.lib_deps} + -D M5AIRQ=1 ; in your implementation you NEED it (it will improved in the future) +lib_deps = + ${commonlibs.lib_deps} + tanakamasayuki/I2C BM8563 RTC@^1.0.4 [env:m5airq] extends = env platform = espressif32 board = esp32-s3-devkitc-1 -board_build.filesystem = littlefs +board_build.filesystem = littlefs ; compatibility with original demo firmware diff --git a/examples/m5airq/src/main.cpp b/examples/m5airq/src/main.cpp index 0dc8e70a..cabea9d4 100644 --- a/examples/m5airq/src/main.cpp +++ b/examples/m5airq/src/main.cpp @@ -17,8 +17,19 @@ #include #include +#include -#define MAIN_HW_EN_PIN 10 // M5AirQ sensor hardware enable +#define POWER_HOLD 46 // M5AirQ main board +#define SEN55_POWER_EN 10 + +#define GROVE_SDA 13 +#define GROVE_SCL 15 + +#define I2C1_SDA_PIN 11 +#define I2C1_SCL_PIN 12 + + +I2C_BM8563 bm8563(I2C_BM8563_DEFAULT_ADDRESS, Wire); void printSensorsDetected() { uint16_t sensors_count = sensors.getSensorsRegisteredCount(); @@ -60,21 +71,27 @@ void onSensorDataError(const char * msg){ void powerEnableSensors() { Serial.println("-->[POWR] == enable sensors =="); - pinMode(MAIN_HW_EN_PIN, OUTPUT); - digitalWrite(MAIN_HW_EN_PIN, HIGH); // step-up on + pinMode(POWER_HOLD, OUTPUT); + digitalWrite(POWER_HOLD, HIGH); + pinMode(SEN55_POWER_EN, OUTPUT); + digitalWrite(SEN55_POWER_EN, LOW); } void setup() { Serial.begin(115200); delay(2000); // Only for debugging powerEnableSensors(); // M5AirQ enable sensors + Wire.begin(I2C1_SDA_PIN, I2C1_SCL_PIN); + Serial.println("-->[SETUP] RTC(BM8563) init"); + bm8563.begin(); + bm8563.clearIRQ(); delay(100); Serial.println("\n== Sensor test setup ==\n"); Serial.println("-->[SETUP] Detecting sensors.."); sensors.setSampleTime(10); // config sensors sample time interval sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback - sensors.setDebugMode(false); // [optional] debug mode + sensors.setDebugMode(true); // [optional] debug mode sensors.detectI2COnly(false); // not force to only i2c sensors sensors.setTemperatureUnit(TEMPUNIT::CELSIUS); // comment for Celsius or set Fahrenheit sensors.init(); // Auto detection (UART and i2c sensors) From 9b38f52f152df15aaad32932574e8a5549138d08 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Thu, 7 Mar 2024 14:36:44 -0500 Subject: [PATCH 14/19] fixed issue on sen5x read. Added startMeasure call --- examples/m5airq/src/main.cpp | 4 ++-- src/Sensors.cpp | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/examples/m5airq/src/main.cpp b/examples/m5airq/src/main.cpp index cabea9d4..9ecaeab5 100644 --- a/examples/m5airq/src/main.cpp +++ b/examples/m5airq/src/main.cpp @@ -34,7 +34,7 @@ I2C_BM8563 bm8563(I2C_BM8563_DEFAULT_ADDRESS, Wire); 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 detected \t: " + String(sensors_count)); Serial.println("-->[MAIN] Sensors units count \t: " + String(units_count)); Serial.print( "-->[MAIN] Sensors devices names\t: "); int i = 0; @@ -52,7 +52,7 @@ void printSensorsValues() { 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()); + Serial.printf("-->[MAIN] %6s:\t%02.1f\t%s\n", uName.c_str(), uValue, uSymb.c_str()); unit = sensors.getNextUnit(); } } diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 5a4e60af..b4068253 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -66,7 +66,6 @@ bool Sensors::readAllSensors() { } enableWire1(); - sen5xRead(); CO2scd30Read(); GCJA5Read(); sps30Read(); @@ -1068,12 +1067,15 @@ void Sensors::sen5xRead() { massConcentrationPm1p0, massConcentrationPm2p5, massConcentrationPm4p0, massConcentrationPm10p0, ambientHumidity, ambientTemperature, vocIndex, noxIndex); - if (error) return; + if (error) { + DEBUG("[E][SLIB] SEN5x read error!"); + return; + } - pm1 = massConcentrationPm1p0; - pm25 = massConcentrationPm2p5; - pm4 = massConcentrationPm4p0; - pm10 = massConcentrationPm4p0; + pm1 = (u_int16_t) massConcentrationPm1p0; + pm25 = (u_int16_t) massConcentrationPm2p5; + pm4 = (u_int16_t) massConcentrationPm4p0; + pm10 = (u_int16_t) massConcentrationPm4p0; temp = ambientTemperature; humi = ambientHumidity; dataReady = true; @@ -1749,6 +1751,12 @@ void Sensors::sen5xInit() { sen5x.setTemperatureOffsetSimple(toffset); delay(10); } + /** Start Measurement */ + error = sen5x.startMeasurement(); + if (error) { + DEBUG("[E][SLIB] Error trying to execute startMeasurement():"); + return; + } sensorRegister(SENSORS::SSEN5X); } From d19b2dd74fee72d00b4a4d3506185cf726bb213a Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Thu, 7 Mar 2024 14:56:32 -0500 Subject: [PATCH 15/19] clang format and minors refators --- examples/m5airq/src/main.cpp | 113 +++++++++++++++++------------------ src/Sensors.cpp | 5 +- 2 files changed, 56 insertions(+), 62 deletions(-) diff --git a/examples/m5airq/src/main.cpp b/examples/m5airq/src/main.cpp index 9ecaeab5..2f58242d 100644 --- a/examples/m5airq/src/main.cpp +++ b/examples/m5airq/src/main.cpp @@ -4,22 +4,22 @@ * @date June 2018 - 2024 * @brief CanAirIO M5AirQ test * @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 -#include -#define POWER_HOLD 46 // M5AirQ main board +#define POWER_HOLD 46 // M5AirQ main board #define SEN55_POWER_EN 10 #define GROVE_SDA 13 @@ -28,76 +28,71 @@ #define I2C1_SDA_PIN 11 #define I2C1_SCL_PIN 12 - -I2C_BM8563 bm8563(I2C_BM8563_DEFAULT_ADDRESS, Wire); - void printSensorsDetected() { - uint16_t sensors_count = sensors.getSensorsRegisteredCount(); - uint16_t units_count = sensors.getUnitsRegisteredCount(); - Serial.println("-->[MAIN] Sensors detected \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(); + uint16_t sensors_count = sensors.getSensorsRegisteredCount(); + uint16_t units_count = sensors.getUnitsRegisteredCount(); + Serial.println("-->[MAIN] Sensors detected \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] %6s:\t%02.1f\t%s\n", uName.c_str(), uValue, uSymb.c_str()); - unit = sensors.getNextUnit(); - } + 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] %6s:\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(); + Serial.println("======= E X A M P L E T E S T ========="); + printSensorsDetected(); + printSensorsValues(); } -void onSensorDataError(const char * msg){ -} +void onSensorDataError(const char* msg) {} /****************************************************************************** -* M A I N -******************************************************************************/ + * M A I N + ******************************************************************************/ void powerEnableSensors() { - Serial.println("-->[POWR] == enable sensors =="); - pinMode(POWER_HOLD, OUTPUT); - digitalWrite(POWER_HOLD, HIGH); - pinMode(SEN55_POWER_EN, OUTPUT); - digitalWrite(SEN55_POWER_EN, LOW); + Serial.println("-->[POWR] == enable sensors =="); + pinMode(POWER_HOLD, OUTPUT); + digitalWrite(POWER_HOLD, HIGH); + pinMode(SEN55_POWER_EN, OUTPUT); + digitalWrite(SEN55_POWER_EN, LOW); } void setup() { - Serial.begin(115200); - delay(2000); // Only for debugging - powerEnableSensors(); // M5AirQ enable sensors - Wire.begin(I2C1_SDA_PIN, I2C1_SCL_PIN); - Serial.println("-->[SETUP] RTC(BM8563) init"); - bm8563.begin(); - bm8563.clearIRQ(); - delay(100); - Serial.println("\n== Sensor test setup ==\n"); - Serial.println("-->[SETUP] Detecting sensors.."); - - sensors.setSampleTime(10); // config sensors sample time interval - sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback - sensors.setDebugMode(true); // [optional] debug mode - sensors.detectI2COnly(false); // not force to only i2c sensors - sensors.setTemperatureUnit(TEMPUNIT::CELSIUS); // comment for Celsius or set Fahrenheit - sensors.init(); // Auto detection (UART and i2c sensors) - delay(1000); + Serial.begin(115200); + delay(2000); // Only for debugging + powerEnableSensors(); // M5AirQ enable sensors + + Wire.begin(I2C1_SDA_PIN, I2C1_SCL_PIN); + + delay(100); + Serial.println("\n== Sensor test setup ==\n"); + Serial.println("-->[SETUP] Detecting sensors.."); + + sensors.setSampleTime(10); // config sensors sample time interval + sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback + sensors.setDebugMode(true); // [optional] debug mode + sensors.detectI2COnly(false); // not force to only i2c sensors + sensors.setTemperatureUnit(TEMPUNIT::CELSIUS); // comment for Celsius or set Fahrenheit + sensors.init(); // Auto detection (UART and i2c sensors) + delay(1000); } void loop() { - sensors.loop(); // read sensor data and showed it + sensors.loop(); // read sensor data and showed it } diff --git a/src/Sensors.cpp b/src/Sensors.cpp index b4068253..69132360 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1745,13 +1745,12 @@ void Sensors::sen5xInit() { error = sen5x.deviceReset(); if (error) return; float tempOffset = 0.0; - DEBUG("-->[SLIB] SEN5X Temp offset\t:", - String(sen5x.getTemperatureOffsetSimple(tempOffset)).c_str()); + sen5x.getTemperatureOffsetSimple(tempOffset); + DEBUG("-->[SLIB] SEN5X Temp offset\t:", String(tempOffset).c_str()); if (uint16_t((tempOffset * 100)) != (uint16_t(toffset * 100))) { sen5x.setTemperatureOffsetSimple(toffset); delay(10); } - /** Start Measurement */ error = sen5x.startMeasurement(); if (error) { DEBUG("[E][SLIB] Error trying to execute startMeasurement():"); From 130b12671ba5fd82f2bdb95746692728d71d9445 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Thu, 7 Mar 2024 14:57:43 -0500 Subject: [PATCH 16/19] removed unnecesary libraries --- examples/m5airq/platformio.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/m5airq/platformio.ini b/examples/m5airq/platformio.ini index 5a7a8512..2e6a89a5 100644 --- a/examples/m5airq/platformio.ini +++ b/examples/m5airq/platformio.ini @@ -24,7 +24,6 @@ build_flags = -D M5AIRQ=1 ; in your implementation you NEED it (it will improved in the future) lib_deps = ${commonlibs.lib_deps} - tanakamasayuki/I2C BM8563 RTC@^1.0.4 [env:m5airq] extends = env From 540ed6f4b51e308e22380728b714916a0462e020 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Thu, 7 Mar 2024 16:05:17 -0500 Subject: [PATCH 17/19] added missing variables from sen5x sensor. New units: voci and noxi --- src/Sensors.cpp | 14 +++++++++----- src/Sensors.hpp | 6 +++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 69132360..60ee645a 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1070,12 +1070,14 @@ void Sensors::sen5xRead() { if (error) { DEBUG("[E][SLIB] SEN5x read error!"); return; - } + } - pm1 = (u_int16_t) massConcentrationPm1p0; - pm25 = (u_int16_t) massConcentrationPm2p5; - pm4 = (u_int16_t) massConcentrationPm4p0; - pm10 = (u_int16_t) massConcentrationPm4p0; + pm1 = (u_int16_t)massConcentrationPm1p0; + pm25 = (u_int16_t)massConcentrationPm2p5; + pm4 = (u_int16_t)massConcentrationPm4p0; + pm10 = (u_int16_t)massConcentrationPm4p0; + voci = vocIndex; + noxi = noxIndex; temp = ambientTemperature; humi = ambientHumidity; dataReady = true; @@ -1086,6 +1088,8 @@ void Sensors::sen5xRead() { unitRegister(UNIT::PM10); unitRegister(UNIT::TEMP); unitRegister(UNIT::HUM); + unitRegister(UNIT::VOCI); + unitRegister(UNIT::NOXI); } void Sensors::GCJA5Read() { diff --git a/src/Sensors.hpp b/src/Sensors.hpp index 30b3a5a5..069ff234 100644 --- a/src/Sensors.hpp +++ b/src/Sensors.hpp @@ -119,6 +119,8 @@ X(NH3, "ppm", "NH3") \ X(CO, "ppm", "CO") \ X(NO2, "ppm", "NO2") \ + X(NOXI, "noxi", "NOXI") \ + X(VOCI, "voci", "VOCI") \ X(UCOUNT, "COUNT", "UCOUNT") #define X(unit, symbol, name) unit, @@ -399,7 +401,9 @@ class Sensors { float temp = 0.0; // Temperature (°C) float pres = 0.0; // Pressure float alt = 0.0; - float gas = 0.0; // + float gas = 0.0; + float voci = 0.0; + float noxi = 0.0; // temperature unit (C,K,F) TEMPUNIT temp_unit = TEMPUNIT::CELSIUS; From 375a48a8ba3d2b8f1ffb9b58eb3f50addef71044 Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Thu, 7 Mar 2024 16:07:49 -0500 Subject: [PATCH 18/19] fixed some clang issues --- src/Sensors.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sensors.hpp b/src/Sensors.hpp index 069ff234..b0181307 100644 --- a/src/Sensors.hpp +++ b/src/Sensors.hpp @@ -119,8 +119,8 @@ X(NH3, "ppm", "NH3") \ X(CO, "ppm", "CO") \ X(NO2, "ppm", "NO2") \ - X(NOXI, "noxi", "NOXI") \ - X(VOCI, "voci", "VOCI") \ + X(NOXI, "noxi", "NOXI") \ + X(VOCI, "voci", "VOCI") \ X(UCOUNT, "COUNT", "UCOUNT") #define X(unit, symbol, name) unit, From 689712bfd16ceb1b2806465843329c22ca59bd7c Mon Sep 17 00:00:00 2001 From: Hpsaturn Date: Thu, 7 Mar 2024 20:19:37 -0500 Subject: [PATCH 19/19] improved i2c init for M5AIRQ variant --- examples/m5airq/platformio.ini | 2 +- examples/m5airq/src/main.cpp | 12 +++++------- src/Sensors.cpp | 8 ++++++++ src/Sensors.hpp | 1 - 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/examples/m5airq/platformio.ini b/examples/m5airq/platformio.ini index 2e6a89a5..e7785bd0 100644 --- a/examples/m5airq/platformio.ini +++ b/examples/m5airq/platformio.ini @@ -18,7 +18,7 @@ framework = arduino upload_speed = 1500000 monitor_speed = 115200 build_flags = - -D CORE_DEBUG_LEVEL=0 + -D CORE_DEBUG_LEVEL=0 -D ARDUINO_USB_CDC_ON_BOOT=1 -D ARDUINO_ESP32_DEV=1 -D M5AIRQ=1 ; in your implementation you NEED it (it will improved in the future) diff --git a/examples/m5airq/src/main.cpp b/examples/m5airq/src/main.cpp index 2f58242d..91be28f3 100644 --- a/examples/m5airq/src/main.cpp +++ b/examples/m5airq/src/main.cpp @@ -31,8 +31,8 @@ void printSensorsDetected() { uint16_t sensors_count = sensors.getSensorsRegisteredCount(); uint16_t units_count = sensors.getUnitsRegisteredCount(); - Serial.println("-->[MAIN] Sensors detected \t: " + String(sensors_count)); - Serial.println("-->[MAIN] Sensors units count \t: " + String(units_count)); + Serial.println("-->[MAIN] Sensors detected \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) { @@ -43,7 +43,7 @@ void printSensorsDetected() { } void printSensorsValues() { - Serial.println("-->[MAIN] Preview sensor values:"); + Serial.println("-->[MAIN] Preview sensor values :"); UNIT unit = sensors.getNextUnit(); while (unit != UNIT::NUNIT) { String uName = sensors.getUnitName(unit); @@ -78,16 +78,14 @@ void setup() { delay(2000); // Only for debugging powerEnableSensors(); // M5AirQ enable sensors - Wire.begin(I2C1_SDA_PIN, I2C1_SCL_PIN); - delay(100); Serial.println("\n== Sensor test setup ==\n"); Serial.println("-->[SETUP] Detecting sensors.."); sensors.setSampleTime(10); // config sensors sample time interval sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback - sensors.setDebugMode(true); // [optional] debug mode - sensors.detectI2COnly(false); // not force to only i2c sensors + sensors.setDebugMode(false); // [optional] debug mode + sensors.detectI2COnly(true); // not force to only i2c sensors sensors.setTemperatureUnit(TEMPUNIT::CELSIUS); // comment for Celsius or set Fahrenheit sensors.init(); // Auto detection (UART and i2c sensors) delay(1000); diff --git a/src/Sensors.cpp b/src/Sensors.cpp index 60ee645a..d156d88b 100644 --- a/src/Sensors.cpp +++ b/src/Sensors.cpp @@ -1966,6 +1966,10 @@ void Sensors::startI2C() { #ifdef ESP32C3 Wire.begin(19, 18); #endif +#ifdef M5AIRQ + Wire.begin(I2C1_SDA_PIN, I2C1_SCL_PIN); + enableWire1(); +#endif } void Sensors::enableWire1() { @@ -1981,6 +1985,10 @@ void Sensors::enableWire1() { Wire1.flush(); Wire1.begin(26, 32); // M5CoreInk Ext port (default for all sensors) #endif +#ifdef M5AIRQ + Wire1.flush(); + Wire1.begin(GROVE_SDA, GROVE_SCL); +#endif } void Sensors::disableWire1() { diff --git a/src/Sensors.hpp b/src/Sensors.hpp index b0181307..e55937df 100644 --- a/src/Sensors.hpp +++ b/src/Sensors.hpp @@ -84,7 +84,6 @@ #ifdef M5AIRQ #define GROVE_SDA 13 #define GROVE_SCL 15 - #define I2C1_SDA_PIN 11 #define I2C1_SCL_PIN 12 #endif