diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0ae0da2..f0118e9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -21,7 +21,7 @@ jobs:
- "ttgo-t-beam-v1_SX1268"
- "ttgo-t-beam-v1_2_SX1262"
- "heltec_wireless_stick"
- - "heltec_wireless_stick_lite"
+ - "heltec_ht-ct62"
steps:
- uses: actions/checkout@v3
@@ -41,6 +41,7 @@ jobs:
- name: Move Files
run: |
mkdir -p installer/firmware
+ cp .pio/build/${{ matrix.target }}/firmware.bin installer/ota_update.bin
cp .pio/build/${{ matrix.target }}/firmware.bin installer/firmware/
cp .pio/build/${{ matrix.target }}/bootloader.bin installer/firmware/
cp .pio/build/${{ matrix.target }}/partitions.bin installer/firmware/
diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml
index c593327..d2512a4 100644
--- a/.github/workflows/commit.yml
+++ b/.github/workflows/commit.yml
@@ -22,7 +22,7 @@ jobs:
- "ttgo-t-beam-v1_SX1268"
- "ttgo-t-beam-v1_2_SX1262"
- "heltec_wireless_stick"
- - "heltec_wireless_stick_lite"
+ - "heltec_ht-ct62"
steps:
- uses: actions/checkout@v3
diff --git a/data/igate_conf.json b/data/igate_conf.json
index 2aae297..4260b1b 100644
--- a/data/igate_conf.json
+++ b/data/igate_conf.json
@@ -65,6 +65,8 @@
"rememberStationTime": 30,
"sendBatteryVoltage": false,
"externalVoltageMeasurement": false,
- "externalVoltagePin": 34
+ "externalVoltagePin": 34,
+ "lowPowerMode": false,
+ "lowVoltageCutOff": 0
}
}
\ No newline at end of file
diff --git a/data_embed/index.html b/data_embed/index.html
index 94cb1cb..59a8ec9 100644
--- a/data_embed/index.html
+++ b/data_embed/index.html
@@ -1236,6 +1236,72 @@
+
+
+
+
+
+
+
+
+
+ Experimental
+
+
You can test new features. Use at your own risk!
+
+
+
+
+
+
Low voltage cut off (Deep sleep below specific voltage)
+
+
+ MCU will deep sleep when below provided battery voltage to save power. Set to 0 if you don't want this option. Please calibrate your voltage reading first!
+
+
+
+
+
= Config.beacon.interval * 60) {
+ Serial.println("Sending beacon");
+
+ LoRa_Utils::sendNewPacket("APRS", iGateLoRaBeaconPacket + Config.beacon.comment + " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V");
+
+ lastBeacon = time;
+ }
+
+ LoRa_Utils::startReceive();
+
+ Serial.println("Sleeping");
+
+ long sleep = (Config.beacon.interval * 60) - (time - lastBeacon);
+
+ Serial.flush();
+
+ esp_sleep_enable_timer_wakeup(sleep * 1000000);
+ esp_light_sleep_start();
+
+ Serial.println("Waked up");
+ }
+
+ Config.loramodule.rxActive = false;
+ }
+#endif
+
+ WIFI_Utils::setup();
+
SYSLOG_Utils::setup();
BME_Utils::setup();
WEB_Utils::setup();
@@ -96,7 +154,9 @@ void loop() {
return; // Don't process IGate and Digi during OTA update
}
- BATTERY_Utils::checkIfShouldSleep();
+ if (Config.lowVoltageCutOff > 0) {
+ BATTERY_Utils::checkIfShouldSleep();
+ }
thirdLine = Utils::getLocalIP();
diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp
index a11bb0b..8e9160a 100644
--- a/src/battery_utils.cpp
+++ b/src/battery_utils.cpp
@@ -1,12 +1,6 @@
#include "battery_utils.h"
#include "configuration.h"
#include "pins_config.h"
-//#include "lora_utils.h"
-
-// Uncomment if you want to monitor voltage and sleep if voltage is too low (<3.15V)
-//#define LOW_VOLTAGE_CUTOFF
-
-float cutOffVoltage = 3.15;
extern Configuration Config;
extern uint32_t lastBatteryCheck;
@@ -31,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_WSL)
+ #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_HTCT62)
sample = analogRead(batteryPin);
#endif
#if defined(HELTEC_V3) || defined(ESP32_DIY_LoRa) || defined(ESP32_DIY_1W_LoRa)
@@ -65,24 +59,15 @@ namespace BATTERY_Utils {
}
void checkIfShouldSleep() {
- #ifdef LOW_VOLTAGE_CUTOFF
if (lastBatteryCheck == 0 || millis() - lastBatteryCheck >= 15 * 60 * 1000) {
lastBatteryCheck = millis();
float voltage = checkBattery();
- if (voltage < cutOffVoltage) {
- /* Send message over APRS-IS or over LoRa???
-
- APRS_IS_Utils::upload("battery is low = sleeping")
-
- LoRa_Utils::sendNewMessage("battery is low = sleeping");
-
- */
+ if (voltage < Config.lowVoltageCutOff) {
ESP.deepSleep(1800000000); // 30 min sleep (60s = 60e6)
}
}
- #endif
}
}
\ No newline at end of file
diff --git a/src/configuration.cpp b/src/configuration.cpp
index ee4597e..e765787 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -96,6 +96,9 @@ void Configuration::writeFile() {
data["ota"]["username"] = ota.username;
data["ota"]["password"] = ota.password;
+ data["other"]["lowPowerMode"] = lowPowerMode;
+ data["other"]["lowVoltageCutOff"] = lowVoltageCutOff;
+
serializeJson(data, configFile);
configFile.close();
@@ -160,6 +163,9 @@ bool Configuration::readFile() {
tnc.enableSerial = data["tnc"]["enableSerial"].as();
tnc.acceptOwn = data["tnc"]["acceptOwn"].as();
+ lowPowerMode = data["other"]["lowPowerMode"].as();
+ lowVoltageCutOff = data["other"]["lowVoltageCutOff"].as();
+
int stationMode = data["stationMode"].as(); // deprecated but need to specify config version
if (stationMode == 0) {
@@ -331,6 +337,9 @@ void Configuration::init() {
externalVoltageMeasurement = false;
externalVoltagePin = 34;
+ lowPowerMode = false;
+ lowVoltageCutOff = 0;
+
Serial.println("todo escrito");
}
diff --git a/src/configuration.h b/src/configuration.h
index 8507c9f..bef4ca9 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -114,6 +114,8 @@ public:
bool sendBatteryVoltage;
bool externalVoltageMeasurement;
int externalVoltagePin;
+ bool lowPowerMode;
+ double lowVoltageCutOff;
std::vector wifiAPs;
WiFi_Auto_AP wifiAutoAP;
Beacon beacon; // new
diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp
index 0fc3459..3515eea 100644
--- a/src/digi_utils.cpp
+++ b/src/digi_utils.cpp
@@ -61,6 +61,7 @@ namespace DIGI_Utils {
String loraPacket, Sender, AddresseeAndMessage, Addressee;
if (packet != "") {
if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("NOGATE") == -1)) {
+ Sender = packet.substring(3, packet.indexOf(">"));
if (Sender != Config.callsign) {
String sender = packet.substring(3, packet.indexOf(">"));
STATION_Utils::updateLastHeard(sender);
diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp
index d835ee1..8849cf5 100644
--- a/src/lora_utils.cpp
+++ b/src/lora_utils.cpp
@@ -10,7 +10,7 @@
extern Configuration Config;
-#if defined(HELTEC_V3) || defined(HELTEC_WS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(HELTEC_WSL)
+#if defined(HELTEC_V3) || defined(HELTEC_WS) || defined(TTGO_T_Beam_V1_2_SX1262) || defined(HELTEC_HTCT62)
SX1262 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN);
bool transmissionFlag = true;
bool enableInterrupt = true;
@@ -63,7 +63,11 @@ namespace LoRa_Utils {
Serial.println("Starting LoRa failed!");
while (true);
}
- radio.setDio1Action(setFlag);
+ if (!Config.lowPowerMode) {
+ radio.setDio1Action(setFlag);
+ } else {
+ radio.setDIOMapping(1, RADIOLIB_SX126X_IRQ_RX_DONE);
+ }
radio.setSpreadingFactor(Config.loramodule.spreadingFactor);
float signalBandwidth = Config.loramodule.signalBandwidth/1000;
radio.setBandwidth(signalBandwidth);
@@ -178,6 +182,12 @@ namespace LoRa_Utils {
return packet;
}
+ void startReceive() {
+#ifdef HAS_SX126X
+ radio.startReceive();
+#endif
+ }
+
String receivePacket() {
String loraPacket = "";
#ifdef HAS_SX127X
@@ -205,7 +215,7 @@ namespace LoRa_Utils {
return loraPacket;
#endif
#ifdef HAS_SX126X
- if (transmissionFlag) {
+ if (transmissionFlag || Config.lowPowerMode) {
transmissionFlag = false;
radio.startReceive();
int state = radio.readData(loraPacket);
diff --git a/src/lora_utils.h b/src/lora_utils.h
index bca0e62..a756f0c 100644
--- a/src/lora_utils.h
+++ b/src/lora_utils.h
@@ -13,6 +13,7 @@ namespace LoRa_Utils {
String receivePacket();
void changeFreqTx();
void changeFreqRx();
+ void startReceive();
}
diff --git a/src/pins_config.h b/src/pins_config.h
index 2050316..6598146 100644
--- a/src/pins_config.h
+++ b/src/pins_config.h
@@ -64,7 +64,7 @@
#define RADIO_TXEN 13
#endif
-#ifdef HELTEC_WSL
+#ifdef HELTEC_HTCT62
#define RADIO_SCLK_PIN 10 // SX1262 SCK
#define RADIO_MISO_PIN 6 // SX1262 MISO
#define RADIO_MOSI_PIN 7 // SX1262 MOSI
@@ -94,7 +94,7 @@
#define OLED_RST 21
#endif
-#ifndef HELTEC_WSL
+#ifndef HELTEC_HTCT62
#define HAS_DISPLAY
#endif
@@ -104,7 +104,7 @@
#define HAS_INTERNAL_LED
#endif
-#ifdef HELTEC_WSL
+#ifdef HELTEC_HTCT62
#define batteryPin 1
#endif
#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2)
diff --git a/src/utils.cpp b/src/utils.cpp
index 84277d9..5d9ee65 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -115,7 +115,7 @@ namespace Utils {
secondaryBeaconPacket = iGateLoRaBeaconPacket + Config.beacon.comment;
}
- #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_WSL)
+ #if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_HTCT62)
if (Config.sendBatteryVoltage) {
beaconPacket += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V";
secondaryBeaconPacket += " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V";
diff --git a/src/web_utils.cpp b/src/web_utils.cpp
index d8c35cb..8a719e8 100644
--- a/src/web_utils.cpp
+++ b/src/web_utils.cpp
@@ -155,6 +155,9 @@ namespace WEB_Utils {
Config.externalVoltagePin = request->getParam("other.externalVoltagePin", true)->value().toInt();
}
+ Config.lowPowerMode = request->hasParam("other.lowPowerMode", true);
+ Config.lowVoltageCutOff = request->getParam("other.lowVoltageCutOff", true)->value().toDouble();
+
Config.writeFile();
AsyncWebServerResponse *response = request->beginResponse(302, "text/html", "");