From 9742e2510015d3781a992256f03b3682f39122b2 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Tue, 23 Apr 2024 22:25:20 -0400 Subject: [PATCH] sx1276 && 915 added --- README.md | 1 + platformio.ini | 12 +++++++++++- src/LoRa_APRS_iGate.cpp | 4 ++-- src/battery_utils.cpp | 2 +- src/lora_utils.cpp | 16 ++++++++++------ src/pins_config.h | 33 +++++++++++++++------------------ src/utils.cpp | 10 +++++----- src/wifi_utils.cpp | 12 ++++++------ 8 files changed, 51 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 428f1217..ba4153fd 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ ____________________________________________________ ____________________________________________________ ## Timeline (Versions): +- 2024.04.23 T-LoRa32 v1.6/v2.1 with 915MHz support added. - 2024.04.23 ESP32 + 4G/LTE MODEM A7670SA + LoRa (SX1278) support added. - 2024.04.22 Wemos Lolin32 OLED DIY LoRa support added . - 2024.04.21 WEB INSTALLER (thanks Damian SQ2CPA). diff --git a/platformio.ini b/platformio.ini index 508bfb53..b838abfd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -206,4 +206,14 @@ build_flags = lib_deps = ${common.lib_deps} vshymanskyy/TinyGSM@^0.11.7 - vshymanskyy/StreamDebugger@^1.0.1 \ No newline at end of file + vshymanskyy/StreamDebugger@^1.0.1 + +[env:ttgo-lora32-v21-915] +board = ttgo-lora32-v21 +build_flags = + -Werror -Wall + -DTTGO_T_LORA32_V2_1_915 + -DHAS_SX1276 + -DELEGANTOTA_USE_ASYNC_WEBSERVER=1 +lib_deps = + ${common.lib_deps} \ No newline at end of file diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 7ea98560..7ba83756 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -70,8 +70,8 @@ void setup() { #ifdef BATTERY_PIN pinMode(BATTERY_PIN, INPUT); #endif - #ifdef HAS_INTERNAL_LED - pinMode(internalLedPin, OUTPUT); + #ifdef INTERNAL_LED_PIN + pinMode(INTERNAL_LED_PIN, OUTPUT); #endif if (Config.externalVoltageMeasurement) { pinMode(Config.externalVoltagePin, INPUT); diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp index 1f9136ea..da3173a5 100644 --- a/src/battery_utils.cpp +++ b/src/battery_utils.cpp @@ -25,7 +25,7 @@ namespace BATTERY_Utils { int sample; int sampleSum = 0; for (int i = 0; i < 100; i++) { - #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_HTCT62) || defined(HELTEC_V3) || defined(ESP32_DIY_LoRa_A7670) + #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_HTCT62) || defined(HELTEC_V3) || defined(ESP32_DIY_LoRa_A7670) || defined(TTGO_T_LORA32_V2_1_915) sample = analogRead(BATTERY_PIN); #endif #if defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa) diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index e348952d..5388cc93 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -29,6 +29,10 @@ SX1268 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUS SX1278 radio = new Module(RADIO_CS_PIN, RADIO_BUSY_PIN, RADIO_RST_PIN); #endif +#ifdef HAS_SX1276 +SX1276 radio = new Module(RADIO_CS_PIN, RADIO_BUSY_PIN, RADIO_RST_PIN); +#endif + int rssi, freqError; float snr; @@ -48,7 +52,7 @@ namespace LoRa_Utils { Utils::println("Starting LoRa failed!"); while (true); } - #ifdef HAS_SX1278 + #if defined(HAS_SX1278) || defined(HAS_SX1276) radio.setDio0Action(setFlag, RISING); #endif #if defined(HAS_SX1262) || defined(HAS_SX1268) @@ -68,7 +72,7 @@ namespace LoRa_Utils { radio.setRfSwitchPins(RADIO_RXEN, RADIO_TXEN); #endif - #if defined(HAS_SX1278) || ESP32_DIY_1W_LoRa + #if defined(HAS_SX1278) || defined(HAS_SX1276) || ESP32_DIY_1W_LoRa state = radio.setOutputPower(Config.loramodule.power); // max value 20dB for 400M30S as it has Low Noise Amp #endif #if defined(HELTEC_V3) || defined(HELTEC_WS) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) @@ -101,8 +105,8 @@ namespace LoRa_Utils { changeFreqTx(); } - #ifdef HAS_INTERNAL_LED - digitalWrite(internalLedPin, HIGH); + #ifdef INTERNAL_LED_PIN + digitalWrite(INTERNAL_LED_PIN, HIGH); #endif int state = radio.transmit("\x3c\xff\x01" + newPacket); transmissionFlag = true; @@ -120,8 +124,8 @@ namespace LoRa_Utils { Utils::print(F("failed, code ")); Utils::println(String(state)); } - #ifdef HAS_INTERNAL_LED - digitalWrite(internalLedPin, LOW); + #ifdef INTERNAL_LED_PIN + digitalWrite(INTERNAL_LED_PIN, LOW); #endif if (Config.loramodule.txFreq != Config.loramodule.rxFreq) { changeFreqRx(); diff --git a/src/pins_config.h b/src/pins_config.h index 531da8a0..c73df23c 100644 --- a/src/pins_config.h +++ b/src/pins_config.h @@ -9,7 +9,7 @@ // LORA MODULES -#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(ESP32_DIY_LoRa) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0) +#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(ESP32_DIY_LoRa) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_LORA32_V2_1_915) #define RADIO_SCLK_PIN 5 // GPIO5 - SX1278 SCK #define RADIO_MISO_PIN 19 // GPIO19 - SX1278 MISO #define RADIO_MOSI_PIN 27 // GPIO27 - SX1278 MOSI @@ -97,7 +97,7 @@ // OLED -#if defined(TTGO_T_LORA32_V2_1) || defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(OE5HWN_MeshCom) || defined(ESP32_DIY_LoRa_A7670) +#if defined(TTGO_T_LORA32_V2_1) || defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(OE5HWN_MeshCom) || defined(ESP32_DIY_LoRa_A7670) || defined(TTGO_T_LORA32_V2_1_915) #define OLED_SDA 21 #define OLED_SCL 22 #define OLED_RST -1 // Reset pin # (or -1 if sharing Arduino reset pin) @@ -127,35 +127,32 @@ // Leds and other stuff -#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_V3) || defined(HELTEC_WS) || defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa) -#define HAS_INTERNAL_LED -#endif - #ifdef HELTEC_HTCT62 -#define BATTERY_PIN 1 +#define BATTERY_PIN 1 #endif -#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) -#define internalLedPin 25 // Green Led -#define BATTERY_PIN 35 +#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(TTGO_T_LORA32_V2_1_915) +#define INTERNAL_LED_PIN 25 // Green Led +#define BATTERY_PIN 35 #endif #if defined(HELTEC_WS) -#define internalLedPin 35 +#define INTERNAL_LED_PIN 35 #endif #if defined(HELTEC_V3) -#define internalLedPin 35 -#define BATTERY_PIN 1 -#define VExt_CTRL 36 -#define ADC_CTRL 37 +#define INTERNAL_LED_PIN 35 +#define BATTERY_PIN 1 +#define VExt_CTRL 36 +#define ADC_CTRL 37 #endif #if defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa) -#define internalLedPin 2 +#define INTERNAL_LED_PIN 2 #endif #if defined(ESP32_DIY_LoRa_A7670) -#define BATTERY_PIN 35 -#define internalLedPin 13 // 13 for V1.1 and 12 for V1.0 +#define INTERNAL_LED_PIN 13 // 13 for V1.1 and 12 for V1.0 +#define BATTERY_PIN 35 #endif + #ifdef ESP32_C3_DIY_LoRa #define OLED_SDA 8 #define OLED_SCL 9 diff --git a/src/utils.cpp b/src/utils.cpp index fcbc007a..758344d2 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -68,13 +68,13 @@ namespace Utils { void setupDisplay() { setup_display(); - #ifdef HAS_INTERNAL_LED - digitalWrite(internalLedPin,HIGH); + #ifdef INTERNAL_LED_PIN + digitalWrite(INTERNAL_LED_PIN,HIGH); #endif Serial.println("\nStarting Station: " + Config.callsign + " Version: " + versionDate); show_display(" LoRa APRS", "", " ( iGATE & DIGI )", "", "", "Richonguzman / CA2RXU", " " + versionDate, 4000); - #ifdef HAS_INTERNAL_LED - digitalWrite(internalLedPin,LOW); + #ifdef INTERNAL_LED_PIN + digitalWrite(INTERNAL_LED_PIN,LOW); #endif firstLine = Config.callsign; seventhLine = " listening..."; @@ -114,7 +114,7 @@ namespace Utils { beaconPacket += Config.beacon.comment; secondaryBeaconPacket += Config.beacon.comment; - #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_HTCT62) || defined(HELTEC_V3) || defined(ESP32_DIY_LoRa_A7670) + #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_HTCT62) || defined(HELTEC_V3) || defined(ESP32_DIY_LoRa_A7670) || defined(TTGO_T_LORA32_V2_1_915) if (Config.sendBatteryVoltage) { beaconPacket += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V"; secondaryBeaconPacket += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V"; diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp index df7188e4..64e40ef8 100644 --- a/src/wifi_utils.cpp +++ b/src/wifi_utils.cpp @@ -52,13 +52,13 @@ namespace WIFI_Utils { WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str()); while (WiFi.status() != WL_CONNECTED && wifiCounter 10000){ delay(1000); @@ -78,8 +78,8 @@ namespace WIFI_Utils { } } } - #ifdef HAS_INTERNAL_LED - digitalWrite(internalLedPin,LOW); + #ifdef INTERNAL_LED_PIN + digitalWrite(INTERNAL_LED_PIN,LOW); #endif if (WiFi.status() == WL_CONNECTED) { Serial.print("Connected as ");