mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-10-31 02:51:58 +01:00
QRP Labs Gateway update
This commit is contained in:
1 parent
f739b90adc
commit
033657836f
8 files changed
+81
-11
No files matched your search
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace POWER_Utils {
|
||||
|
||||
#ifdef VEXT_CTRL
|
||||
#ifdef VEXT_CTRL_PIN
|
||||
void vext_ctrl_ON();
|
||||
void vext_ctrl_OFF();
|
||||
#endif
|
||||
@@ -46,6 +46,9 @@ namespace POWER_Utils {
|
||||
void activateLoRa();
|
||||
void deactivateLoRa();
|
||||
bool begin(TwoWire &port);
|
||||
#ifdef SOLAR_CHARGE_PIN
|
||||
void checkSolarCharge();
|
||||
#endif
|
||||
void setup();
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace WX_Utils {
|
||||
String generateHumString(const float sensorHum);
|
||||
String generatePresString(const float sensorPres);
|
||||
String readDataSensor();
|
||||
float readBoardTemperature();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "battery_utils.h"
|
||||
#include "board_pinout.h"
|
||||
#include "power_utils.h"
|
||||
#include "wx_utils.h"
|
||||
#include "utils.h"
|
||||
|
||||
#if defined(HAS_AXP192) || defined(HAS_AXP2101)
|
||||
@@ -210,6 +211,23 @@ namespace POWER_Utils {
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SOLAR_CHARGE_PIN
|
||||
void checkSolarCharge() { // called on each beacon: disable solar charging when too cold for Li-Ion
|
||||
static bool chargingEnabled = true;
|
||||
float boardTemp = WX_Utils::readBoardTemperature();
|
||||
if (isnan(boardTemp)) {
|
||||
chargingEnabled = true; // sensor failure: keep charging (previous behaviour)
|
||||
} else if (chargingEnabled && boardTemp < SOLAR_CHARGE_DISABLE_TEMP) {
|
||||
chargingEnabled = false;
|
||||
Serial.println("[SOLAR] Charging disabled, board temp: " + String(boardTemp, 1) + "C");
|
||||
} else if (!chargingEnabled && boardTemp > SOLAR_CHARGE_ENABLE_TEMP) {
|
||||
chargingEnabled = true;
|
||||
Serial.println("[SOLAR] Charging enabled, board temp: " + String(boardTemp, 1) + "C");
|
||||
}
|
||||
digitalWrite(SOLAR_CHARGE_PIN, chargingEnabled ? SOLAR_CHARGE_ENABLED_STATE : !SOLAR_CHARGE_ENABLED_STATE);
|
||||
}
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
#ifdef HAS_AXP192
|
||||
Wire.begin(SDA, SCL);
|
||||
@@ -254,6 +272,12 @@ namespace POWER_Utils {
|
||||
pinMode(BATTERY_PIN, INPUT);
|
||||
#endif
|
||||
|
||||
#ifdef SOLAR_CHARGE_PIN
|
||||
pinMode(SOLAR_CHARGE_PIN, OUTPUT);
|
||||
digitalWrite(SOLAR_CHARGE_PIN, SOLAR_CHARGE_ENABLED_STATE); // solar charging enabled by default
|
||||
gpio_hold_dis((gpio_num_t)SOLAR_CHARGE_PIN); // release hold kept during deep sleep (if any)
|
||||
#endif
|
||||
|
||||
#ifdef INTERNAL_LED_PIN
|
||||
pinMode(INTERNAL_LED_PIN, OUTPUT);
|
||||
digitalWrite(INTERNAL_LED_PIN, LOW);
|
||||
|
||||
+12
-3
@@ -25,6 +25,7 @@
|
||||
#include "battery_utils.h"
|
||||
#include "aprs_is_utils.h"
|
||||
#include "board_pinout.h"
|
||||
#include "power_utils.h"
|
||||
#include "syslog_utils.h"
|
||||
#include "A7670_utils.h"
|
||||
#include "lora_utils.h"
|
||||
@@ -168,6 +169,9 @@ namespace Utils {
|
||||
#endif
|
||||
|
||||
if (beaconUpdate) {
|
||||
#ifdef SOLAR_CHARGE_PIN
|
||||
POWER_Utils::checkSolarCharge(); // solar boards: enable/disable charging by board temperature
|
||||
#endif
|
||||
if (!Config.display.alwaysOn && Config.display.timeout != 0) displayToggle(true);
|
||||
|
||||
TELEMETRY_Utils::checkEUPInterval();
|
||||
@@ -437,11 +441,16 @@ namespace Utils {
|
||||
displayToggle(false);
|
||||
}
|
||||
#ifdef VEXT_CTRL_PIN
|
||||
#ifndef HELTEC_WSL_V3
|
||||
digitalWrite(VEXT_CTRL_PIN, LOW);
|
||||
#endif
|
||||
digitalWrite(VEXT_CTRL_PIN, !VEXT_CTRL_ON_STATE); // VEXT off before deep sleep (always, regardless of ecoMode)
|
||||
#endif
|
||||
LoRa_Utils::sleepRadio();
|
||||
#ifdef RADIO_VCC_PIN
|
||||
digitalWrite(RADIO_VCC_PIN, LOW); // cut LoRa module power (QRP Labs LightGateway) so it draws nothing while sleeping
|
||||
#endif
|
||||
#ifdef SOLAR_CHARGE_PIN
|
||||
gpio_hold_en((gpio_num_t)SOLAR_CHARGE_PIN); // keep charge on/off decided by temperature while sleeping
|
||||
gpio_deep_sleep_hold_en();
|
||||
#endif
|
||||
transmitFlag = true;
|
||||
delay(100);
|
||||
esp_deep_sleep_start();
|
||||
|
||||
+27
-7
@@ -17,11 +17,11 @@
|
||||
*/
|
||||
|
||||
#include <TinyGPS++.h>
|
||||
#ifdef LIGHTGATEWAY_PLUS_1_0
|
||||
#include "Adafruit_SHTC3.h"
|
||||
#endif
|
||||
#include "configuration.h"
|
||||
#include "board_pinout.h"
|
||||
#ifdef HAS_SHTC3
|
||||
#include "Adafruit_SHTC3.h"
|
||||
#endif
|
||||
#include "wx_utils.h"
|
||||
#include "display.h"
|
||||
|
||||
@@ -51,8 +51,9 @@ Adafruit_BMP280 bmp280;
|
||||
Adafruit_BME680 bme680;
|
||||
Adafruit_Si7021 si7021 = Adafruit_Si7021();
|
||||
#endif
|
||||
#ifdef LIGHTGATEWAY_PLUS_1_0
|
||||
#ifdef HAS_SHTC3
|
||||
Adafruit_SHTC3 shtc3 = Adafruit_SHTC3();
|
||||
bool boardTempSensorFound = false; // onboard SHTC3 (solar charge protection), independent of WX telemetry
|
||||
#endif
|
||||
|
||||
|
||||
@@ -66,7 +67,7 @@ namespace WX_Utils {
|
||||
err = SENSOR_I2C_BUS.endTransmission();
|
||||
#else
|
||||
Wire.beginTransmission(addr);
|
||||
#ifdef LIGHTGATEWAY_PLUS_1_0
|
||||
#ifdef HAS_SHTC3
|
||||
Wire.write(0x35);
|
||||
Wire.write(0x17);
|
||||
#endif
|
||||
@@ -90,6 +91,15 @@ namespace WX_Utils {
|
||||
}
|
||||
|
||||
void setup() {
|
||||
#ifdef HAS_SHTC3
|
||||
Wire.beginTransmission(0x70); // SHTC3 wakeup (0x3517): it sleeps between reads and ignores its address while asleep (e.g. after deep sleep)
|
||||
Wire.write(0x35);
|
||||
Wire.write(0x17);
|
||||
Wire.endTransmission();
|
||||
delay(1);
|
||||
boardTempSensorFound = shtc3.begin();
|
||||
Serial.println(boardTempSensorFound ? "init : SHTC3 (onboard) ... done!" : "SHTC3 (onboard) not found!");
|
||||
#endif
|
||||
if (Config.wxsensor.active) {
|
||||
getWxModuleAddres();
|
||||
if (wxModuleAddress != 0x00) {
|
||||
@@ -133,7 +143,7 @@ namespace WX_Utils {
|
||||
wxModuleFound = true;
|
||||
}
|
||||
}
|
||||
#ifdef LIGHTGATEWAY_PLUS_1_0
|
||||
#ifdef HAS_SHTC3
|
||||
else if (wxModuleAddress == 0x70) {
|
||||
if (shtc3.begin()) {
|
||||
Serial.println("SHTC3 sensor found");
|
||||
@@ -238,6 +248,16 @@ namespace WX_Utils {
|
||||
#endif
|
||||
}
|
||||
|
||||
float readBoardTemperature() { // onboard SHTC3 (no WX correction applied), NAN if not available
|
||||
#ifdef HAS_SHTC3
|
||||
if (boardTempSensorFound) {
|
||||
sensors_event_t humidity, temp;
|
||||
if (shtc3.getEvent(&humidity, &temp)) return temp.temperature;
|
||||
}
|
||||
#endif
|
||||
return NAN;
|
||||
}
|
||||
|
||||
String readDataSensor() {
|
||||
switch (wxModuleType) {
|
||||
case 1: // BME280
|
||||
@@ -271,7 +291,7 @@ namespace WX_Utils {
|
||||
break;
|
||||
case 5: // SHTC3
|
||||
{
|
||||
#ifdef LIGHTGATEWAY_PLUS_1_0
|
||||
#ifdef HAS_SHTC3
|
||||
sensors_event_t humidity, temp;
|
||||
shtc3.getEvent(&humidity, &temp);
|
||||
newTemp = temp.temperature;
|
||||
|
||||
@@ -54,5 +54,12 @@
|
||||
#define INTERNAL_LED_PIN 16
|
||||
#define BATTERY_PIN 1
|
||||
#define BUTTON_PIN 0
|
||||
#define SOLAR_CHARGE_PIN 48 // HIGH = solar charging disabled / LOW = enabled
|
||||
#define SOLAR_CHARGE_ENABLED_STATE LOW
|
||||
#define SOLAR_CHARGE_DISABLE_TEMP -4.0 // °C: below this, stop charging (Li-Ion must not charge below 0°C)
|
||||
#define SOLAR_CHARGE_ENABLE_TEMP -3.0 // °C: above this, charge again (1°C hysteresis)
|
||||
|
||||
// Onboard Sensors
|
||||
#define HAS_SHTC3 // temperature/humidity (I2C 0x70), used for solar charge protection
|
||||
|
||||
#endif
|
||||
@@ -14,6 +14,9 @@ board_build.embed_files =
|
||||
data_embed/leaflet.css.gz
|
||||
data_embed/leaflet.js.gz
|
||||
data_embed/favicon.png.gz
|
||||
data_embed/aprs-symbols-24-0.png.gz
|
||||
data_embed/aprs-symbols-24-1.png.gz
|
||||
data_embed/aprs-symbols-24-2.png.gz
|
||||
extra_scripts =
|
||||
pre:tools/compress.py
|
||||
debug_tool = esp-prog
|
||||
|
||||
@@ -14,6 +14,9 @@ board_build.embed_files =
|
||||
data_embed/leaflet.css.gz
|
||||
data_embed/leaflet.js.gz
|
||||
data_embed/favicon.png.gz
|
||||
data_embed/aprs-symbols-24-0.png.gz
|
||||
data_embed/aprs-symbols-24-1.png.gz
|
||||
data_embed/aprs-symbols-24-2.png.gz
|
||||
extra_scripts =
|
||||
pre:tools/compress.py
|
||||
debug_tool = esp-prog
|
||||
|
||||
Reference in new issue
Block a user