Skip to content

Add Heltec WiFi LoRa 32 V4.3 support - #2376

Draft
waiet wants to merge 14 commits into
1technophile:developmentfrom
waiet:codex/heltec-v4-upstream-pr
Draft

waiet wants to merge 14 commits into
1technophile:developmentfrom
waiet:codex/heltec-v4-upstream-pr

Conversation

@waiet

@waiet waiet commented Sep 29, 2026 •

Copy link
Copy Markdown

Summary

Add native OpenMQTTGateway support for the Heltec WiFi LoRa 32 V4.3 high-frequency board (ESP32-S3R2, SX1262, KCT8103L, 16 MB flash, 2 MB QSPI PSRAM), while preserving the existing Arduino-LoRa implementation for SX127x-based boards. V4.2/GC1109 and V4 R8 are not covered.

What changed

  • add a dedicated PlatformIO board definition and heltec-wifi-lora-32-v4 environment
  • add an SX1262 backend based on RadioLib, selected only by the V4 environment
  • keep existing LoRa environments on the current Arduino-LoRa backend
  • configure the V4 RF front end (KCT8103L control pins, RX/TX switching and PA-aware output-power mapping)
  • retain DIO2 RF-switch control, set the chip current limit to 140 mA and TCXO to 1.8 V, and apply Heltec's mandatory RX workaround using a checked read-modify-write of register 0x08B5
  • expose optional rxboostedgain through existing MQTT commands, state, NVS and a V4-only WebUI checkbox; default off, including migration of old NVS records
  • initialize the V4 OLED power rail before display reset
  • validate runtime LoRa configuration before applying or persisting it
  • constrain this board to 863-928 MHz, 4-28 dBm requested connector output, SF5-12, CR5-8, preamble 6-65535 and supported discrete bandwidths; restore the previous hardware configuration after a failed update, or mark the radio unavailable if recovery fails
  • stream WebUI power options in bounded chunks so the extended selector cannot truncate the page
  • enforce the LoRa packet-size limit and preserve text/hex MQTT payload compatibility
  • document the V4 environment, wiring profile and supported radio settings
  • add host-side regression tests for both radio backends, payload bounds, configuration limits and non-LoRa build isolation
  • retain the original ESP32 internal-temperature register implementation and use the Arduino temperature driver on ESP32-S3/newer targets

Compatibility

The radio abstraction is compile-time selected. Existing SX127x boards continue to use sandeepmistry/LoRa; RadioLib is linked only by the Heltec V4 environment. Builds without ZgatewayLORA do not require either LoRa library.

Existing MQTT topics and text/hex payload formats are unchanged. SX127x WebUI frequency/power/SF choices and state schema remain unchanged. The V4.3 profile defaults to 868 MHz, 14 dBm connector output, SF7, 125 kHz, CR4/5, preamble 8, sync word 0x12, CRC on, IQ inversion off and RX boost off. Hardware maximum settings are not a statement of regulatory permission.

Validation

  • host tests: exact configuration bounds/discrete bandwidths, PA power mapping, payload codec, SX127x facade, SX1262 initialization, checked RX register operations, boost switching, rollback/recovery failure, non-LoRa isolation
  • actual production JSON/NVS/state and WebUI handler tests using ArduinoJson 6.18.5: partial updates, old-record migration, rejected settings not persisted, save/load/init/erase, checkbox on/off, both radio profiles and the 3000-byte chunk bound
  • PlatformIO builds:
    • heltec-wifi-lora-32-v4
    • heltec-wifi-lora-32
    • ttgo-lora32-v1
    • ttgo-lora32-v21
    • esp32dev-ble
  • dependency check: RadioLib 7.7.1 only in the V4 build; Arduino-LoRa only in the three legacy LoRa builds
  • git diff --check, shell syntax check and board JSON validation

Fresh hardware flashing and offline validation passed on two Heltec V4.3 868 MHz boards. Each reports 16 MB flash, 2 MB PSRAM, an OLED I2C acknowledgement and ready SX1262 with no radio error. A temporary serial-only adapter invoked the production LoRa command handler and observed its normal received-message queue/dispatch; neither this adapter nor offline overrides are included in the PR.

All 38 sequential test packets were received in both directions at 4 dBm requested connector output: normal/boosted/normal RX gain, SF5 and SF12, 15500/15600 Hz bandwidth interoperability and binary hex payloads. RSSI/SNR metadata, invalid-frequency rejection and NVS save/load passed. Previous LoRa settings were restored after testing. This is a close-range functional check, not a long-range, sensitivity, calibrated power or loss-rate measurement.

Live MQTT broker/WebUI end-to-end checks and outdoor range validation remain pending; this PR stays draft. No private Xiaomi BLE/offline dashboard features are included.

Run bash test/host/run_heltec_v4_radio_tests.sh after the V4 PlatformIO build has installed ArduinoJson, or set ARDUINOJSON_INCLUDE to its src directory. Local formatter checks, shell syntax, board JSON validation and git diff --check also passed. A final clean production V4.3 rebuild passed after all temporary hardware hooks were removed. Upstream clang-format 9 and security checks passed on 24ef8e3; the V4.3 matrix build is still queued, so its result is not yet claimed.

Relation to #2339

#2339 implements an SX1262 FSK weather-sensor gateway. This change targets the existing OpenMQTTGateway LoRa transport and adds a native V4 board/environment instead of using the V3 board definition as a pin-compatible workaround. The changes are complementary, although they touch some of the same board setup files.

Vladimir Rusnak added 14 commits September 26, 2026 20:21
Signed-off-by: Vladimir Rusnak <kira@MacBook-Pro-uzivatela-Vladimir.local>
Signed-off-by: Vladimir Rusnak <kira@MacBook-Pro-uzivatela-Vladimir.local>
Signed-off-by: Vladimir Rusnak <kira@MacBook-Pro-uzivatela-Vladimir.local>
Signed-off-by: Vladimir Rusnak <kira@MacBook-Pro-uzivatela-Vladimir.local>
Signed-off-by: Vladimir Rusnak <kira@MacBook-Pro-uzivatela-Vladimir.local>
Signed-off-by: Vladimir Rusnak <kira@MacBook-Pro-uzivatela-Vladimir.local>
Signed-off-by: Vladimir Rusnak <kira@MacBook-Pro-uzivatela-Vladimir.local>
Signed-off-by: Vladimir Rusnak <kira@MacBook-Pro-uzivatela-Vladimir.local>
Signed-off-by: Vladimir Rusnak <kira@MacBook-Pro-uzivatela-Vladimir.local>
Signed-off-by: Vladimir Rusnak <kira@MacBook-Pro-uzivatela-Vladimir.local>
@waiet waiet changed the title Add Heltec WiFi LoRa 32 V4 support Add Heltec WiFi LoRa 32 V4.3 support Sep 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant