Compare commits

..

16 Commits

Author SHA1 Message Date
Liam Cottle
5372388e6e Merge pull request #2353 from jirogit/fix/techo-lite-non-shell-ble-clean
feat(techo-lite): add Non-Shell companion BLE variant
2026-04-22 20:25:32 +12:00
Liam Cottle
dc548578ff Merge pull request #2287 from pelgraine/fix/techo-lite-battery
Fixes #1183 — T-Echo Lite incorrect battery voltage
2026-04-22 20:23:21 +12:00
Liam Cottle
d3b457681a Merge pull request #2008 from weebl2000/p_lora_reset_rak4631
Fix RAK4631 SX1262 hardware pin config
2026-04-22 19:45:06 +12:00
Liam Cottle
f1f1361fd5 Merge pull request #2340 from weebl2000/fem-enabled-def
Fix FEM/LNA enbaled by default for Heltec T096, Heltec Wireless Tracker v2
2026-04-22 19:33:29 +12:00
Liam Cottle
bdae60498c Merge pull request #2016 from weebl2000/add-lr1110-sx1276
Add sanity build for LR1110 and SX1276 too
2026-04-22 19:30:12 +12:00
Wessel Nieboer
66fe9ac2db Fix FEM/LNA enbaled by default for Heltec T096, Heltec Wireless Tracker v2
Should only really be disabled when it causes issues.
2026-04-22 09:30:00 +02:00
Liam Cottle
cc6139bc23 Merge pull request #2371 from weebl2000/r1-neo-shutdown
Implement proper shutdown procedure for R1 neo
2026-04-22 19:22:46 +12:00
pelgraine
d516cd8a9e Fixes #1183 — T-Echo Lite incorrect battery voltage
Battery (TechoBoard.h/cpp): Added PIN_VBAT_MEAS_EN (P0.31) — the T-Echo
Lite has a gated voltage divider that must be enabled before reading. Also
added pinMode(PIN_VBAT_READ, INPUT) before each ADC read to reclaim P0.02
from other peripherals. Pin definitions hardcoded from LilyGo's
t_echo_lite_config.h.

I2C (variant.h): Corrected SDA/SCL from P0.04/P0.02 to P1.04/P1.02 per
LilyGo's IIC_1_SDA/IIC_1_SCL. The old P0.02 mapping conflicted with the
battery ADC pin.

GPS (variant.h): Corrected all five GPS pin assignments to match LilyGo's
config — UART TX/RX, wake, PPS, and power enable were all scrambled.

SPI (variant.h): Fixed SPI_INTERFACES_COUNT from _PINNUM(0, 2) to (2).

Tested on T-Echo Lite Non-Shell (USB-C, no display). Battery readings match
Heltec V4 reference within 10mV.
2026-04-22 12:56:15 +10:00
Wessel Nieboer
07671cf1fe Implement proper shutdown procedure for R1 neo
fixes #2361
2026-04-21 21:29:18 +02:00
Liam Cottle
d532481f34 Merge pull request #2335 from fizzyfuzzle/v4_adc_mult
Add Heltec V4 set adc.multiplier functionality
2026-04-21 18:06:42 +12:00
me
28b1586fd7 feat(techo-lite): add Non-Shell (screenless) companion BLE variant
T-Echo Lite Non-Shell has no ePaper display, but the existing
companion BLE env inherits DISPLAY_CLASS=GxEPDDisplay from the base
env. This causes display.begin() to run on non-existent hardware,
corrupting BLE initialization and generating a random PIN that
cannot be displayed, making BLE connection impossible.

Add LilyGo_T-Echo-Lite_non_shell_companion_radio_ble env that:
- excludes DISPLAY_CLASS and ePaper-related build flags
- removes GxEPDDisplay.cpp and ui-new from build sources
- uses static BLE_PIN_CODE=123456 (avoids random PIN generation)

Also fix boards/t-echo.json:
- add nrfutil to upload protocols list
- add use_1200bps_touch=true and wait_for_upload_port=true
  to enable reliable flashing via PlatformIO upload button
2026-04-20 21:08:08 -07:00
Scott Powell
3d982711a6 * CommonCLI: more reply bounds checking 2026-04-21 12:12:47 +10:00
Scott Powell
db7baa7bd7 * CommonCLI: bounds check added to "unknown config:" replies 2026-04-21 12:07:39 +10:00
Marco
e8907a3108 Add Heltec V4 set adc.multiplier 2026-04-19 15:29:43 +02:00
Wessel Nieboer
a5ae89aac0 Fix RAK4631 SX1262 hardware pin config 2026-04-04 13:18:17 +02:00
Wessel Nieboer
c0252ab82c Add sanity build for LR1110 and SX1276 too 2026-04-04 13:18:15 +02:00
16 changed files with 147 additions and 44 deletions

View File

@@ -39,6 +39,10 @@ jobs:
- wio-e5-mini_repeater
# ESP32-C6
- LilyGo_Tlora_C6_repeater_
# LR1110 (nRF52)
- wio_wm1110_repeater
# SX1276 (ESP32)
- Tbeam_SX1276_repeater
steps:
- name: Clone Repo

View File

@@ -53,11 +53,14 @@
"protocols": [
"jlink",
"nrfjprog",
"nrfutil",
"stlink",
"cmsis-dap",
"blackmagic"
]
],
"use_1200bps_touch": true,
"wait_for_upload_port": true
},
"url": "https://os.mbed.com/platforms/Nordic-nRF52840-DK/",
"vendor": "Nordic"
}
}

View File

@@ -2,6 +2,7 @@
#include "CommonCLI.h"
#include "TxtDataHelpers.h"
#include "AdvertDataHelpers.h"
#include "TxtDataHelpers.h"
#include <RTClib.h>
#ifndef BRIDGE_MAX_BAUD
@@ -285,7 +286,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
// change admin password
StrHelper::strncpy(_prefs->password, &command[9], sizeof(_prefs->password));
savePrefs();
sprintf(reply, "password now: %s", _prefs->password); // echo back just to let admin know for sure!!
sprintf(reply, "password now: ");
StrHelper::strncpy(&reply[14], _prefs->password, 160-15); // echo back just to let admin know for sure!!
} else if (memcmp(command, "clear stats", 11) == 0) {
_callbacks->clearStats();
strcpy(reply, "(OK - stats reset)");
@@ -726,7 +728,8 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep
strcpy(reply, "Error: unsupported by this board");
};
} else {
sprintf(reply, "unknown config: %s", config);
strcpy(reply, "unknown config: ");
StrHelper::strncpy(&reply[16], config, 160-17);
}
}
@@ -784,10 +787,11 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep
} else if (memcmp(config, "direct.txdelay", 14) == 0) {
sprintf(reply, "> %s", StrHelper::ftoa(_prefs->direct_tx_delay_factor));
} else if (memcmp(config, "owner.info", 10) == 0) {
auto start = reply;
*reply++ = '>';
*reply++ = ' ';
const char* sp = _prefs->owner_info;
while (*sp) {
while (*sp && reply - start < 159) {
*reply++ = (*sp == '\n') ? '|' : *sp; // translate newline back to orig '|'
sp++;
}

View File

@@ -9,7 +9,7 @@ void LoRaFEMControl::init(void)
pinMode(P_LORA_KCT8103L_PA_CSD, OUTPUT);
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH);
pinMode(P_LORA_KCT8103L_PA_CTX, OUTPUT);
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
digitalWrite(P_LORA_KCT8103L_PA_CTX, lna_enabled ? LOW : HIGH);
setLnaCanControl(true);
}

View File

@@ -16,6 +16,6 @@ class LoRaFEMControl
void setLnaCanControl(bool can_control) { lna_can_control = can_control; }
private:
bool lna_enabled = false;
bool lna_enabled = true;
bool lna_can_control = false;
};

View File

@@ -14,7 +14,7 @@ void LoRaFEMControl::init(void)
pinMode(P_LORA_KCT8103L_PA_CSD, OUTPUT);
digitalWrite(P_LORA_KCT8103L_PA_CSD, HIGH);
pinMode(P_LORA_KCT8103L_PA_CTX, OUTPUT);
digitalWrite(P_LORA_KCT8103L_PA_CTX, HIGH);
digitalWrite(P_LORA_KCT8103L_PA_CTX, lna_enabled ? LOW : HIGH);
setLnaCanControl(true);
}

View File

@@ -16,6 +16,6 @@ class LoRaFEMControl
void setLnaCanControl(bool can_control) { lna_can_control = can_control; }
private:
bool lna_enabled = false;
bool lna_enabled = true;
bool lna_can_control = false;
};

View File

@@ -73,7 +73,7 @@ void HeltecV4Board::begin() {
digitalWrite(PIN_ADC_CTRL, LOW);
return (5.42 * (3.3 / 1024.0) * raw) * 1000;
return (adc_mult * (3.3 / 1024.0) * raw) * 1000;
}
const char* HeltecV4Board::getManufacturerName() const {

View File

@@ -5,8 +5,16 @@
#include <helpers/ESP32Board.h>
#include <driver/rtc_io.h>
#include "LoRaFEMControl.h"
#ifndef ADC_MULTIPLIER
#define ADC_MULTIPLIER 5.42
#endif
class HeltecV4Board : public ESP32Board {
protected:
float adc_mult = ADC_MULTIPLIER;
public:
RefCountedDigitalPin periph_power;
LoRaFEMControl loRaFEMControl;
@@ -18,6 +26,14 @@ public:
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
void powerOff() override;
uint16_t getBattMilliVolts() override;
const char* getManufacturerName() const override ;
bool setAdcMultiplier(float multiplier) override {
if (multiplier == 0.0f) {
adc_mult = ADC_MULTIPLIER;
} else {
adc_mult = multiplier;
}
return true;
}
float getAdcMultiplier() const override { return adc_mult; }
const char* getManufacturerName() const override;
};

View File

@@ -8,24 +8,47 @@
void TechoBoard::begin() {
NRF52Board::begin();
// Configure battery measurement control BEFORE Wire.begin()
// to ensure P0.02 is not claimed by another peripheral
pinMode(PIN_VBAT_MEAS_EN, OUTPUT);
digitalWrite(PIN_VBAT_MEAS_EN, LOW);
pinMode(PIN_VBAT_READ, INPUT);
Wire.begin();
pinMode(SX126X_POWER_EN, OUTPUT);
digitalWrite(SX126X_POWER_EN, HIGH);
delay(10); // give sx1262 some time to power up
delay(10);
}
uint16_t TechoBoard::getBattMilliVolts() {
int adcvalue = 0;
// Use LilyGo's exact ADC configuration
analogReference(AR_INTERNAL_3_0);
analogReadResolution(12);
delay(10);
// ADC range is 0..3000mV and resolution is 12-bit (0..4095)
adcvalue = analogRead(PIN_VBAT_READ);
// Convert the raw value to compensated mv, taking the resistor-
// divider into account (providing the actual LIPO voltage)
return (uint16_t)((float)adcvalue * REAL_VBAT_MV_PER_LSB);
// Enable battery voltage divider (MOSFET gate on P0.31)
pinMode(PIN_VBAT_MEAS_EN, OUTPUT);
digitalWrite(PIN_VBAT_MEAS_EN, HIGH);
// Reclaim P0.02 for analog input (in case another peripheral touched it)
pinMode(PIN_VBAT_READ, INPUT);
delay(10); // let divider + ADC settle
// Read and average (matching LilyGo's approach)
uint32_t sum = 0;
for (int i = 0; i < 8; i++) {
sum += analogRead(PIN_VBAT_READ);
delayMicroseconds(100);
}
uint16_t adc = sum / 8;
// Disable divider to save power
digitalWrite(PIN_VBAT_MEAS_EN, LOW);
// LilyGo's exact formula: adc * (3000.0 / 4096.0) * 2.0
// = adc * 0.73242188 * 2.0 = adc * 1.46484375
uint16_t millivolts = (uint16_t)((float)adc * (3000.0f / 4096.0f) * 2.0f);
return millivolts;
}
#endif
#endif

View File

@@ -4,14 +4,12 @@
#include <Arduino.h>
#include <helpers/NRF52Board.h>
// built-ins
#define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
#define VBAT_DIVIDER (0.5F) // 150K + 150K voltage divider on VBAT
#define VBAT_DIVIDER_COMP (2.0F) // Compensation factor for the VBAT divider
#define PIN_VBAT_READ (4)
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
// ============================================================
// T-Echo Lite battery pins — hardcoded from LilyGo t_echo_lite_config.h
// NOT using any defines from variant.h for battery measurement
// ============================================================
#define PIN_VBAT_READ _PINNUM(0, 2) // BATTERY_ADC_DATA
#define PIN_VBAT_MEAS_EN _PINNUM(0, 31) // BATTERY_MEASUREMENT_CONTROL
class TechoBoard : public NRF52BoardDCDC {
public:
@@ -20,10 +18,11 @@ public:
uint16_t getBattMilliVolts() override;
const char* getManufacturerName() const override {
return "LilyGo T-Echo";
return "LilyGo T-Echo Lite";
}
void powerOff() override {
digitalWrite(PIN_VBAT_MEAS_EN, LOW);
#ifdef LED_RED
digitalWrite(LED_RED, LOW);
#endif
@@ -41,4 +40,4 @@ public:
#endif
sd_power_system_off();
}
};
};

View File

@@ -96,3 +96,47 @@ build_src_filter = ${LilyGo_T-Echo-Lite.build_src_filter}
lib_deps =
${LilyGo_T-Echo-Lite.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:LilyGo_T-Echo-Lite_non_shell_companion_radio_ble]
extends = LilyGo_T-Echo-Lite
upload_protocol = nrfutil
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
board_upload.maximum_size = 712704
build_flags =
${nrf52_base.build_flags}
-I variants/lilygo_techo_lite
-I src/helpers/nrf52
-I lib/nrf52/s140_nrf52_6.1.1_API/include
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
-I src/helpers/ui
-I examples/companion_radio/ui-new
-D LILYGO_TECHO
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=22
-D SX126X_POWER_EN=30
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D P_LORA_TX_LED=LED_GREEN
-D DISABLE_DIAGNOSTIC_OUTPUT
-D ENV_INCLUDE_GPS=1
-D GPS_BAUD_RATE=9600
-D PIN_GPS_EN=GPS_EN
-D AUTO_OFF_MILLIS=0
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
-D UI_RECENT_LIST_SIZE=9
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<TechoBoard.cpp>
+<helpers/sensors/EnvironmentSensorManager.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../variants/lilygo_techo_lite>
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/*.cpp>
lib_deps =
${LilyGo_T-Echo-Lite.lib_deps}
densaugeo/base64 @ ~1.4.0

View File

@@ -24,7 +24,7 @@
#define PIN_PWR_EN _PINNUM(0, 30) // RT9080_EN
#define BATTERY_PIN _PINNUM(0, 2)
#define ADC_MULTIPLIER (4.90F)
#define ADC_MULTIPLIER (2.0F)
#define ADC_RESOLUTION (14)
#define BATTERY_SENSE_RES (12)
@@ -47,13 +47,13 @@
////////////////////////////////////////////////////////////////////////////////
// I2C pin definition
#define PIN_WIRE_SDA _PINNUM(0, 4) // (SDA)
#define PIN_WIRE_SCL _PINNUM(0, 2) // (SCL)
#define PIN_WIRE_SDA _PINNUM(1, 4) // (SDA) - per LilyGo IIC_1_SDA
#define PIN_WIRE_SCL _PINNUM(1, 2) // (SCL) - per LilyGo IIC_1_SCL
////////////////////////////////////////////////////////////////////////////////
// SPI pin definition
#define SPI_INTERFACES_COUNT _PINNUM(0, 2)
#define SPI_INTERFACES_COUNT (2)
#define PIN_SPI_MISO _PINNUM(0, 17) // (MISO)
#define PIN_SPI_MOSI _PINNUM(0, 15) // (MOSI)
@@ -149,10 +149,11 @@ extern const int SCK;
#define PIN_DISPLAY_BUSY DISP_BUSY
////////////////////////////////////////////////////////////////////////////////
// GPS
// GPS — per LilyGo t_echo_lite_config.h
// PIN_GPS_TX/RX named from GPS module's perspective
#define PIN_GPS_RX _PINNUM(1, 13) // RXD
#define PIN_GPS_TX _PINNUM(1, 15) // TXD
#define GPS_EN _PINNUM(1, 11) // POWER_RT9080_EN
#define PIN_GPS_STANDBY _PINNUM(1, 10)
#define PIN_GPS_PPS _PINNUM(0, 29) // 1PPS
#define PIN_GPS_TX _PINNUM(0, 29) // GPS UART TX → MCU RX
#define PIN_GPS_RX _PINNUM(1, 10) // GPS UART RX ← MCU TX
#define GPS_EN _PINNUM(1, 11) // GPS RT9080 power enable
#define PIN_GPS_STANDBY _PINNUM(1, 13) // GPS wake-up
#define PIN_GPS_PPS _PINNUM(1, 15) // GPS 1PPS

View File

@@ -14,9 +14,12 @@ const PowerMgtConfig power_config = {
void R1NeoBoard::initiateShutdown(uint8_t reason) {
// Disable LoRa module power before shutdown
MESH_DEBUG_PRINTLN("R1Neo: shutting down");
digitalWrite(SX126X_POWER_EN, LOW);
// Signal IO controller that MCU is off, then release DCDC latch
digitalWrite(PIN_SOFT_SHUTDOWN, LOW);
digitalWrite(PIN_DCDC_EN_MCU_HOLD, LOW);
if (reason == SHUTDOWN_REASON_LOW_VOLTAGE ||
reason == SHUTDOWN_REASON_BOOT_PROTECT) {
configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel);

View File

@@ -18,6 +18,12 @@ public:
R1NeoBoard() : NRF52Board("R1NEO_OTA") {}
void begin();
#ifdef NRF52_POWER_MANAGEMENT
void powerOff() override {
initiateShutdown(SHUTDOWN_REASON_USER);
}
#endif
#if defined(P_LORA_TX_LED)
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on

View File

@@ -147,7 +147,7 @@ extern "C"
// LoRa radio module pins for RAK4631
#define P_LORA_DIO_1 (47)
#define P_LORA_NSS (42)
#define P_LORA_RESET (-1)
#define P_LORA_RESET (38)
#define P_LORA_BUSY (46)
#define P_LORA_SCLK (43)
#define P_LORA_MISO (45)