Skip to content

Added PowerSaving for all ESP32-based repeaters#1687

Open
IoTThinks wants to merge 10 commits intomeshcore-dev:devfrom
IoTThinks:MCdev-PowerSaving-for-all-esp32-repeaters-202602
Open

Added PowerSaving for all ESP32-based repeaters#1687
IoTThinks wants to merge 10 commits intomeshcore-dev:devfrom
IoTThinks:MCdev-PowerSaving-for-all-esp32-repeaters-202602

Conversation

@IoTThinks
Copy link
Copy Markdown
Contributor

@IoTThinks IoTThinks commented Feb 13, 2026

Hi friends,
This is the cleanup PR for this old PR #1353
The changes are below:

  1. (New) Let ESP32-based repeaters to sleep immediately receiving and process a LoRa packet
  2. (New) Added detailed response for powersaving CLI
  3. Supported sleep for all ESP32-based repeaters
  4. (New) Reduced time drift ESP32-based repeaters in power saving
  5. Added getIRQGpio to return DIO1 (SX1262) and DIO0 (SX127x)
  6. Fixed DIO0, DIO1 and RESET for Heltec v2. This is to allow Heltec v2 to do power saving. Well, I have a lot of requests to support Heltec v2.
  7. Added getIRQGpio to return DIO0 for Lilygo T3S3 SX1276
  8. Added getIRQGpio to return DIO0 for Lilygo TLoRa SX1276

I have tested with RAK4631, Heltec v3, Heltec v4 and Heltec V4 with ESPNOW.
I will set this as Draft to see if I miss anything and let all of my repeaters to run for a while.

Thanks a lot and have a nice day.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

IoTThinks commented Feb 13, 2026

Still need to fix for those TBeam boards.
Will do it tomorrow.

@IoTThinks IoTThinks marked this pull request as ready for review February 14, 2026 13:54
@IoTThinks IoTThinks marked this pull request as draft February 14, 2026 14:11
IoTThinks added a commit to IoTThinks/EasySkyMesh that referenced this pull request Feb 14, 2026
@IoTThinks
Copy link
Copy Markdown
Contributor Author

IoTThinks commented Feb 14, 2026

@towerviewcams Here you go.
These files are for UPGRADE from existing repeater firmware.
https://github.com/IoTThinks/EasySkyMesh/tree/main/firmware/Testing/PR-1687

This PR should be for ESP32-based repeaters only.
I have tested RAK4631 to ensure the PR does not break PowerSaving in NRF52.

  • powersaving on => It should tell you to have effect immediately.

Testing steps for ESP32-based repeaters

  • powersaving on => It should tell you to to wait 2 minutes to see the power reduction. Around 14mA for Heltec v4. Around 10mA for Heltec v3.
    When receiving a LoRa packet, it will process and sleep again immediately.
  • For heltecv4 with bridge, it will say "Bridge not supported" and will not go to sleep.
  • powersaving off => Returns Off
  • powersaving => To see status On or Off
  • start ota => It will skip sleep and stay at 120mA. You can do OTA as normal. After automatically reboot, the powersaving will automatically run after 2 minutes from boot.
  • clock => for time drift, around 1 minute/24 hours.

Please help to test.
Thanks a lot.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

IoTThinks commented Feb 14, 2026

For Heltec v4, when doing "start ota", the current may jump to ...750mA then down to 124mA.
So if the power supply is not stable for spike or set at low voltage (3.6-3.8v) the "start ota" may fail to start.
I see this happen even if "powersaving off".

It should be ok for battery.

@IoTThinks IoTThinks marked this pull request as ready for review February 15, 2026 03:20
@cra0
Copy link
Copy Markdown

cra0 commented Feb 15, 2026

+1 testing atm

@towerviewcams
Copy link
Copy Markdown

towerviewcams commented Feb 15, 2026

V4 testing on two boards results:

*fresh flash 1.13 firmware, powersaving delay is 22 seconds, then drops to 11.6mA sleep.
**testing/PR-1687 flashed over the 1.13 firmware and sleep is FAST! after packet process, sleep is immediate. 11.6mA
(version shows 1.12 29-Jan-2026) on the test bin for PR1687) FYI. I know this file is new because powersaving now reply with "On - After 2 minutes".

I have also verified that the receiver sensitivity remains normal with my lab test companion set to -9 power and the V4 has rssi of my test signals at -117 setup in a RF cage (normal RX level for V4 in my test cage). Also checked to make sure GC1109 has power on VCC pin full time-yes. So the LNA is always on.

Now running live on the mesh here in Oregon USA. repeating packets normally working good.

Next for Rak!

**Update
Testing 2, 4631 rak boards with new stock 1.13 works great and sleep is immediate at 4mA

@beachmiles
Copy link
Copy Markdown

beachmiles commented Feb 17, 2026

There is a chance that rtc_gpio_hold_dis will release this pin P_LORA_PA_EN to its default state which is off. May want to put the rtc_gpio_hold_dis function after setting the pin. There could be an extremely short blip on waking up after deep sleep that may not really show too much during testing but is not ideal.

pinMode(P_LORA_PA_EN, OUTPUT);
digitalWrite(P_LORA_PA_EN,HIGH);
rtc_gpio_hold_dis((gpio_num_t)P_LORA_PA_EN);

The esp32 docs are not super clear on this rtc_gpio_hold_dis function and may be missing some detail that the gpio_hold_dis function had Discussion about it here.
#1600 (comment)

@IoTThinks
Copy link
Copy Markdown
Contributor Author

IoTThinks commented Feb 18, 2026

@beachmiles This is required in deepsleep as I understand.

rtc_gpio_hold_dis

This PowerSaving uses light sleep.
So during lightsleep, GPIO states and RAM are intact / unchanged.

@beachmiles
Copy link
Copy Markdown

beachmiles commented Feb 19, 2026

Initial testing on this firmware is very good with VERY low power usage during sleep (6.7mA at 5.095V / 34.2 mW) and its extremely quick in going back to sleep after handling traffic.
Nice job!!

The bright white LED is still flashing during communication which it ideally wouldn't be doing while in powersave.
I believe this is the P_LORA_TX_LED pin?
Ideally a check for powersaving_enabled flag could be done before running this function,
_board->onBeforeTransmit();

Otherwise you'd have to put the check in each of the onBeforeTransmit functions in all of the variants cpp files. Save a little bit of juice and reducing this small current spike during TX could help keep the PA voltage a bit more steady giving slightly better TX performance?

@mikecarper
Copy link
Copy Markdown

mikecarper commented Feb 19, 2026

@beachmiles can you remove the led on code and measure the power difference? If it's small then chasing this down might not be worth it; if it's significant then this is important

@towerviewcams
Copy link
Copy Markdown

@beachmiles can you remove the led on code and measure the power difference? If it's small then chasing this down might not be worth it; if it's significant then this is important

I remove the current limit resister on all my boards. Might be a small amount but why have a light show in a sealed box that no one can see. Buy areas like Oregon is now the benefit is a bit more then slow areas.

@beachmiles
Copy link
Copy Markdown

beachmiles commented Feb 19, 2026

@beachmiles can you remove the led on code and measure the power difference? If it's small then chasing this down might not be worth it; if it's significant then this is important

Will try to see if I can compile it with it off and do some testing. I am not only concerned about saving a tiny bit of power but also ensuring there is no VCC / 3.3V voltage drop with the bright LED on why transmitting as that same rail is used by the PA chip which could degrade its TX signal strength.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

IoTThinks commented Feb 20, 2026

@towerviewcams @beachmiles Likely very minimum power saved if turn off led after TX.

but also ensuring there is no VCC / 3.3V voltage drop with the bright LED on why transmitting as that same rail is used by the PA chip which could degrade its TX signal strength.

It makes sense.
I actually love to see the led on during TX for ...debugging :D
Generally, the LED seems to be ON for Heltec boards only.

Ideally a check for powersaving_enabled flag could be done before running this function,
_board->onBeforeTransmit();

Let me see if the code can access powersaving_flag.

@Theo-Marshall
Copy link
Copy Markdown

Theo-Marshall commented Feb 20, 2026

This works great for my ESP32C6 board. Current from 38 mA down to 6.5 mA, basically just spending energy on keeping the sx1262 in RX!
image

@beachmiles
Copy link
Copy Markdown

beachmiles commented Feb 20, 2026

Excuse my continued editing of this post. My original findings were bad as I was disabling the PA as well as the LED so was seeing way better power savings with the PA off.

I couldn't easily access the powersaving_flag inside RadioLibWrappers.cpp so I just commented out the LED turning on in HeltecV4Board.cpp and built and flashed to my v4.

With the LED on during TX I am seeing ~3.5W spikes that drops the voltage from my 5V usb power supply from 5.09V all the way down to 4.78V.

Edit 3. @mikecarper Having the LED turned off lowers this TX peak to 3.35W and the 5.09V voltage dropping to 4.83V.
So the powersavings with the LED off only saves~150mW during TX blasts which is still not insignificant.

Im guessing the onboard 3.3V regulator is handling this voltage drop without its 3.3V output dropping too far, but Im fairly sure its 3.3V output is not going to be steady during these short blasts of the LED which could slightly decrease the PA signal strength.

Maybe this powersaving flag could be a uint8 instead of a bool so you could set different levels of powersaving for folks that want LEDs flashing and still have decent powersaving. I def love LEDs when I am debugging/troubleshooting but not when its sealed inside a box powered by a battery.

This is the build I finally got working with only 1 line commented out that turns on the LED on the heltec v4 variant.
meshcore_Heltec_v4_Repeater_PR1687_wLED_Off_v3.zip

@mikecarper
Copy link
Copy Markdown

The savings here are significant. Great find @beachmiles. With powersaving on, led off makes a lot of sense; I don't think we need to make a setting here. If you want blinking lights just turn powersaving off.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

IoTThinks commented Feb 20, 2026

I am willing to off the led in powersaving on.
Still finding a way to reach the powersaving_enabled flag in Heltec v3 and v4.
Do you have any suggested simple fix for this?

BTW, if this is bad not because of power consumption but because of the voltage drop during TX.
Then the LED should not be on during TX at all regardless powersaving is on or off.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

@Theo-Marshall Thanks a lot for your testing.
Glad it works as my Xiao C6 has not reached me yet.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

IoTThinks commented Feb 20, 2026

@mikecarper @beachmiles Confirmed having lower voltage drop via USB cable when LED is on. Measured by realtime usb monitor.
However, this issue happens even in main power and may affect TX.
Actually, the main power will be less stable to current spike like LED compared to battery.

So I suggest we or any friends here propose a way to turn off LED for all boards in all modes instead of just in powersaving mode.

Many boards have this features. RAK4631 does not have it.

@basiccode12
Copy link
Copy Markdown

basiccode12 commented Feb 21, 2026

@IoTThinks Hi, my apologies on a little confused.

Some places say seeed esp32s3 + WIO works, some say it works with a pin hack. Some say its not working. Any chance I can get an update or eta (no hack).

@IoTThinks
Copy link
Copy Markdown
Contributor Author

IoTThinks commented Feb 21, 2026

@basiccode12 This new PR requires no pin hack / change for Xiao Wio S3 combo.
This combo has a 30-pin connector link.

You may try the bin here.

https://github.com/IoTThinks/EasySkyMesh/releases/tag/PowerSaving13

Please note Xiao S3 (non Wio) + Wio Sx1262 is different.
This combo uses basic GPIOs only.
It is supported too in the link.
I will create a PR for this combo too.

@basiccode12
Copy link
Copy Markdown

basiccode12 commented Feb 21, 2026

@basiccode12 This new PR requires no pin hack / change for Xiao Wio S3 combo. This combo has a 30-pin connector link.

You may try the bin here.

https://github.com/IoTThinks/EasySkyMesh/releases/tag/PowerSaving13

Please note Xiao S3 (non Wio) + Wio Sx1262 is different. This combo uses basic GPIOs only. It is supported too in the link. I will create a PR for this combo too.

Thanks!, 66mA for 2 mins then to 9mA on a 30 pin connector type. Went straight back to sleep after repeat.
----> The only thing i noticed is there were no adverts in sleep. Is it supposed to wake for adverts? Has anyone else noticed this?

@IoTThinks
Copy link
Copy Markdown
Contributor Author

@basiccode12 All esp32 repeaters will wakeup every 30 minutes to check if to send adverts.

Last version, periodically adverts were sent correctly.

This version sleep after a few cycles after wakeup.

Let me monitor the adverts.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

@basiccode12 So your board is Xiao Wio S3.

Does it show battery percentage?

@towerviewcams
Copy link
Copy Markdown

I'm at 21 hours at a very busy, high noise repeater site and everything is running great! This location would not run 8-10 hours before. Well done Kevin!

@eureekasigns
Copy link
Copy Markdown

eureekasigns commented Apr 9, 2026

Edit - seems to be working on a WROOM based chip!

Board is a Circuitmess Chatter2. Initial files here. Testing repeater build.

This is really cool thank you

#1268

@terminalvelocity23
Copy link
Copy Markdown

I'm building it with my patches and deploying across the board.

@AI7NC
Copy link
Copy Markdown
Contributor

AI7NC commented Apr 10, 2026

Up to 3 days now on the tree repeater. (V4.2)

image

@towerviewcams
Copy link
Copy Markdown

1 day 22 hours on a 4.3 and running strong. Remote admin login is fast and first try through multiple repeaters now. very fast response. This is great. thank you Kevin @IoTThinks

@terminalvelocity23
Copy link
Copy Markdown

FYI it's still crashing when built with dev. Panic / exception reset.
So, when dev gets merged into main, it'll break it again.

@mihlit
Copy link
Copy Markdown

mihlit commented Apr 12, 2026

Hi, I did some tests with Xiao esp32c3 and Xiao esp32c6 boards. It improves power consumption a lot. I did a lot of measurements for these and other boards with nordic power profiler.

Power consumption-wise it works perfectly, but when powersaving is enabled and kicks in (after two minutes), sx1262 becomes deaf. Normally, signal strength of nearby repeater 10 km away is around 10-11 dB both ways. With powersaving, received signal drops to -6 dB. Disabling powersaving fixes it again. Noise floor (at least the value reported in repeater status) does not change. Using agc workaround agc.reset.interval has no effect. Any idea what could be happening here?

Note: I'm running up-to-date IoTThinks/MeshCore PowerSaving-v14.1 branch. I'm not 100 % sure if this is 1:1 with what is present in this PR.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

@towerviewcams We only merge with MeshCore main for stability.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

IoTThinks commented Apr 13, 2026

@mihlit I will take a look.
However, the powersaving for repeater is the same with this PR.

Which boards are you using?
Agc works fine on my Heltec v3 and 4.2.

@towerviewcams
Copy link
Copy Markdown

@towerviewcams We only merge with MeshCore main for stability.

absolutely. I did not question that sir

@terminalvelocity23
Copy link
Copy Markdown

terminalvelocity23 commented Apr 13, 2026

@towerviewcams We only merge with MeshCore main for stability.

Doesn't dev get merged into main when it's time for a new release? The git tree tells me so, for example, look at this commit.
It's not like I've merged every PR out there, only those which are already merged into dev and likely to be merged into main when the time comes.

@towerviewcams
Copy link
Copy Markdown

towerviewcams commented Apr 13, 2026

If the pulls are shown in the commits page then it merges into dev and the next day is available via Nightly firm. Then once a new main merge happens dev is pulled forward.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

@terminalvelocity23 Just curious, this PR has not been merged into Dev.
How do you do the testing this PR with nightly firmware?

@towerviewcams I will monitor it. Do you have the nightly firmware you are testing?
Not sure if they get the update from this PR?

Usually, we will release a new PS firmware 1 week after MC release.
So we can know the issue is due to MC main and fix accordingly in PS firmware.

@towerviewcams
Copy link
Copy Markdown

towerviewcams commented Apr 13, 2026

@IoTThinks There must be some confusion here. I haven't asked any questions regarding this PR.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

IoTThinks commented Apr 13, 2026

@terminalvelocity23 This PR is not merged into dev yet.
Is this PR included in the build of the nightly builds?

We love to fix a potential issue before it is getting merged into main.
However, we may need some information how the nightly builds are created.

@terminalvelocity23
Copy link
Copy Markdown

We love to fix a potential issue before it is getting merged into main. However, we may need some information how the nightly builds are created.

Idk about the nightly builds. I've just pulled dev, merged your PR on top of it, compiled and flashed it to my 2 devices. Both crashed within first 6 hours with the same reason, Panic / exception reset.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

@terminalvelocity23 Double check if your merge has the latest code from this file.
https://github.com/IoTThinks/MeshCore/blob/c88813a41011e87e14ecdbeb563c9e2688b282a0/src/helpers/ESP32Board.h

@fizzyfuzzle
Copy link
Copy Markdown

I merged this PR on top of the dev branch too and its running stable (without any resets) for multiple days already.

Guess there is something different going on, because even if it was resetting the 'powerlog' command is not be part of this PR.

@mihlit
Copy link
Copy Markdown

mihlit commented Apr 13, 2026

@mihlit Which boards are you using? Agc works fine on my Heltec v3 and 4.2.

I tested it with Seeed Studio XIAO ESP32-C6 and Seeed Studio XIAO ESP32-C3 boards. Both exactly the same behavior.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

@mihlit Which boards are you using? Agc works fine on my Heltec v3 and 4.2.

I tested it with Seeed Studio XIAO ESP32-C6 and Seeed Studio XIAO ESP32-C3 boards. Both exactly the same behavior.

@mihlit How to replicate the issue for your case? Please help to list the steps so I can replicate it.
I have Xiao C3 + Wio sx1262.

The sleep for ESP32 is lightsleep only.
All the data in the RAM and GPIO states are unchanged in the light sleep.

@mihlit
Copy link
Copy Markdown

mihlit commented Apr 13, 2026

HW part:
xiao c3 + wio sx1262, power connected to 3.3V pin, used LFP battery with external 3.3V buck-boost TPS63802 (I've tried directly to LFP battery with no change).

Modification for VBAT measurement - 210k/210k voltage divider connected to c3's D0. The "top" side connected to LFP battery. c3's D0 pin is not connected with sx1262 board

SW part:
PowerSaving-v14.1 branch, Xiao_C3_repeater build env

upload fw, set preset, sync clock, in cli powersaving on, manual trace with some repeater -> works, wait 2 minutes, do again -> reception significantly reduced, powersaving off in cli, works again

While it drops sensitivity significantly (+10 to -6 dB) it does not reproduce with both repeaters on the table. At least one should be some distance away. Does not matter which one, so the surrounding noise is not an issue. Both rptrs report noise floor around -110

@terminalvelocity23
Copy link
Copy Markdown

@terminalvelocity23 Double check if your merge has the latest code from this file. https://github.com/IoTThinks/MeshCore/blob/c88813a41011e87e14ecdbeb563c9e2688b282a0/src/helpers/ESP32Board.h

Will do.

@terminalvelocity23
Copy link
Copy Markdown

@terminalvelocity23 Double check if your merge has the latest code from this file. https://github.com/IoTThinks/MeshCore/blob/c88813a41011e87e14ecdbeb563c9e2688b282a0/src/helpers/ESP32Board.h

Yes I do, but somehow my firmware doesn't have the powerlog command support. Pulled fresh dev, pulled fresh #1687, copied that file. Nada.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

@terminalvelocity23 This PR does not have powerlog.

@eureekasigns
Copy link
Copy Markdown

eureekasigns commented Apr 14, 2026

Hi, I did some tests with Xiao esp32c3 and Xiao esp32c6 boards. It improves power consumption a lot. I did a lot of measurements for these and other boards with nordic power profiler.

Power consumption-wise it works perfectly, but when powersaving is enabled and kicks in (after two minutes), sx1262 becomes deaf. Normally, signal strength of nearby repeater 10 km away is around 10-11 dB both ways. With powersaving, received signal drops to -6 dB. Disabling powersaving fixes it again. Noise floor (at least the value reported in repeater status) does not change. Using agc workaround agc.reset.interval has no effect. Any idea what could be happening here?

Note: I'm running up-to-date IoTThinks/MeshCore PowerSaving-v14.1 branch. I'm not 100 % sure if this is 1:1 with what is present in this PR.

This is interesting. Are you just seeing those numbers via ping or management screen from app?

Have yet to deploy my test anywhere. So far just seeing if battery holds up (it is). I have seen multiple tries on viewing telemetry but it may also just be the terrible little antenna that's currently attached.

Edit - fwiw powerlog is there in my build from the other day. Just pulled whatever was linked on the branch. Not sure exactly how I pulled it in. I'm not great at GitHub or visual studio code. No crashes yet that I know of. Only the multiple attempts to view telemetry, but again IDK if that's garbage antenna or this build, or interference.

@mihlit
Copy link
Copy Markdown

mihlit commented Apr 14, 2026

I've always used app->tools->trace path and check path with 2 repeaters . You also don't have to check it twenty time to see if it happens for you or not. Once powersaving kicks in (after two minutes) every single transmission is affected. Just don't test with both rptrs on a table next to each other, there must be some distance (a few km) between them - my guess is that 10+ numbers you see when next to each other are after AGC adjustment, so it has some space to (not) amplify more and you will still see 10dB, just once with higher AGC amplification and once with lower and not notice anything.

Also, it's not just reported number. If I use repeater that has 4 dB signal (and not 10 dB as mentioned in previous example) and enable powersaving, the communication is lost completely.

@IoTThinks
Copy link
Copy Markdown
Contributor Author

IoTThinks commented Apr 14, 2026

@mihlit No time to test yet. May be I will test at weekend.

So far, I did trace path to Xiao C3 via a few hops (3-5 km away).
Still good SNR.

By right, powersaving has no power or mean to impact the sx1262.
Sx1262 is always active with full power.

In powersaving, the ESP32 just sleeps and sx1262 is still awake.

The only impact I can think of is agc.reset.interval may not trigger as frequent as intended due to sleep.
However, the impact is minimal as a repeater will be waken up frequently.

@terminalvelocity23
Copy link
Copy Markdown

@terminalvelocity23 This PR does not have powerlog.

I see. Anyway, built in the abovementioned manner, it seems stable enough, 24+ h uptime without resets.
False alarm, then, sorry.

@mihlit
Copy link
Copy Markdown

mihlit commented Apr 14, 2026

yeah, I know that in theory there should be no way why sleeping esp32 should degrade sx1262 sensitivity as it literally sleeps and does not do anything. That's why it is weird. When it happened with first esp32c6 I thought that esp or sx1262 are just damaged or something, also esp32c6 uses esp-idf 5.x so I thought that maybe it has some bug (same as esp32h2 w esp-idf 5 I'm still trying to make work). So I replaced repeater with new one based on esp32c3 (which has lower power consumption w/o powersaving) and it showed the same issue. So I tried again with another esp32c3 and still the same issue (always different sx1262). I tried google if someone had similar issue, but did not find anything except when NSS is floating during sleep, but esp32c3 uses light sleep, so it should not change. Even tried asking AI that came up with theory that during sleep and low power consumption, dc/dc may produce significant noise. So I tried powering it directly from LFP battery 3.25-3.30 V and it did not change anything.

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.