mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-11-01 03:15:47 +01:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1591d9f7fe | ||
|
|
1747922036 | ||
|
|
37afd9a659 | ||
|
|
f9439704f7 | ||
|
|
9314bf10ba | ||
|
|
a045599df1 | ||
|
|
9930603e99 | ||
|
|
9a8bbc2a99 | ||
|
|
c0d67acffd | ||
|
|
075ed0e6b4 | ||
|
|
8ded0e96df |
No files matched your search
@@ -71,6 +71,8 @@ jobs:
|
||||
chip: esp32s3
|
||||
- name: ttgo_t_beam_s3_SUPREME_v3
|
||||
chip: esp32s3
|
||||
- name: ttgo-t-beam-1W
|
||||
chip: esp32s3
|
||||
- name: ESP32_DIY_LoRa_A7670_SX1278
|
||||
chip: esp32
|
||||
- name: ESP32_DIY_LoRa_A7670_915_SX1276
|
||||
|
||||
@@ -37,7 +37,7 @@ ____________________________________________________
|
||||
|
||||
- TTGO Lilygo LoRa32 LoRa32 V2.1 (V1.6 is the same) and T3S3 V1.2.
|
||||
|
||||
- TTGO T-Beam V1.0 , V1.1, V1.2 (also variations with SX1262 and SX1268 LoRa Modules) and Supreme V3.
|
||||
- TTGO T-Beam V1.0 , V1.1, V1.2 (also variations with SX1262 and SX1268 LoRa Modules), Supreme V3 and T-Beam 1W.
|
||||
|
||||
- T-Deck Plus (and also regular T-Deck with/without GPS).
|
||||
|
||||
@@ -64,6 +64,8 @@ ____________________________________________________
|
||||
<br />
|
||||
|
||||
# Timeline (Versions):
|
||||
- 2026-10-14 T-Beam 1W board added (with fan control and Tx over-temperature protection).
|
||||
- 2026-10-05 Fix for stored XSS in received packets, Wifi warning with bad password, date on Rx packets, mDNS kiss-tnc for phone apps, APRSPacketLib V1.0.10 update.
|
||||
- 2026-09-30 GPS baud rate auto-detection, CAD timeout (packet dropped after 10s of busy channel)
|
||||
- 2026-09-23 APRSPacketLib V1.0.7 update and many code cleaning with this.
|
||||
- 2026-09-17 Real APRS Symbols added to map and TNC2 output as a posibility in TNC mode.
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
"rxSignalBandwidth": 125000,
|
||||
"txActive": false,
|
||||
"txFreq": 433775000,
|
||||
"txSpreadingFactor": 9,
|
||||
"txCodingRate4": 7,
|
||||
"txSpreadingFactor": 12,
|
||||
"txCodingRate4": 5,
|
||||
"txSignalBandwidth": 125000,
|
||||
"power": 20,
|
||||
"cadActive": true
|
||||
|
||||
+12
-12
@@ -1313,10 +1313,10 @@ body{background:var(--msh-bg);color:var(--msh-text);font-family:"Inter",system-u
|
||||
<option value="6">SF6</option>
|
||||
<option value="7">SF7</option>
|
||||
<option value="8">SF8</option>
|
||||
<option value="9" selected>SF9</option>
|
||||
<option value="9">SF9</option>
|
||||
<option value="10">SF10</option>
|
||||
<option value="11">SF11</option>
|
||||
<option value="12">SF12 - Highest sensitivity</option>
|
||||
<option value="12" selected>SF12 - Highest sensitivity</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-6 mt-3">
|
||||
@@ -1335,10 +1335,10 @@ body{background:var(--msh-bg);color:var(--msh-text);font-family:"Inter",system-u
|
||||
<option value="6">SF6</option>
|
||||
<option value="7">SF7</option>
|
||||
<option value="8">SF8</option>
|
||||
<option value="9" selected>SF9</option>
|
||||
<option value="9">SF9</option>
|
||||
<option value="10">SF10</option>
|
||||
<option value="11">SF11</option>
|
||||
<option value="12">SF12 - Highest sensitivity</option>
|
||||
<option value="12" selected>SF12 - Highest sensitivity</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-6 mt-3">
|
||||
@@ -1353,9 +1353,9 @@ body{background:var(--msh-bg);color:var(--msh-text);font-family:"Inter",system-u
|
||||
id="lora.rxCodingRate4"
|
||||
required=""
|
||||
>
|
||||
<option value="5">5</option>
|
||||
<option value="5" selected>5</option>
|
||||
<option value="6">6</option>
|
||||
<option value="7" selected>7</option>
|
||||
<option value="7">7</option>
|
||||
<option value="8">8</option>
|
||||
</select>
|
||||
</div>
|
||||
@@ -1371,9 +1371,9 @@ body{background:var(--msh-bg);color:var(--msh-text);font-family:"Inter",system-u
|
||||
id="lora.txCodingRate4"
|
||||
required=""
|
||||
>
|
||||
<option value="5">5</option>
|
||||
<option value="5" selected>5</option>
|
||||
<option value="6">6</option>
|
||||
<option value="7" selected>7</option>
|
||||
<option value="7">7</option>
|
||||
<option value="8">8</option>
|
||||
</select>
|
||||
</div>
|
||||
@@ -1421,7 +1421,7 @@ body{background:var(--msh-bg);color:var(--msh-text);font-family:"Inter",system-u
|
||||
<label
|
||||
for="lora.power"
|
||||
class="form-label">
|
||||
Power
|
||||
Power <small>(SX127X Max 20dBm / SX126X Max 22dBm)</small>
|
||||
</label>
|
||||
<div class="input-group">
|
||||
<input
|
||||
@@ -1429,8 +1429,8 @@ body{background:var(--msh-bg);color:var(--msh-text);font-family:"Inter",system-u
|
||||
name="lora.power"
|
||||
id="lora.power"
|
||||
placeholder="20"
|
||||
min="0"
|
||||
max="20"
|
||||
min="2"
|
||||
max="22"
|
||||
step="1"
|
||||
class="form-control"
|
||||
required=""
|
||||
@@ -2467,7 +2467,7 @@ body{background:var(--msh-bg);color:var(--msh-text);font-family:"Inter",system-u
|
||||
if(window.fetchReceivedPackets)window.fetchReceivedPackets();
|
||||
});
|
||||
var bi=document.getElementById("buildInfo");
|
||||
if(bi){var h=bi.innerHTML; if(/Version date/i.test(h)){h=h.replace(/(<br\s*\/?>)[\s\S]*?(?=Version date)/i,"$1");bi.innerHTML="Board / Environment = "+h;}}
|
||||
if(bi){var h=bi.innerHTML; if(/Version date/i.test(h)){h=h.replace(/(<br\s*\/?>)[\s\S]*?(?=Version: )/i,"$1");bi.innerHTML="Board / Environment = "+h;}}
|
||||
if(window.loadReceivedPackets){var _o=window.loadReceivedPackets;window.loadReceivedPackets=function(p){if(p&&p.slice){p=p.slice().reverse();}return _o(p);};}
|
||||
})();
|
||||
</script>
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
namespace LoRa_Utils {
|
||||
|
||||
int validPower(int requested);
|
||||
void setup();
|
||||
void sendNewPacket(const String& newPacket);
|
||||
String receivePacketFromSleep();
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 2026 Ricardo Guzman - CA2RXU
|
||||
*
|
||||
* This file is part of LoRa APRS iGate.
|
||||
*
|
||||
* LoRa APRS iGate is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LoRa APRS iGate is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LoRa APRS iGate. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Fan / thermal control adapted from KJ7NYE's LoRa_FieldOps_APRS_Tracker (GPLv3)
|
||||
|
||||
#ifndef THERMAL_UTILS_H_
|
||||
#define THERMAL_UTILS_H_
|
||||
|
||||
#include "board_pinout.h"
|
||||
|
||||
#ifdef FAN_CTRL_PIN
|
||||
|
||||
namespace THERMAL_Utils {
|
||||
|
||||
void setup();
|
||||
void monitor();
|
||||
void onTxStart();
|
||||
void onTxEnd();
|
||||
void turnOffFan();
|
||||
bool isTxBlocked();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+12
-2
@@ -52,6 +52,7 @@ ___________________________________________________________________*/
|
||||
#include "syslog_utils.h"
|
||||
#include "power_utils.h"
|
||||
#include "sleep_utils.h"
|
||||
#include "thermal_utils.h"
|
||||
#include "mqtt_utils.h"
|
||||
#include "lora_utils.h"
|
||||
#include "wifi_utils.h"
|
||||
@@ -68,8 +69,8 @@ ___________________________________________________________________*/
|
||||
#endif
|
||||
|
||||
|
||||
String versionDate = "2026-10-05";
|
||||
String versionNumber = "4.0.2";
|
||||
String versionDate = "2026-10-14";
|
||||
String versionNumber = "4.0.4";
|
||||
Configuration Config;
|
||||
WiFiClient aprsIsClient;
|
||||
WiFiClient mqttClient;
|
||||
@@ -108,6 +109,9 @@ void setup() {
|
||||
}
|
||||
networkManager->setHostName("iGATE-" + Config.callsign);
|
||||
POWER_Utils::setup();
|
||||
#ifdef FAN_CTRL_PIN
|
||||
THERMAL_Utils::setup();
|
||||
#endif
|
||||
Utils::setupDisplay();
|
||||
LoRa_Utils::setup();
|
||||
Utils::validateFreqs();
|
||||
@@ -135,6 +139,9 @@ void loop() {
|
||||
SLEEP_Utils::checkWakeUpFlag();
|
||||
Utils::checkBeaconInterval();
|
||||
STATION_Utils::processOutputPacketBufferUltraEcoMode();
|
||||
#ifdef FAN_CTRL_PIN
|
||||
THERMAL_Utils::monitor();
|
||||
#endif
|
||||
Utils::checkSleepByLowBatteryVoltage(1);
|
||||
SLEEP_Utils::startSleeping();
|
||||
} else {
|
||||
@@ -222,6 +229,9 @@ void loop() {
|
||||
displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
|
||||
#endif
|
||||
|
||||
#ifdef FAN_CTRL_PIN
|
||||
THERMAL_Utils::monitor();
|
||||
#endif
|
||||
Utils::checkRebootTime();
|
||||
Utils::checkSleepByLowBatteryVoltage(1);
|
||||
}
|
||||
|
||||
+54
-21
@@ -28,6 +28,7 @@
|
||||
#include "ntp_utils.h"
|
||||
#include "display.h"
|
||||
#include "utils.h"
|
||||
#include "thermal_utils.h"
|
||||
|
||||
|
||||
extern Configuration Config;
|
||||
@@ -69,6 +70,18 @@ int rssi, freqError;
|
||||
float snr;
|
||||
APRSPacket lastAprsPacket;
|
||||
|
||||
#if defined(HAS_SX1278) || defined(HAS_SX1276)
|
||||
#define CHIP_MIN_POWER 2 // PA_BOOST (below 2 RadioLib switches to RFO, not wired on most modules)
|
||||
#define CHIP_MAX_POWER 20
|
||||
#else // SX1262 / SX1268 / LLCC68
|
||||
#define CHIP_MIN_POWER -9
|
||||
#define CHIP_MAX_POWER 22
|
||||
#endif
|
||||
|
||||
#ifndef RADIO_MAX_POWER // optional per board in board_pinout.h (e.g. 1W PA modules)
|
||||
#define RADIO_MAX_POWER CHIP_MAX_POWER
|
||||
#endif
|
||||
|
||||
|
||||
namespace LoRa_Utils {
|
||||
|
||||
@@ -85,10 +98,21 @@ namespace LoRa_Utils {
|
||||
operationDone = true;
|
||||
}
|
||||
|
||||
int validPower(int requested) {
|
||||
const int maxPower = (RADIO_MAX_POWER < CHIP_MAX_POWER) ? RADIO_MAX_POWER : CHIP_MAX_POWER;
|
||||
int power = constrain(requested, CHIP_MIN_POWER, maxPower);
|
||||
#if defined(HAS_SX1278) || defined(HAS_SX1276)
|
||||
if (power > 17 && power < 20) power = 17; // SX127x PA_BOOST: only 2-17 or 20
|
||||
#endif
|
||||
return power;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
#ifdef RADIO_VCC_PIN // LoRa module power switch (QRP Labs LightGateway, T-Beam 1W)
|
||||
pinMode(RADIO_VCC_PIN, OUTPUT);
|
||||
digitalWrite(RADIO_VCC_PIN, HIGH);
|
||||
#endif
|
||||
#if defined (LIGHTGATEWAY_1_0) || defined(LIGHTGATEWAY_PLUS_1_0)
|
||||
pinMode(RADIO_VCC_PIN,OUTPUT);
|
||||
digitalWrite(RADIO_VCC_PIN,HIGH);
|
||||
loraSPI.begin(RADIO_SCLK_PIN, RADIO_MISO_PIN, RADIO_MOSI_PIN, RADIO_CS_PIN);
|
||||
#else
|
||||
SPI.begin(RADIO_SCLK_PIN, RADIO_MISO_PIN, RADIO_MOSI_PIN);
|
||||
@@ -103,6 +127,8 @@ namespace LoRa_Utils {
|
||||
#endif
|
||||
#if (defined(RADIO_RXEN) && defined(RADIO_TXEN)) // before begin() so RF switch is driven from start (Ebyte E22/E32 1W, QRP Labs LightGateway)
|
||||
radio.setRfSwitchPins(RADIO_RXEN, RADIO_TXEN);
|
||||
#elif defined(RADIO_RXEN) // T-Beam 1W: RXEN = LNA only, DIO2 drives the PA
|
||||
radio.setRfSwitchPins(RADIO_RXEN, RADIOLIB_NC);
|
||||
#endif
|
||||
int state = radio.begin(freq);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
@@ -131,21 +157,17 @@ namespace LoRa_Utils {
|
||||
radio.setBandwidth(signalBandwidth);
|
||||
radio.setCRC(true);
|
||||
|
||||
/*#ifdef SX126X_DIO2_AS_RF_SWITCH
|
||||
radio.setRfSwitchPins(RADIO_RXEN, RADIOLIB_NC);
|
||||
radio.setDio2AsRfSwitch(true);
|
||||
#endif*/
|
||||
|
||||
#ifdef HAS_1W_LORA // Ebyte E22 400M30S (SX1268) / 900M30S (SX1262) / Ebyte E220 400M30S (LLCC68)
|
||||
state = radio.setOutputPower(Config.loramodule.power); // max value 20dB for 1W modules as they have Low Noise Amp
|
||||
radio.setCurrentLimit(140); // to be validated (100 , 120, 140)?
|
||||
#endif
|
||||
int power = validPower(Config.loramodule.power);
|
||||
if (power != Config.loramodule.power) {
|
||||
Utils::println("LoRa power adjusted: " + String(Config.loramodule.power) + " -> " + String(power));
|
||||
}
|
||||
state = radio.setOutputPower(power);
|
||||
if (state != RADIOLIB_ERR_NONE) {
|
||||
Utils::println("LoRa setOutputPower failed! State: " + String(state)); // log and keep going
|
||||
}
|
||||
#if defined(HAS_SX1278) || defined(HAS_SX1276)
|
||||
state = radio.setOutputPower(Config.loramodule.power); // max value 20dB for 400M30S as it has Low Noise Amp
|
||||
radio.setCurrentLimit(120); // OCP ceiling for SX127x: ~120mA needed at +20dBm (not a fixed consumption)
|
||||
#endif
|
||||
#if (defined(HAS_SX1268) || defined(HAS_SX1262)) && !defined(HAS_1W_LORA)
|
||||
state = radio.setOutputPower(Config.loramodule.power + 2); // values available: 10, 17, 22 --> if 20 in tracker_conf.json it will be updated to 22.
|
||||
#else // SX1262 / SX1268 / LLCC68 (also 1W Ebyte E22 / E220 modules)
|
||||
radio.setCurrentLimit(140);
|
||||
#endif
|
||||
|
||||
@@ -156,16 +178,15 @@ namespace LoRa_Utils {
|
||||
#if defined(HAS_TCXO) && !defined(HAS_1W_LORA)
|
||||
radio.setDio2AsRfSwitch();
|
||||
#endif
|
||||
#if defined(TTGO_T_BEAM_1W)
|
||||
radio.setDio2AsRfSwitch(true); // DIO2 drives the 1W PA
|
||||
radio.setPaRampTime(RADIOLIB_SX126X_PA_RAMP_800U); // PA needs >800us to settle (default 200us)
|
||||
#endif
|
||||
#ifdef HAS_TCXO
|
||||
radio.setTCXO(1.8);
|
||||
#endif
|
||||
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
Utils::println("init : LoRa Module ... done!");
|
||||
} else {
|
||||
Utils::println("Starting LoRa failed! State: " + String(state));
|
||||
while (true);
|
||||
}
|
||||
Utils::println("init : LoRa Module ... done!");
|
||||
}
|
||||
|
||||
void changeFreqTx() {
|
||||
@@ -222,6 +243,12 @@ namespace LoRa_Utils {
|
||||
|
||||
void sendNewPacket(const String& newPacket) {
|
||||
if (!Config.loramodule.txActive) return;
|
||||
#ifdef FAN_CTRL_PIN
|
||||
if (THERMAL_Utils::isTxBlocked()) {
|
||||
Utils::println("Thermal: Tx blocked (over-temperature), packet dropped: " + newPacket);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Config.loramodule.txFreq != Config.loramodule.rxFreq) {
|
||||
if (!packetIsBeacon || (packetIsBeacon && Config.beacon.beaconFreq == 1)) {
|
||||
@@ -245,7 +272,13 @@ namespace LoRa_Utils {
|
||||
}
|
||||
|
||||
if (!cadDropped) {
|
||||
#ifdef FAN_CTRL_PIN
|
||||
THERMAL_Utils::onTxStart();
|
||||
#endif
|
||||
int state = radio.transmit("\x3c\xff\x01" + newPacket);
|
||||
#ifdef FAN_CTRL_PIN
|
||||
THERMAL_Utils::onTxEnd();
|
||||
#endif
|
||||
transmitFlag = true;
|
||||
if (state == RADIOLIB_ERR_NONE) {
|
||||
if (Config.syslog.active && networkManager->isConnected()) {
|
||||
|
||||
+7
-8
@@ -66,7 +66,7 @@ namespace POWER_Utils {
|
||||
}
|
||||
|
||||
void vext_ctrl_OFF() {
|
||||
digitalWrite(VEXT_CTRL_PIN, Config.digi.ecoMode == 1 ? VEXT_CTRL_ON_STATE : !VEXT_CTRL_ON_STATE);
|
||||
digitalWrite(VEXT_CTRL_PIN, !VEXT_CTRL_ON_STATE); // always off, regardless of ecoMode
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -111,9 +111,7 @@ namespace POWER_Utils {
|
||||
PMU.enableALDO3();
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HELTEC_WIRELESS_TRACKER
|
||||
adc_ctrl_ON();
|
||||
#endif
|
||||
// HELTEC_WIRELESS_TRACKER: GPS shares Vext (GPIO3) with the TFT, so it follows the display power (not controlled here)
|
||||
//gpsIsActive = true;
|
||||
}
|
||||
|
||||
@@ -129,9 +127,7 @@ namespace POWER_Utils {
|
||||
PMU.disableALDO3();
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HELTEC_WIRELESS_TRACKER
|
||||
adc_ctrl_OFF();
|
||||
#endif
|
||||
// HELTEC_WIRELESS_TRACKER: GPS shares Vext with the TFT, turned off with it (see activateGPS)
|
||||
//gpsIsActive = false;
|
||||
}
|
||||
|
||||
@@ -199,7 +195,10 @@ namespace POWER_Utils {
|
||||
PMU.setDC1Voltage(3300);
|
||||
PMU.enableDC1();
|
||||
#ifdef TTGO_T_Beam_S3_SUPREME_V3
|
||||
PMU.setALDO1Voltage(3300);
|
||||
PMU.setALDO1Voltage(3300); // BME280, QMC6310, QMI8658, OLED
|
||||
PMU.enableALDO1();
|
||||
PMU.setALDO2Voltage(3300); // sensors/OLED I2C + RTC PCF8563 (must stay on)
|
||||
PMU.enableALDO2();
|
||||
#endif
|
||||
PMU.setButtonBatteryChargeVoltage(3300);
|
||||
PMU.enableButtonBatteryCharge();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "sleep_utils.h"
|
||||
#include "digi_utils.h"
|
||||
#include "lora_utils.h"
|
||||
#include "thermal_utils.h"
|
||||
|
||||
|
||||
extern Configuration Config;
|
||||
@@ -75,6 +76,9 @@ namespace SLEEP_Utils {
|
||||
Serial.print("(Sleeping : "); Serial.print(timeToSleep); Serial.println("seconds)");
|
||||
delay(100);
|
||||
LoRa_Utils::wakeRadio();
|
||||
#ifdef FAN_CTRL_PIN
|
||||
THERMAL_Utils::turnOffFan(); // GPIOs keep their level in light sleep
|
||||
#endif
|
||||
esp_light_sleep_start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/* Copyright (C) 2026 Ricardo Guzman - CA2RXU
|
||||
*
|
||||
* This file is part of LoRa APRS iGate.
|
||||
*
|
||||
* LoRa APRS iGate is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LoRa APRS iGate is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LoRa APRS iGate. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Fan / thermal control adapted from KJ7NYE's LoRa_FieldOps_APRS_Tracker (GPLv3)
|
||||
// NTC circuit (T-Beam 1W V1.0 schematic): 3V3 -> NCP18XH103F03RB -> TEMP_PIN -> 10K -> GND
|
||||
|
||||
#include "board_pinout.h"
|
||||
|
||||
#ifdef FAN_CTRL_PIN
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <math.h>
|
||||
#include "thermal_utils.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define NTC_B 3380.0f // B25/50 (K)
|
||||
#define NTC_R25 10000.0f // NTC resistance at 25C (ohm)
|
||||
#define NTC_T0 298.15f // 25C in Kelvin
|
||||
#define NTC_R_FIXED 10000.0f // pull-down resistor (ohm)
|
||||
#define NTC_VCC_MV 3300.0f
|
||||
#define NTC_MIN_VALID_MV 100 // below this the sample is a failed ADC2 read (100mV = ~-45C)
|
||||
|
||||
#define FAN_ON_TEMP 50.0f // fan on at or above
|
||||
#define FAN_OFF_TEMP 42.0f // fan off below (hysteresis)
|
||||
#define TEMP_WARNING 75.0f
|
||||
#define TEMP_TX_BLOCK 85.0f // Tx blocked at or above
|
||||
#define TEMP_TX_UNBLOCK 75.0f // Tx allowed again below (hysteresis)
|
||||
#define TX_COOLDOWN_MS 30000 // fan kept on after TX
|
||||
#define TEMP_SAMPLE_MS 30000
|
||||
|
||||
static float currentTemperature = 25.0f;
|
||||
static bool fanOn = false;
|
||||
static bool txBlocked = false;
|
||||
static bool txCooldownActive = false;
|
||||
static uint32_t txEndTime = 0;
|
||||
static uint32_t lastTempSample = 0;
|
||||
static bool firstTempSample = true;
|
||||
|
||||
|
||||
namespace THERMAL_Utils {
|
||||
|
||||
float readTemperature() { // TEMP_PIN is on ADC2: reads fail (return 0) while Wi-Fi holds the ADC2 arbiter
|
||||
analogReadMilliVolts(TEMP_PIN); // dummy read to settle the ADC
|
||||
delay(1);
|
||||
uint32_t sum = 0;
|
||||
int validSamples = 0;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
uint32_t sample = analogReadMilliVolts(TEMP_PIN);
|
||||
if (sample > NTC_MIN_VALID_MV) {
|
||||
sum += sample;
|
||||
validSamples++;
|
||||
}
|
||||
delay(3);
|
||||
}
|
||||
if (validSamples == 0) return NAN;
|
||||
float mv = (float)sum / validSamples;
|
||||
if (mv >= NTC_VCC_MV) return NAN;
|
||||
float ntcResistance = NTC_R_FIXED * (NTC_VCC_MV - mv) / mv;
|
||||
float kelvin = 1.0f / (1.0f / NTC_T0 + (1.0f / NTC_B) * logf(ntcResistance / NTC_R25));
|
||||
return kelvin - 273.15f;
|
||||
}
|
||||
|
||||
void setFan(bool on, const String& reason) {
|
||||
if (fanOn == on) return;
|
||||
fanOn = on;
|
||||
digitalWrite(FAN_CTRL_PIN, on ? HIGH : LOW);
|
||||
Utils::println("Thermal: Fan " + String(on ? "ON" : "OFF") + " (" + reason + ", " + String(currentTemperature, 1) + " C)");
|
||||
}
|
||||
|
||||
void updateFan() {
|
||||
if (!fanOn) {
|
||||
if (txCooldownActive) {
|
||||
setFan(true, "TX cooldown");
|
||||
} else if (currentTemperature >= FAN_ON_TEMP) {
|
||||
setFan(true, "temperature");
|
||||
}
|
||||
} else if (!txCooldownActive && currentTemperature < FAN_OFF_TEMP) {
|
||||
setFan(false, "cooled down");
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(TEMP_PIN, INPUT);
|
||||
analogSetPinAttenuation(TEMP_PIN, ADC_11db);
|
||||
pinMode(FAN_CTRL_PIN, OUTPUT);
|
||||
digitalWrite(FAN_CTRL_PIN, LOW);
|
||||
fanOn = false;
|
||||
firstTempSample = true; // first monitor() call samples immediately
|
||||
}
|
||||
|
||||
void monitor() {
|
||||
uint32_t now = millis();
|
||||
|
||||
if (txCooldownActive && (now - txEndTime >= TX_COOLDOWN_MS)) {
|
||||
txCooldownActive = false;
|
||||
updateFan();
|
||||
}
|
||||
|
||||
if (!firstTempSample && (now - lastTempSample < TEMP_SAMPLE_MS)) return;
|
||||
firstTempSample = false;
|
||||
lastTempSample = now;
|
||||
|
||||
float temperature = readTemperature();
|
||||
if (!isnan(temperature)) currentTemperature = temperature;
|
||||
|
||||
if (!txBlocked && currentTemperature >= TEMP_TX_BLOCK) {
|
||||
txBlocked = true;
|
||||
Utils::println("Thermal: Over-temperature at " + String(currentTemperature, 1) + " C, Tx blocked");
|
||||
} else if (txBlocked && currentTemperature < TEMP_TX_UNBLOCK) {
|
||||
txBlocked = false;
|
||||
Utils::println("Thermal: Temperature back to " + String(currentTemperature, 1) + " C, Tx allowed");
|
||||
} else if (!txBlocked && currentTemperature >= TEMP_WARNING) {
|
||||
Utils::println("Thermal: High temperature: " + String(currentTemperature, 1) + " C");
|
||||
}
|
||||
updateFan();
|
||||
}
|
||||
|
||||
void onTxStart() {
|
||||
txCooldownActive = false;
|
||||
setFan(true, "TX");
|
||||
}
|
||||
|
||||
void onTxEnd() {
|
||||
txCooldownActive = true;
|
||||
txEndTime = millis();
|
||||
}
|
||||
|
||||
void turnOffFan() { // before sleeping: no Tx while asleep, so the PA doesn't heat up
|
||||
txCooldownActive = false;
|
||||
setFan(false, "sleep");
|
||||
}
|
||||
|
||||
bool isTxBlocked() {
|
||||
return txBlocked;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+6
-1
@@ -27,6 +27,7 @@
|
||||
#include "board_pinout.h"
|
||||
#include "power_utils.h"
|
||||
#include "syslog_utils.h"
|
||||
#include "thermal_utils.h"
|
||||
#include "A7670_utils.h"
|
||||
#include "lora_utils.h"
|
||||
#include "wifi_utils.h"
|
||||
@@ -433,9 +434,13 @@ namespace Utils {
|
||||
displayToggle(false);
|
||||
}
|
||||
#ifdef VEXT_CTRL_PIN
|
||||
digitalWrite(VEXT_CTRL_PIN, !VEXT_CTRL_ON_STATE); // VEXT off before deep sleep (always, regardless of ecoMode)
|
||||
POWER_Utils::vext_ctrl_OFF(); // VEXT off before deep sleep (always, regardless of ecoMode)
|
||||
#endif
|
||||
#ifdef FAN_CTRL_PIN
|
||||
THERMAL_Utils::turnOffFan();
|
||||
#endif
|
||||
LoRa_Utils::sleepRadio();
|
||||
POWER_Utils::deactivateGPS(); // GPS rail off (AXP boards), otherwise it keeps draining the low battery while sleeping
|
||||
#ifdef RADIO_VCC_PIN
|
||||
digitalWrite(RADIO_VCC_PIN, LOW); // cut LoRa module power (QRP Labs LightGateway) so it draws nothing while sleeping
|
||||
#endif
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include "network_manager.h"
|
||||
#include "configuration.h"
|
||||
#include "lora_utils.h"
|
||||
#include "ota_utils.h"
|
||||
#include "web_utils.h"
|
||||
#include "map_utils.h"
|
||||
@@ -277,7 +278,7 @@ namespace WEB_Utils {
|
||||
Config.loramodule.txSpreadingFactor = getParamIntSafe("lora.txSpreadingFactor", Config.loramodule.txSpreadingFactor);
|
||||
Config.loramodule.txCodingRate4 = getParamIntSafe("lora.txCodingRate4", Config.loramodule.txCodingRate4);
|
||||
Config.loramodule.txSignalBandwidth = getParamIntSafe("lora.txSignalBandwidth", Config.loramodule.txSignalBandwidth);
|
||||
Config.loramodule.power = getParamIntSafe("lora.power", Config.loramodule.power);
|
||||
Config.loramodule.power = LoRa_Utils::validPower(getParamIntSafe("lora.power", Config.loramodule.power)); // saved as the power the radio chip really uses
|
||||
if (Config.loramodule.txActive)
|
||||
Config.loramodule.cadActive = request->hasParam("lora.cadActive", true);
|
||||
|
||||
|
||||
+13
-10
@@ -35,16 +35,19 @@ files = [
|
||||
]
|
||||
|
||||
string_to_find_str = "String"
|
||||
string_to_find_ver = "versionDate"
|
||||
|
||||
with open('src/LoRa_APRS_iGate.cpp', encoding='utf-8') as cpp_file:
|
||||
for line in cpp_file:
|
||||
if string_to_find_str in line and string_to_find_ver in line:
|
||||
start = line.find('"') + 1
|
||||
end = line.find('"', start)
|
||||
if start > 0 and end > start:
|
||||
versionDate = line[start:end]
|
||||
break
|
||||
def find_string_value(variable_name):
|
||||
with open('src/LoRa_APRS_iGate.cpp', encoding='utf-8') as cpp_file:
|
||||
for line in cpp_file:
|
||||
if string_to_find_str in line and variable_name in line:
|
||||
start = line.find('"') + 1
|
||||
end = line.find('"', start)
|
||||
if start > 0 and end > start:
|
||||
return line[start:end]
|
||||
return ""
|
||||
|
||||
versionDate = find_string_value("versionDate")
|
||||
versionNumber = find_string_value("versionNumber")
|
||||
|
||||
for src in files:
|
||||
out = src + ".gz"
|
||||
@@ -54,7 +57,7 @@ for src in files:
|
||||
content = f.read()
|
||||
|
||||
if src == 'data_embed/index.html':
|
||||
env_vars = env["BOARD"] + "<br>" + ','.join(env["BUILD_FLAGS"]).replace('-Werror -Wall,', '').replace(',-DELEGANTOTA_USE_ASYNC_WEBSERVER=1', '') + "<br>" + "Version date: " + versionDate
|
||||
env_vars = env["BOARD"] + "<br>" + ','.join(env["BUILD_FLAGS"]).replace('-Werror -Wall,', '').replace(',-DELEGANTOTA_USE_ASYNC_WEBSERVER=1', '') + "<br>" + "Version: " + versionNumber + "<br>" + "Version date: " + versionDate
|
||||
current_date = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') + " UTC"
|
||||
build_info = f'{env_vars}<br>Build date: {current_date}'.encode()
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* Copyright (C) 2026 Ricardo Guzman - CA2RXU
|
||||
*
|
||||
* This file is part of LoRa APRS iGate.
|
||||
*
|
||||
* LoRa APRS iGate is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LoRa APRS iGate is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LoRa APRS iGate. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BOARD_PINOUT_H_
|
||||
#define BOARD_PINOUT_H_
|
||||
|
||||
// LoRa Radio
|
||||
#define HAS_SX1262
|
||||
#define HAS_1W_LORA
|
||||
#define HAS_TCXO
|
||||
#define RADIO_VCC_PIN 40 // (RADIO_LDO_EN_PIN) HIGH = turn on the radio, LOW = turns off the radio
|
||||
#define RADIO_SCLK_PIN 13
|
||||
#define RADIO_MISO_PIN 12
|
||||
#define RADIO_MOSI_PIN 11
|
||||
#define RADIO_CS_PIN 15
|
||||
#define RADIO_RST_PIN 3
|
||||
#define RADIO_DIO1_PIN 1
|
||||
#define RADIO_BUSY_PIN 38
|
||||
#define RADIO_RXEN 21 // (RADIO_CTRL_PIN) HIGH = LNA on (Rx), LOW = LNA off (Tx)
|
||||
#define RADIO_WAKEUP_PIN RADIO_DIO1_PIN
|
||||
#define GPIO_WAKEUP_PIN GPIO_SEL_1
|
||||
|
||||
// I2C
|
||||
#define USE_WIRE_WITH_OLED_PINS
|
||||
|
||||
// Display
|
||||
#define HAS_DISPLAY
|
||||
#define HAS_SH1106
|
||||
|
||||
#undef OLED_SDA
|
||||
#undef OLED_SCL
|
||||
#undef OLED_RST
|
||||
|
||||
#define OLED_SDA 8
|
||||
#define OLED_SCL 9
|
||||
#define OLED_RST -1 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||
|
||||
// Aditional Config
|
||||
#define BATTERY_PIN 4
|
||||
#define BATTERY_CELLS 2 // 7.4V 2S battery
|
||||
#define BUTTON_PIN 0
|
||||
#define TEMP_PIN 14 // NTC Temperature sensor
|
||||
#define FAN_CTRL_PIN 41
|
||||
|
||||
// GPS
|
||||
#define HAS_GPS
|
||||
#define GPS_RX 6
|
||||
#define GPS_TX 5
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
[env:ttgo-t-beam-1W]
|
||||
board = esp32-s3-devkitm-1
|
||||
board_build.mcu = esp32s3
|
||||
board_build.flash_size = 16MB
|
||||
board_build.flash_mode = qio
|
||||
board_build.arduino.memory_type = qio_opi
|
||||
board_upload.flash_size = 16MB
|
||||
board_upload.maximum_size = 16777216
|
||||
board_build.psram_type = opi
|
||||
build_flags =
|
||||
${common.build_flags}
|
||||
${common.usb_flags}
|
||||
-D RADIOLIB_EXCLUDE_LR11X0=1
|
||||
-D RADIOLIB_EXCLUDE_SX127X=1
|
||||
-D RADIOLIB_EXCLUDE_SX128X=1
|
||||
-D TTGO_T_BEAM_1W
|
||||
-D BOARD_HAS_PSRAM
|
||||
lib_deps =
|
||||
${common.lib_deps}
|
||||
${common.display_libs}
|
||||
adafruit/Adafruit SH110X @ 2.1.15
|
||||
Reference in new issue
Block a user