diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0502b17..e7dfe82 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,6 +23,7 @@ jobs: - esp32:esp32:heltec_wireless_stick:PSRAM=disabled - esp32:esp32:heltec_wifi_lora_32_V2 - esp32:esp32:featheresp32 + - esp32:esp32:m5stack-core2 - esp32:esp32:adafruit_feather_esp32s2 - rp2040:rp2040:adafruit_feather:dbgport=Serial @@ -75,7 +76,7 @@ jobs: #declare -a required_libs=("https://github.com/matthias-bs/BresserWeatherSensorReceiver.git" declare -a required_libs=( "RadioLib@6.4.2" - "BresserWeatherSensorReceiver@0.23.1" + "BresserWeatherSensorReceiver@0.24.0" "MCCI LoRaWAN LMIC library@4.1.1" "MCCI Arduino LoRaWAN Library@0.10.0" "MCCI Arduino Development Kit ADK@0.2.2" @@ -87,7 +88,9 @@ jobs: "NimBLE-Arduino@1.4.1" "ATC_MiThermometer@0.2.1" "TheengsDecoder@1.7.2" - "Preferences@2.1.0") + "Preferences@2.1.0" + "M5Unified@0.1.13" + "M5Core2@0.1.9") for i in "${required_libs[@]}" do arduino-cli lib install "$i" @@ -142,6 +145,7 @@ jobs: # hardcoded fqbn, because 'esp32:esp32@1.0.6' did not work arduino-cli compile --libraries /home/runner/work/BresserWeatherSensorReceiver --fqbn esp32:esp32:esp32${{ steps.prep.outputs.options }} $example --warnings=${{ steps.prep.outputs.warnings }} else + #arduino-cli compile --show-properties --libraries /home/runner/work/BresserWeatherSensorReceiver --fqbn ${{ matrix.board }}${{ steps.prep.outputs.options }} $example --warnings=${{ steps.prep.outputs.warnings }} arduino-cli compile --libraries /home/runner/work/BresserWeatherSensorReceiver --fqbn ${{ matrix.board }}${{ steps.prep.outputs.options }} $example --warnings=${{ steps.prep.outputs.warnings }} fi diff --git a/BresserWeatherSensorTTN.ino b/BresserWeatherSensorTTN.ino index cee4e07..9741042 100644 --- a/BresserWeatherSensorTTN.ino +++ b/BresserWeatherSensorTTN.ino @@ -123,6 +123,7 @@ // (see https://github.com/matthias-bs/BresserWeatherSensorReceiver/releases/tag/v0.5.1) // 20240222 Added weatherSensor.clearSlots() (part of fix for #82), added workaround for (#81) // 20240303 Added evaluation of temp_ok/humidity_ok/rain_ok (#82) +// 20240325 Added configuration for M5Stack Core2 with M5Stack Module LoRa868 // // ToDo: // - Split this file @@ -169,6 +170,9 @@ #include "src/pico_rtc/pico_rtc_utils.h" #include #endif +#if defined(ARDUINO_M5STACK_CORE2) +#include +#endif #ifdef RAINDATA_EN #include "RainGauge.h" @@ -280,6 +284,19 @@ #pragma message("ARDUINO_ADAFRUIT_FEATHER_ESP32 defined; assuming RFM95W FeatherWing will be used") #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS") +#elif defined(ARDUINO_M5STACK_Core2) || defined(ARDUINO_M5STACK_CORE2) + // Note: + // Depending on the environment, selecting M5Stack Core2 defines + // either ARDUINO_M5STACK_Core2 or ARDUINO_M5STACK_CORE2 + // so both variants have to be checked!!! + #define PIN_LMIC_NSS 33 + #define PIN_LMIC_RST 26 + #define PIN_LMIC_DIO0 36 + #define PIN_LMIC_DIO1 35 + #define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN + #pragma message("ARDUINO_M5STACK_CORE2 defined; assuming M5Stack Module LoRa868 will be used") + #pragma message("Required wiring: DIO1 to GPIO35") + #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) // Use pinning for Adafruit Feather RP2040 with RFM95W "FeatherWing" ADA3232 // https://github.com/earlephilhower/arduino-pico/blob/master/variants/adafruit_feather/pins_arduino.h @@ -791,6 +808,16 @@ void setup() { longSleep = ((watchdog_hw->scratch[1] & 2) == 2); rtcLastClockSync = watchdog_hw->scratch[2]; #endif + #if defined(ARDUINO_M5STACK_CORE2) + auto cfg = M5.config(); + cfg.clear_display = true; // default=true. clear the screen when begin. + cfg.output_power = true; // default=true. use external port 5V output. + cfg.internal_imu = false; // default=true. use internal IMU. + cfg.internal_rtc = true; // default=true. use internal RTC. + cfg.internal_spk = false; // default=true. use internal speaker. + cfg.internal_mic = false; // default=true. use internal microphone. + M5.begin(cfg); + #endif // set baud rate Serial.begin(115200); diff --git a/BresserWeatherSensorTTNCfg.h b/BresserWeatherSensorTTNCfg.h index a86e947..a5e0069 100644 --- a/BresserWeatherSensorTTNCfg.h +++ b/BresserWeatherSensorTTNCfg.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // BresserWeatherSensorTTNCfg.h -// +// // User specific configuration for BresserWeatherSensorTTN.ino // // - Enabling or disabling of features @@ -14,17 +14,17 @@ // MIT License // // Copyright (c) 2022 Matthias Prinke -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -40,12 +40,12 @@ // 20221011 Changed timezone handling // 20221113 Fixed ADC defines // 20221117 Enabled FORCE_JOIN_AFTER_SLEEP_TIMEOUT per default -// Added defines for power saving - +// Added defines for power saving - // BATTERY_WEAK, BATTERY_LOW, SLEEP_INTERVAL_LONG // 20221228 Modified DEBUG_PRINTF/DEBUG_PRINTF_TS macros to use // Arduino logging functions // 20221230 Added WEATHERSENSOR_DATA_REQUIRED -// 20220112 Removed LMIC_ENABLE_DeviceTimeReq; must be defined in +// 20220112 Removed LMIC_ENABLE_DeviceTimeReq; must be defined in // ~/Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/ // lmic_project_config.h // in order to be recognized!!! @@ -54,22 +54,28 @@ // Adafruit Feather ESP32-S2 and Adafruit Feather ESP32 // 20230211 Added integration of Theengs Decoder (https://github.com/theengs/decoder) // for support of additional BLE sensors -// 20230217 Added integration of A02YYUW (DFRobot SEN0311) -// ultrasonic distance sensor +// 20230217 Added integration of A02YYUW (DFRobot SEN0311) +// ultrasonic distance sensor // (https://wiki.dfrobot.com/_A02YYUW_Waterproof_Ultrasonic_Sensor_SKU_SEN0311) // 20230714 Added LIGHTNINGSENSOR_EN // 20230927 Added configuration for Adafruit Feather RP2040 // 20231005 Added SESSION_IN_PREFERENCES and NVS_LOG // 20231008 [RP2040] Added configuration for distance sensor // 20231009 Added configuration for FIREBEETLE_COVER_LORA -// Improved config for Firebeetle Cover LoRa and +// Improved config for Firebeetle Cover LoRa and // Adafruit Feather ESP32-S2 (default battery voltage thresholds) // Renamed FIREBEETLE_COVER_LORA in FIREBEETLE_ESP32_COVER_LORA // 20231102 Added ARDUINO_THINGPULSE_EPULSE_FEATHER for special // VBAT voltage divider +// 20240325 Added configuration for M5Stack Core2 with M5Stack Module LoRa868 +// +// Note: +// Depending on the environment, selecting M5Stack Core2 defines +// either ARDUINO_M5STACK_Core2 or ARDUINO_M5STACK_CORE2 +// so both variants have to be checked!!! // // ToDo: -// - +// - // /////////////////////////////////////////////////////////////////////////////// @@ -81,24 +87,25 @@ // For other architectures than ESP32, see logging.h // Enable logging for https://github.com/vshymanskyy/Preferences (used for RP2040) -//#define NVS_LOG +// #define NVS_LOG //--- Select Board --- -#if !defined(ARDUINO_TTGO_LoRa32_V1) && !defined(ARDUINO_TTGO_LoRa32_V2) && \ +#if !defined(ARDUINO_TTGO_LoRa32_V1) && !defined(ARDUINO_TTGO_LoRa32_V2) && \ !defined(ARDUINO_TTGO_LoRa32_v21new) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) && \ - !defined(ARDUINO_FEATHER_ESP32) && !defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) - // Use pinning for LoRaWAN Node - //#define LORAWAN_NODE + !defined(ARDUINO_FEATHER_ESP32) && !defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) && \ + !defined(ARDUINO_M5STACK_Core2) && !defined(ARDUINO_M5STACK_CORE2) +// Use pinning for LoRaWAN Node +#define LORAWAN_NODE - // Use pinning for Firebeetle Cover LoRa - #define FIREBEETLE_ESP32_COVER_LORA +// Use pinning for Firebeetle Cover LoRa +// #define FIREBEETLE_ESP32_COVER_LORA #endif #if defined(ARDUINO_FEATHER_ESP32) - // The Thingpulse ePulse Feather board has the same pinout as - // the Adafruit Feather ESP32 board, but a different VBAT voltage divider! - // See https://github.com/matthias-bs/BresserWeatherSensorTTN/issues/55 - //#define ARDUINO_THINGPULSE_EPULSE_FEATHER +// The Thingpulse ePulse Feather board has the same pinout as +// the Adafruit Feather ESP32 board, but a different VBAT voltage divider! +// See https://github.com/matthias-bs/BresserWeatherSensorTTN/issues/55 +// #define ARDUINO_THINGPULSE_EPULSE_FEATHER #endif //--- Select LoRaWAN Network --- @@ -110,41 +117,43 @@ // (https://github.com/mcci-catena/arduino-lorawan/issues/185) #define ARDUINO_LMIC_CFG_NETWORK_GENERIC 0 -// Enable LORAWAN debug mode - this generates dummy weather data and skips weather sensor reception -//#define LORAWAN_DEBUG +// Enable LORAWAN debug mode - this generates dummy weather data and skips weather sensor reception +// #define LORAWAN_DEBUG -// LoRaWAN session info is stored in RTC RAM on ESP32 and in Preferences (flash) on RP2040 +// LoRaWAN session info is stored in RTC RAM on ESP32 and in Preferences (flash) on RP2040 #if defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) - #define SESSION_IN_PREFERENCES +#define SESSION_IN_PREFERENCES #endif // Battery voltage thresholds for energy saving // If SLEEP_EN is defined and battery voltage <= BATTERY_WEAK [mV], MCU will sleep for SLEEP_INTERVAL_LONG #if defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) - // External voltage divider required - #pragma message("External voltage divider required for battery voltage measurement.") - #pragma message("Setting BATTERY_WEAK 0 (no power-saving).") - #define BATTERY_WEAK 0 +// External voltage divider required +#pragma message("External voltage divider required for battery voltage measurement.") +#pragma message("Setting BATTERY_WEAK 0 (no power-saving).") +#define BATTERY_WEAK 0 #elif defined(FIREBEETLE_ESP32_COVER_LORA) - #pragma message("On-board voltage divider must be enabled for battery voltage measurement (see schematic).") - #pragma message("Setting BATTERY_WEAK 0 (no power-saving).") - #define BATTERY_WEAK 0 +#pragma message("On-board voltage divider must be enabled for battery voltage measurement (see schematic).") +#pragma message("Setting BATTERY_WEAK 0 (no power-saving).") +#define BATTERY_WEAK 0 +#elif defined(ARDUINO_M5STACK_Core2) || defined(ARDUINO_M5STACK_CORE2) +#pragma message("Setting BATTERY_WEAK 0 (no power-saving).") +#define BATTERY_WEAK 0 #else - #define BATTERY_WEAK 3500 +#define BATTERY_WEAK 3500 #endif - // Go to sleep mode immediately after start if battery voltage <= BATTERY_LOW [mV] #if defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) - // External voltage divider required - #pragma message("Setting BATTERY_LOW 0 (no deep-discharge prevention).") - #define BATTERY_LOW 0 -#elif defined(FIREBEETLE_ESP32_COVER_LORA) - #pragma message("Setting BATTERY_LOW 0 (no deep-discharge prevention).") - #define BATTERY_LOW 0 +// External voltage divider required +#pragma message("Setting BATTERY_LOW 0 (no deep-discharge prevention).") +#define BATTERY_LOW 0 +#elif defined(FIREBEETLE_ESP32_COVER_LORA) || defined(ARDUINO_M5STACK_Core2) || defined(ARDUINO_M5STACK_CORE2) +#pragma message("Setting BATTERY_LOW 0 (no deep-discharge prevention).") +#define BATTERY_LOW 0 #else - #define BATTERY_LOW 3200 +#define BATTERY_LOW 3200 #endif // Enable sleep mode - sleep after successful transmission to TTN (recommended!) @@ -178,27 +187,30 @@ #define WEATHERSENSOR_TIMEOUT 180 // If enabled, enter deep sleep mode if receiving weather sensor data was not successful -//#define WEATHERSENSOR_DATA_REQUIRED +// #define WEATHERSENSOR_DATA_REQUIRED // Enable transmission of weather sensor ID -//#define SENSORID_EN +// #define SENSORID_EN // Enable rain data statistics #define RAINDATA_EN +#if !defined(ARDUINO_M5STACK_Core2) && !defined(ARDUINO_M5STACK_CORE2) // Enable battery / supply voltage measurement +// Note: For M5Stack Core2 use 'float batVoltage = M5.Axp.GetBatVoltage();' #define ADC_EN +#endif // Enable OneWire temperature measurement -#define ONEWIRE_EN +// #define ONEWIRE_EN // Enable BLE temperature/humidity measurement -// Notes: +// Notes: // * BLE requires a lot of program memory! // * ESP32-S2 does not provide BLE! #if !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) && !defined(ARDUINO_ARCH_RP2040) - //#define MITHERMOMETER_EN - #define THEENGSDECODER_EN +// #define MITHERMOMETER_EN +#define THEENGSDECODER_EN #endif // Enable Bresser Soil Temperature/Moisture Sensor @@ -208,11 +220,11 @@ #define LIGHTNINGSENSOR_EN // Enter your time zone (https://remotemonitoringsystems.ca/time-zone-abbreviations.php) -const char* TZ_INFO = "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"; +const char *TZ_INFO = "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"; // Enable Ultrasonic Distance Sensor #if defined(LORAWAN_NODE) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) - //#define DISTANCESENSOR_EN +// #define DISTANCESENSOR_EN #endif // ADC for supply/battery voltage measurement @@ -224,94 +236,96 @@ const char* TZ_INFO = "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"; // Adafruit Feather ESP32-S2: no VBAT input circuit // Adafruit Feather RP2040: no VBAT input circuit (connect external divider to A0) #ifdef ADC_EN - #if defined(ARDUINO_TTGO_LoRa32_V1) || defined(ARDUINO_TTGO_LoRa32_V2) || defined(ARDUINO_TTGO_LoRa32_v21new) - #define PIN_ADC_IN 35 - #elif defined(ARDUINO_FEATHER_ESP32) - #define PIN_ADC_IN A13 - #elif defined(LORAWAN_NODE) || defined(FIREBEETLE_ESP32_COVER_LORA) - #define PIN_ADC_IN A0 - #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) - #define PIN_ADC_IN A0 - #else - #define PIN_ADC_IN 34 - #endif +#if defined(ARDUINO_TTGO_LoRa32_V1) || defined(ARDUINO_TTGO_LoRa32_V2) || defined(ARDUINO_TTGO_LoRa32_v21new) +#define PIN_ADC_IN 35 +#elif defined(ARDUINO_FEATHER_ESP32) +#define PIN_ADC_IN A13 +#elif defined(LORAWAN_NODE) || defined(FIREBEETLE_ESP32_COVER_LORA) +#define PIN_ADC_IN A0 +#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) +#define PIN_ADC_IN A0 +#else +#define PIN_ADC_IN 34 +#endif #endif - -// Additional ADC pins (default: FireBeetle ESP32) -//#define PIN_ADC0_IN A0 -//#define PIN_ADC1_IN A1 -//#define PIN_ADC2_IN A2 +// Additional ADC pins (default: FireBeetle ESP32) +// #define PIN_ADC0_IN A0 +// #define PIN_ADC1_IN A1 +// #define PIN_ADC2_IN A2 #ifdef LORAWAN_NODE - #define PIN_ADC3_IN A3 +#define PIN_ADC3_IN A3 #endif #ifdef PIN_ADC0_IN - // Voltage divider R1 / (R1 + R2) -> V_meas = V(R1 + R2); V_adc = V(R1) - const float ADC0_DIV = 0.5; - const uint8_t ADC0_SAMPLES = 10; +// Voltage divider R1 / (R1 + R2) -> V_meas = V(R1 + R2); V_adc = V(R1) +const float ADC0_DIV = 0.5; +const uint8_t ADC0_SAMPLES = 10; #endif #ifdef PIN_ADC1_IN - // Voltage divider R1 / (R1 + R2) -> V_meas = V(R1 + R2); V_adc = V(R1) - const float ADC1_DIV = 0.5; - const uint8_t ADC1_SAMPLES = 10; +// Voltage divider R1 / (R1 + R2) -> V_meas = V(R1 + R2); V_adc = V(R1) +const float ADC1_DIV = 0.5; +const uint8_t ADC1_SAMPLES = 10; #endif #ifdef PIN_ADC2_IN - // Voltage divider R1 / (R1 + R2) -> V_meas = V(R1 + R2); V_adc = V(R1) - const float ADC2_DIV = 0.5; - const uint8_t ADC2_SAMPLES = 10; +// Voltage divider R1 / (R1 + R2) -> V_meas = V(R1 + R2); V_adc = V(R1) +const float ADC2_DIV = 0.5; +const uint8_t ADC2_SAMPLES = 10; #endif #ifdef PIN_ADC3_IN - // Voltage divider R1 / (R1 + R2) -> V_meas = V(R1 + R2); V_adc = V(R1) - const float ADC3_DIV = 0.5; - const uint8_t ADC3_SAMPLES = 10; +// Voltage divider R1 / (R1 + R2) -> V_meas = V(R1 + R2); V_adc = V(R1) +const float ADC3_DIV = 0.5; +const uint8_t ADC3_SAMPLES = 10; #endif #ifdef ONEWIRE_EN - #if defined(ARDUINO_TTGO_LoRa32_V1) - #define PIN_ONEWIRE_BUS 21 - #elif defined(ARDUINO_FEATHER_ESP32) || defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) - #define PIN_ONEWIRE_BUS 15 - #elif defined(LORAWAN_NODE) || defined(FIREBEETLE_ESP32_COVER_LORA) - #define PIN_ONEWIRE_BUS 5 - #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) - #define PIN_ONEWIRE_BUS 6 - #else - #define PIN_ONEWIRE_BUS 0 - #endif +#if defined(ARDUINO_TTGO_LoRa32_V1) +#define PIN_ONEWIRE_BUS 21 +#elif defined(ARDUINO_FEATHER_ESP32) || defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2) +#define PIN_ONEWIRE_BUS 15 +#elif defined(LORAWAN_NODE) || defined(FIREBEETLE_ESP32_COVER_LORA) +#define PIN_ONEWIRE_BUS 5 +#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) +#define PIN_ONEWIRE_BUS 6 +#else +#define PIN_ONEWIRE_BUS 0 +#endif #endif #ifdef DISTANCESENSOR_EN - #if defined(LORAWAN_NODE) - #define DISTANCESENSOR_TX 0 // pull-up/open: processed value / low: real-time value - #define DISTANCESENSOR_RX 26 - #define DISTANCESENSOR_PWR 25 - #define DISTANCESENSOR_RETRIES 5 - #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) - #define DISTANCESENSOR_TX 0 // pull-up/open: processed value / low: real-time value - #define DISTANCESENSOR_RX 1 - #define DISTANCESENSOR_PWR 7 - #define DISTANCESENSOR_RETRIES 8 - #endif +#if defined(LORAWAN_NODE) +#define DISTANCESENSOR_TX 0 // pull-up/open: processed value / low: real-time value +#define DISTANCESENSOR_RX 26 +#define DISTANCESENSOR_PWR 25 +#define DISTANCESENSOR_RETRIES 5 +#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) +#define DISTANCESENSOR_TX 0 // pull-up/open: processed value / low: real-time value +#define DISTANCESENSOR_RX 1 +#define DISTANCESENSOR_PWR 7 +#define DISTANCESENSOR_RETRIES 8 +#endif #endif #ifdef ADC_EN - // Voltage divider R1 / (R1 + R2) -> V_meas = V(R1 + R2); V_adc = V(R1) - #if defined(ARDUINO_THINGPULSE_EPULSE_FEATHER) - const float UBATT_DIV = 0.6812; - #else - const float UBATT_DIV = 0.5; - #endif - const uint8_t UBATT_SAMPLES = 10; +// Voltage divider R1 / (R1 + R2) -> V_meas = V(R1 + R2); V_adc = V(R1) +#if defined(ARDUINO_THINGPULSE_EPULSE_FEATHER) +const float UBATT_DIV = 0.6812; +#else +const float UBATT_DIV = 0.5; +#endif +const uint8_t UBATT_SAMPLES = 10; #endif #if defined(MITHERMOMETER_EN) || defined(THEENGSDECODER_EN) - // BLE scan time in seconds - #define BLE_SCAN_TIME 31 - - // List of known sensors' BLE addresses - #define KNOWN_BLE_ADDRESSES {"a4:c1:38:b8:1f:7f"} +// BLE scan time in seconds +#define BLE_SCAN_TIME 31 + +// List of known sensors' BLE addresses +#define KNOWN_BLE_ADDRESSES \ + { \ + "a4:c1:38:b8:1f:7f" \ + } #endif diff --git a/WeatherSensorCfg.h.template b/WeatherSensorCfg.h.template index c95b7f3..3fc3a05 100644 --- a/WeatherSensorCfg.h.template +++ b/WeatherSensorCfg.h.template @@ -52,7 +52,10 @@ // 20231121 Added Heltec WiFi LoRa32 V3 // 20231130 Bresser 3-in-1 Professional Wind Gauge / Anemometer, PN 7002531: Replaced workaround // for negative temperatures by fix (6-in-1 decoder) -// 20240124 Added RAINGAUGE_USE_PREFS and LIGHTNING_USE_PREFS +// 20231227 Added RAINGAUGE_USE_PREFS and LIGHTNING_USE_PREFS +// 20240122 Modified for unit testing +// 20240204 Added separate ARDUINO_heltec_wireless_stick_v2/v3 +// 20240322 Added pin definitions for M5Stack Core2 with M5Stack Module LoRa868 // // ToDo: // - @@ -74,7 +77,7 @@ //#define SENSOR_IDS_EXC { 0x792882A2 } // List of sensor IDs to be included - if empty, handle all available sensors -#define SENSOR_IDS_INC {} +#define SENSOR_IDS_INC { } //#define SENSOR_IDS_INC { 0x83750871 } // Disable data type which will not be used to save RAM @@ -170,6 +173,12 @@ // This define (not very specific...) is set by selecting "FireBeetle-ESP32" in the Arduino IDE: //#define ARDUINO_ESP32_DEV +// M5Stack Core2 +// https://github.com/espressif/arduino-esp32/blob/master/variants/m5stack_core2/pins_arduino.h +// +// This define is set by selecting "M5Core2" in the Arduino IDE +//#define ARDUINO_M5STACK_CORE2 + #if defined(ARDUINO_TTGO_LoRa32_V1) #pragma message("ARDUINO_TTGO_LoRa32_V1 defined; using on-board transceiver") #define USE_SX1276 @@ -189,6 +198,14 @@ //#define USE_SX1276 // Heltec Wireless Stick V2 #define USE_SX1262 // Heltec Wireless Stick V3 +#elif defined(ARDUINO_heltec_wireless_stick_v2) + #pragma message("ARDUINO_heltec_wireless_stick_v2 defined; using on-board transceiver") + #define USE_SX1276 + +#elif defined(ARDUINO_heltec_wireless_stick_v3) + #pragma message("ARDUINO_heltec_wireless_stick_v3 defined; using on-board transceiver") + #define USE_SX1262 + #elif defined(ARDUINO_heltec_wifi_lora_32_V2) #pragma message("ARDUINO_heltec_wifi_lora_32_V2 defined; using on-board transceiver") #define USE_SX1276 @@ -206,6 +223,11 @@ #define USE_SX1276 #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS") +#elif defined(ARDUINO_M5STACK_CORE2) + #pragma message("ARDUINO_M5STACK_CORE2 defined; assuming M5Stack Module LoRa868 will be used") + #define USE_SX1276 + #pragma message("Required wiring: DIO1 to GPIO35") + #elif defined(ARDUINO_AVR_FEATHER32U4) #pragma message("ARDUINO_AVR_FEATHER32U4 defined; assuming this is the Adafruit Feather 32u4 RFM95 LoRa Radio") #define USE_SX1276 @@ -215,9 +237,9 @@ #define USE_SX1276 #pragma message("Required wiring: A to RST, B to DIO1, D to DIO0, E to CS") -#elif defined(ARDUINO_ESP32_DEV) - //#define LORAWAN_NODE - #define FIREBEETLE_ESP32_COVER_LORA +#elif defined(ARDUINO_ESP32_DEV) || defined(ARDUINO_DFROBOT_FIREBEETLE_ESP32) + #define LORAWAN_NODE + //#define FIREBEETLE_ESP32_COVER_LORA #if defined(FIREBEETLE_ESP32_COVER_LORA) #pragma message("FIREBEETLE_ESP32_COVER_LORA defined; assuming this is a FireBeetle ESP32 with FireBeetle Cover LoRa") @@ -479,6 +501,19 @@ // RFM95W/SX127x - GPIOxx / CC1101 - RADIOLIB_NC #define PIN_RECEIVER_RST 27 +#elif defined(ARDUINO_M5STACK_CORE2) + // Use pinning for M5Stack Core2 with M5Stack Module LoRa868 + #define PIN_RECEIVER_CS 33 + + // CC1101: GDO0 / RFM95W/SX127x: G0 + #define PIN_RECEIVER_IRQ 36 + + // CC1101: GDO2 / RFM95W/SX127x: G1 + #define PIN_RECEIVER_GPIO 35 + + // RFM95W/SX127x - GPIOxx / CC1101 - RADIOLIB_NC + #define PIN_RECEIVER_RST 26 + #elif defined(ESP32) // Generic pinning for ESP32 development boards #define PIN_RECEIVER_CS 27