diff --git a/platformio.ini b/platformio.ini index 7850aa1..a501b7a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -61,6 +61,10 @@ build_flags = -Werror -Wall -DTTGO_T_LORA_V2_1_GPS board = esp32dev build_flags = -Werror -Wall -DESP32_DIY_LoRa_GPS +[env:ESP32_DIY_1W_LoRa_GPS] +board = esp32dev +build_flags = -Werror -Wall -DESP32_DIY_1W_LoRa_GPS + [env:ttgo-t-beam-v1_SX1268] board = ttgo-t-beam build_flags = -Werror -Wall -DTTGO_T_Beam_V1_0_SX1268 diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 0a016ad..c7ad1d3 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -30,11 +30,11 @@ PowerManagement powerManagement; HardwareSerial neo6m_gps(1); TinyGPSPlus gps; BluetoothSerial SerialBT; -#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) +#if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) OneButton userButton = OneButton(BUTTON_PIN, true, true); #endif -String versionDate = "2023.12.07"; +String versionDate = "2023.12.08"; int myBeaconsIndex = 0; int myBeaconsSize = Config.beacons.size(); @@ -137,7 +137,7 @@ void setup() { } if (!Config.simplifiedTrackerMode) { - #if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) + #if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) userButton.attachClick(BUTTON_Utils::singlePress); userButton.attachLongPressStart(BUTTON_Utils::longPress); userButton.attachDoubleClick(BUTTON_Utils::doublePress); @@ -159,7 +159,7 @@ void loop() { powerManagement.batteryManager(); if (!Config.simplifiedTrackerMode) { - #if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) + #if defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) userButton.tick(); #endif } diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index f5d609c..9826578 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -11,7 +11,7 @@ extern logging::Logger logger; extern Configuration Config; -#if defined(TTGO_T_Beam_V1_0_SX1268) +#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) SX1268 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN); bool transmissionFlag = true; bool enableInterrupt = true; @@ -26,7 +26,7 @@ namespace LoRa_Utils { } void setup() { - #if defined(TTGO_T_Beam_V1_0_SX1268) + #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Set SPI pins!"); SPI.begin(RADIO_SCLK_PIN, RADIO_MISO_PIN, RADIO_MOSI_PIN); float freq = (float)Config.loramodule.frequency/1000000; @@ -92,7 +92,7 @@ namespace LoRa_Utils { if (Config.notification.buzzerActive && Config.notification.txBeep) { NOTIFICATION_Utils::beaconTxBeep(); } - #if defined(TTGO_T_Beam_V1_0_SX1268) + #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) //Serial.print("Transmiting... "); int state = radio.transmit("\x3c\xff\x01" + newPacket); if (state == RADIOLIB_ERR_NONE) { @@ -141,7 +141,7 @@ namespace LoRa_Utils { logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa","Receive data: %s", loraPacket.c_str()); } #endif - #if defined(TTGO_T_Beam_V1_0_SX1268) + #if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) if (transmissionFlag) { transmissionFlag = false; radio.startReceive(); diff --git a/src/pins_config.h b/src/pins_config.h index ad24690..fd0c46a 100644 --- a/src/pins_config.h +++ b/src/pins_config.h @@ -15,6 +15,34 @@ #define BUTTON_PIN 38 // The middle button GPIO on the T-Beam #endif +#if defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) +#define GPS_RX 12 +#define GPS_TX 34 +#define BUTTON_PIN -1 +#define LORA_SCK 5 // GPIO5 - SX1276 SCK +#define LORA_MISO 19 // GPIO19 - SX1276 MISO +#define LORA_MOSI 27 // GPIO27 - SX1276 MOSI +#define LORA_CS 18 // GPIO18 - SX1276 CS ----->NSS +#define LORA_RST 23 // GPIO14 - SX1276 RST +#define LORA_IRQ 26 // GPIO26 - SX1276 IRQ ---->DIO0 +//#define greenLed 25 // Green Led +#endif + +#ifdef ESP32_DIY_1W_LoRa_GPS +#define GPS_RX 17 +#define GPS_TX 16 +#define BUTTON_PIN 15 +#define RADIO_SCLK_PIN 18 +#define RADIO_MISO_PIN 19 +#define RADIO_MOSI_PIN 23 +#define RADIO_CS_PIN 5 +#define RADIO_RST_PIN 27 +#define RADIO_DIO1_PIN 12 +#define RADIO_BUSY_PIN 14 +#define RADIO_RXEN 32 +#define RADIO_TXEN 25 +#endif + #if defined(TTGO_T_Beam_V1_0_SX1268) #define RADIO_SCLK_PIN 5 #define RADIO_MISO_PIN 19 @@ -38,17 +66,4 @@ #define BUTTON_PIN -1 #endif -#if defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) -#define GPS_RX 12 // se cambiaran -#define GPS_TX 34 -#define BUTTON_PIN -1 -#define LORA_SCK 5 // GPIO5 - SX1276 SCK -#define LORA_MISO 19 // GPIO19 - SX1276 MISO -#define LORA_MOSI 27 // GPIO27 - SX1276 MOSI -#define LORA_CS 18 // GPIO18 - SX1276 CS ---> NSS -#define LORA_RST 23 // GPIO14 - SX1276 RST -#define LORA_IRQ 26 // GPIO26 - SX1276 IRQ ---->DIO0 -//#define greenLed 25 // Green Led -#endif - #endif \ No newline at end of file diff --git a/src/power_utils.cpp b/src/power_utils.cpp index e29b18c..0160f2b 100644 --- a/src/power_utils.cpp +++ b/src/power_utils.cpp @@ -11,7 +11,7 @@ extern bool disableGPS; // cppcheck-suppress unusedFunction bool PowerManagement::begin(TwoWire &port) { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) return true; // Currently there is no init for V0.7 boards(they only measure battery voltage). #endif #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) @@ -134,7 +134,7 @@ void PowerManagement::deactivateMeasurement() { // cppcheck-suppress unusedFunction double PowerManagement::getBatteryVoltage() { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) // the battery voltage is divided by 2 with two 100kOhm resistors and connected to ADC1 Channel 7 -> pin 35 // the measured voltage is inaccurate du to known nonlinearity and ~100mV offset of the ESP32 A/D converter int adc_value; @@ -156,7 +156,7 @@ double PowerManagement::getBatteryVoltage() { // cppcheck-suppress unusedFunction double PowerManagement::getBatteryChargeDischargeCurrent() { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) return 0; #endif #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) @@ -171,7 +171,7 @@ double PowerManagement::getBatteryChargeDischargeCurrent() { } bool PowerManagement::isBatteryConnected() { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) if(getBatteryVoltage() > 1.0) { return true; } else { @@ -187,7 +187,7 @@ bool PowerManagement::isBatteryConnected() { } bool PowerManagement::isChargeing() { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) return 0; #endif #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) @@ -240,7 +240,7 @@ void PowerManagement::setup() { } void PowerManagement::lowerCpuFrequency() { - #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) + #if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) if (setCpuFrequencyMhz(80)) { logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "CPU frequency set to 80MHz"); } else { @@ -262,7 +262,7 @@ void PowerManagement::obtainBatteryInfo() { if (!(rate_limit_check_battery++ % 60)) BatteryIsConnected = isBatteryConnected(); if (BatteryIsConnected) { - #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) + #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) batteryVoltage = String(getBatteryVoltage(), 2); #endif #ifdef TTGO_T_Beam_V1_2 diff --git a/src/power_utils.h b/src/power_utils.h index 8ca6b2c..d1527c8 100644 --- a/src/power_utils.h +++ b/src/power_utils.h @@ -2,7 +2,7 @@ #define POWER_UTILS_H_ #include -#if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) +#if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA_V2_1_GPS) || defined(TTGO_T_LORA_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) // The V0.7 boards have no power managment components connected to TwoWire. // Battery charging is controlled by a TP5400 IC indepemdetly from the ESP32. // Wire.h must be included to maitain software compatibility with V1.0 and 1.2 boards.