diff --git a/BresserWeatherSensorTTN.ino b/BresserWeatherSensorTTN.ino index e60fe73..29a72e1 100644 --- a/BresserWeatherSensorTTN.ino +++ b/BresserWeatherSensorTTN.ino @@ -89,6 +89,7 @@ // 20230101 Added remote configuration via LoRaWAN downlink // 20230112 Fixed rain gauge update in case RTC was set by LoRaWAN downlink // Added note regarding LMIC_ENABLE_DeviceTimeReq +// 20230121 Added configuration for TTGO LoRa32 V1 // // ToDo: // - @@ -169,11 +170,25 @@ // Pin mapping for ESP32 (MCCI Arduino LoRaWAN Library) // Note: Pin mapping for BresserWeatherSensorReceiver is done in WeatherSensorCfg.h! // SPI2 is used on ESP32 per default! (e.g. see https://github.com/espressif/arduino-esp32/tree/master/variants/doitESP32devkitV1) -#define PIN_LMIC_NSS 14 -#define PIN_LMIC_RST 12 -#define PIN_LMIC_DIO0 4 -#define PIN_LMIC_DIO1 16 -#define PIN_LMIC_DIO2 17 +#if defined(ARDUINO_TTGO_LoRa32_V1) + // https://github.com/espressif/arduino-esp32/blob/master/variants/ttgo-lora32-v1/pins_arduino.h + // http://www.lilygo.cn/prod_view.aspx?TypeId=50003&Id=1130&FId=t3:50003:3 + // https://github.com/Xinyuan-LilyGo/TTGO-LoRa-Series + // https://github.com/LilyGO/TTGO-LORA32/blob/master/schematic1in6.pdf + #define PIN_LMIC_NSS LORA_CS + #define PIN_LMIC_RST LORA_RST + #define PIN_LMIC_DIO0 LORA_IRQ + #define PIN_LMIC_DIO1 33 + #define PIN_LMIC_DIO2 cMyLoRaWAN::lmic_pinmap::LMIC_UNUSED_PIN +#else + // LoRaWAN_Node board + // https://github.com/matthias-bs/LoRaWAN_Node + #define PIN_LMIC_NSS 14 + #define PIN_LMIC_RST 12 + #define PIN_LMIC_DIO0 4 + #define PIN_LMIC_DIO1 16 + #define PIN_LMIC_DIO2 17 +#endif // Uplink message payload size diff --git a/BresserWeatherSensorTTNCfg.h b/BresserWeatherSensorTTNCfg.h index 1d52084..418d0e7 100644 --- a/BresserWeatherSensorTTNCfg.h +++ b/BresserWeatherSensorTTNCfg.h @@ -49,6 +49,7 @@ // ~/Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/ // lmic_project_config.h // in order to be recognized!!! +// 20230121 Added configuration for TTGO LoRa32 V1 // // ToDo: // - @@ -63,6 +64,12 @@ //#define CORE_DEBUG_LEVEL ARDUHAL_LOG_LEVEL_DEBUG //#define CORE_DEBUG_LEVEL ARDUHAL_LOG_LEVEL_VERBOSE +//--- Select Board --- +#ifndef ARDUINO_TTGO_LoRa32_V1 + // Use pinning for LoRaWAN Node + #define LORAWAN_NODE +#endif + //--- Select LoRaWAN Network --- // The Things Network #define ARDUINO_LMIC_CFG_NETWORK_TTN 1 @@ -137,16 +144,24 @@ // ADC for supply/battery voltage measurement // default: on-board connection to VB on FireBeetle ESP32 (with R10+R11 assembled) +// on-board connection to VBAT on TTGO LoRa32 #ifdef ADC_EN - #define PIN_ADC_IN A0 + #if defined(ARDUINO_TTGO_LoRa32_V1) + #define PIN_ADC_IN 35 + #else + #define PIN_ADC_IN A0 + #endif //#define PIN_ADC_IN 34 #endif + // Additional ADC pins (default: FireBeetle ESP32) //#define PIN_ADC0_IN A0 //#define PIN_ADC1_IN A1 //#define PIN_ADC2_IN A2 -#define PIN_ADC3_IN A3 +#ifdef LORAWAN_NODE + #define PIN_ADC3_IN A3 +#endif #ifdef PIN_ADC0_IN // Voltage divider R1 / (R1 + R2) -> V_meas = V(R1 + R2); V_adc = V(R1) @@ -173,7 +188,11 @@ #endif #ifdef ONEWIRE_EN - #define PIN_ONEWIRE_BUS 5 + #if defined(ARDUINO_TTGO_LoRa32_V1) + #define PIN_ONEWIRE_BUS 21 + #else + #define PIN_ONEWIRE_BUS 5 + #endif #endif #ifdef ADC_EN