Skip to content

Add heltec-v4.3 board#9753

Merged
thebentern merged 19 commits intomeshtastic:developfrom
Quency-D:heltec-v4.3
Mar 4, 2026
Merged

Add heltec-v4.3 board#9753
thebentern merged 19 commits intomeshtastic:developfrom
Quency-D:heltec-v4.3

Conversation

@Quency-D
Copy link
Contributor

  1. This is the schematic diagram for v4.3.
  2. The main difference between v4.2 and v4.3 is the different fem and the different control pins of the fem.
  3. You can identify whether it is v4.2 or v4.3 by the default pull-up and pull-down resistors of GPIO2.
  4. The fem control code is centralized into a single file.
  5. The newly added fem lna is controlled on the screen.

🤝 Attestations

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Heltec (Lora32) V3
    • Heltec (Lora32) V4
    • Heltec (Lora32) V4-TFT
    • Heltec T114

@github-actions github-actions bot added needs-review Needs human review hardware-support Hardware related: new devices or modules, problems specific to hardware labels Feb 26, 2026
@Quency-D
Copy link
Contributor Author

It needs to be combined with the new variables added in this commit for it to compile successfully.

@fifieldt
Copy link
Member

Exciting!

@weebl2000
Copy link
Contributor

Made sure heltec tracker v2 can still build: Quency-D#1

@robekl
Copy link

robekl commented Feb 26, 2026

This PR moves SX126x FEM control from USE_GC1109_PA gates to HAS_LORA_FEM gates, but only heltec_v4 defines HAS_LORA_FEM=1. For GC1109 boards, CSD/CPS control is required for correct TX/RX/sleep behavior (board comments already document this in variant.h). If these controls are skipped, behavior can degrade (wrong RF path/state, higher sleep current, reduced link reliability).

@Quency-D
Copy link
Contributor Author

Made sure heltec tracker v2 can still build: Quency-D#1

Thank you. Only a very small number of samples of the Heltec Tracker v2 board were released before, and it has now been redesigned. I think it's appropriate to wait until the new design is available before making any modifications. Therefore, this submission will not be merged for the time being.

@Quency-D
Copy link
Contributor Author

This PR moves SX126x FEM control from USE_GC1109_PA gates to HAS_LORA_FEM gates, but only heltec_v4 defines HAS_LORA_FEM=1. For GC1109 boards, CSD/CPS control is required for correct TX/RX/sleep behavior (board comments already document this in variant.h). If these controls are skipped, behavior can degrade (wrong RF path/state, higher sleep current, reduced link reliability).

Yes, your concerns are valid. However, currently USE_GC1109_PA is only used for heltec-v4 and heltec tracker v2. The heltec-v4 part has been modified in this submission. As for heltec tracker v2, since only a small number of samples were previously released and it has been redesigned, we plan to modify and submit it again after the new design is completed.

@weebl2000
Copy link
Contributor

Made sure heltec tracker v2 can still build: Quency-D#1

Thank you. Only a very small number of samples of the Heltec Tracker v2 board were released before, and it has now been redesigned. I think it's appropriate to wait until the new design is available before making any modifications. Therefore, this submission will not be merged for the time being.

Should we remove the Heltec Wireless Tracker v2 from Meshtastic firmware altogether?

If we merge this PR the heltec wireless tracker v2 build will fail. That's what my PR tried to address. :)

@Quency-D
Copy link
Contributor Author

Should we remove the Heltec Wireless Tracker v2 from Meshtastic firmware altogether?

If we merge this PR the heltec wireless tracker v2 build will fail. That's what my PR tried to address. :)

I tried using this pr to compile the Heltec Wireless Tracker v2, and it compiled successfully. What error did you get during compilation? Could you post it so I can see?

@weebl2000
Copy link
Contributor

weebl2000 commented Feb 27, 2026

I tried using this pr to compile the Heltec Wireless Tracker v2, and it compiled successfully. What error did you get during compilation? Could you post it so I can see?

The build itself compiles, but the issue is at runtime — the PR removes all USE_GC1109_PA guarded code and replaces it with HAS_LORA_FEM guards, but only heltec_v4 defines HAS_LORA_FEM=1. Since the tracker v2 doesn't define it, the GC1109 FEM would never be initialized, TX/RX mode switching wouldn't happen, and deep sleep RTC hold logic would be skipped. It compiles fine but the FEM would be completely uncontrolled at runtime. Essentially it breaks Heltec Wireless Tracker v2. It's better to remove it then, or merge the PR suggestion I made.

@Quency-D
Copy link
Contributor Author

The build itself compiles, but the issue is at runtime — the PR removes all USE_GC1109_PA guarded code and replaces it with HAS_LORA_FEM guards, but only heltec_v4 defines HAS_LORA_FEM=1. Since the tracker v2 doesn't define it, the GC1109 FEM would never be initialized, TX/RX mode switching wouldn't happen, and deep sleep RTC hold logic would be skipped. It compiles fine but the FEM would be completely uncontrolled at runtime. Essentially it breaks Heltec Wireless Tracker v2. It's better to remove it then, or merge the PR suggestion I made.

Let me think about it. Could you please explain how you perform the format checking? What tools do you use?

@weebl2000
Copy link
Contributor

The repo uses Trunk for CI lint/format checks — it runs automatically on every PR. For C/C++ files it uses clang-format (config is in .trunk/configs/.clang-format).

You can run it locally with:

trunk fmt     # auto-format files
trunk check   # check for lint/format issues

@Quency-D
Copy link
Contributor Author

The repo uses Trunk for CI lint/format checks — it runs automatically on every PR. For C/C++ files it uses clang-format (config is in .trunk/configs/.clang-format).

You can run it locally with:

trunk fmt     # auto-format files
trunk check   # check for lint/format issues

Thank you for your answer. I fixed the FEM control in Heltec Tracker v2. I think this macro approach is also simpler and easier to understand. What do you think?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for the Heltec WiFi LoRa 32 V4.3 board, which uses a different FEM (KCT8103L) compared to V4.2 (GC1109), and centralizes FEM control logic into a new LoRaFEMInterface class. The V4.3 hardware is auto-detected at runtime by reading the default pull state of GPIO2. Additionally, a new LNA toggle menu is added to the screen UI for boards that support LNA control (KCT8103L).

Changes:

  • New LoRaFEMInterface class (src/mesh/LoRaFEMInterface.h/.cpp) unifies FEM control for all supported boards (GC1109 and KCT8103L), replacing board-specific USE_GC1109_PA conditionals throughout the codebase
  • Renamed FEM pin macros from generic (LORA_PA_EN, LORA_PA_TX_EN) to chip-specific (LORA_GC1109_PA_EN, LORA_GC1109_PA_TX_EN), and added KCT8103L pin definitions to heltec_v4/variant.h
  • Added a new LoRa FEM LNA toggle UI menu in MenuHandler.h/.cpp controlled by a new fem_lna_mode config field

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/mesh/LoRaFEMInterface.h New class declaration for unified FEM control interface
src/mesh/LoRaFEMInterface.cpp New implementation with runtime FEM detection and per-chip control logic
src/mesh/SX126xInterface.cpp Delegates FEM init/sleep/TX/RX to LoRaFEMInterface
src/mesh/RadioInterface.h Conditionally includes new LoRaFEMInterface.h
src/mesh/RadioInterface.cpp Uses loraFEMInterface.powerConversion() when HAS_LORA_FEM=1
src/sleep.cpp Uses loraFEMInterface.setRxModeEnableWhenMCUSleep() instead of inline GC1109 code
src/graphics/draw/MenuHandler.h Adds new LoraFemLnaToggleMenu enum value and method declaration
src/graphics/draw/MenuHandler.cpp Adds LNA toggle menu for boards with controllable LNA
src/configuration.h Adds default definition HAS_LORA_FEM 0
variants/esp32s3/heltec_v4/variant.h Adds KCT8103L pin definitions alongside renamed GC1109 macros
variants/esp32s3/heltec_v4/platformio.ini Adds -D HAS_LORA_FEM=1
variants/esp32s3/heltec_wireless_tracker_v2/variant.h Renames FEM pin macros to chip-specific names
variants/esp32s3/heltec_wireless_tracker_v2/platformio.ini Adds -D HAS_LORA_FEM=1

power = loraFEMInterface.powerConversion(power);
}
#else
// todo:All entries containing "lora fem" are grouped together above.
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a leftover in-code TODO comment on line 928. This style of embedded todo comment should not appear in production code. Either the comment should be removed entirely or the suggested cleanup should be done as part of this PR.

Suggested change
// todo:All entries containing "lora fem" are grouped together above.

Copilot uses AI. Check for mistakes.
Quency-D and others added 3 commits March 3, 2026 17:33
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Quency-D and others added 5 commits March 3, 2026 18:12
#ifdef USE_GC1109_PA
// Power Amps are often non-linear, so we can use an array of values for the power curve
#define NUM_PA_POINTS 22
#define TX_GAIN_LORA 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 9, 9, 8, 7
Copy link
Collaborator

@jp-bennett jp-bennett Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this PR would lose this define, which is probably not intentional. Or if intentional, let's remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section was also used in the Heltec Tracker v2, so it should be retained.

@Quency-D Quency-D requested a review from caveman99 March 4, 2026 03:06
@thebentern thebentern merged commit 5ced739 into meshtastic:develop Mar 4, 2026
15 of 65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hardware-support Hardware related: new devices or modules, problems specific to hardware needs-review Needs human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants