Skip to content

Add nrf52 power management for Promicro/Faketec - #2116

Open
ctrlaltca wants to merge 5 commits into
meshcore-dev:devfrom
ctrlaltca:faketec
Open

ctrlaltca wants to merge 5 commits into
meshcore-dev:devfrom
ctrlaltca:faketec

Conversation

@ctrlaltca

Copy link
Copy Markdown

Enables power management for Promicro/Faketec boards.
Tested locally on 4 different boards:

  • undervoltage (< 3300mV) boot prevention works and system gets shutdown; over 3300mV it boots normally;
  • LPCOMP is configured and once the system reaches the vale defined by REFSEL, the system boots up again;
  • on VBUS the board boots up again

Please note that the value of R1 and R2 resistors is not standard on faketec boards, so REFSEL may need tuning depending on the ratio used by the voltage divider. The provided value seems to work fine for R1=R2 (voltage divider ratio =2) and should be conservative for R1=1.5*R2 (another common ratio used).
In meshcore the ADC_MULTIPLER ratio is currently set to 1.815f, that i assume it's meant to be equal to (2 - losses).

@Pacjunk

Pacjunk commented Mar 27, 2026

Copy link
Copy Markdown

This doesnt seem to take into account recent changes to this code. See #2088

@ctrlaltca

Copy link
Copy Markdown
Author

Thanks @Pacjunk , i saw that PR but I'll have to wait until it gets merged before rebasing mine on it.

@oltaco

oltaco commented Apr 8, 2026

Copy link
Copy Markdown
Member

I don't support enabling this by default for promicro. In my testing I found waking from LPCOMP to be very finicky, most likely dependent on size of vdiv resistors used.

For example if you use 1m/1m for the vdiv the voltage rise has to be very fast to trigger the wake from LPCOMP and it will likely never happen when on solar power.

@ctrlaltca

Copy link
Copy Markdown
Author

@oltaco I'm now using really lower values for vdiv resistors (10k/10k), but i still came to the conclusion that LPCOMP not always works reliably, mostly due to the internal voltage getting to a stable value (around 3v) only when battery voltage is at least 3.3v.
Still, I think this PR is still desiderable for a couple of reasons:

  • wake up ok VUSB never failed me, even when using an external solar power connected on USB-C
  • when the battery gets in the < 2.5v area the board enters a bootloop (restart -> die at first advert -> restart) that goes on until the flash gets fried, practically bricking the board until it gets erased and reflashed. The checkBootVoltage() avoids this.

@ctrlaltca

Copy link
Copy Markdown
Author

Rebased on 1.15.0

@ctrlaltca

ctrlaltca commented Nov 13, 2026 •

Copy link
Copy Markdown
Author

This is probably never going to be merged, but I just updated it with a few more changes.
After weeks of experimenting, the best resistor combination i found for getting an accurate volt reading (+- 0,01v) is 160 kΩ on BAT+ / 240 kΩ on GND. This PR reflects the use of these values.
Additional fixes:

  • the radio SPI, reset, RF-switch and status pins are released when the board goes to sleep. Standby current went from 0,007mA to less than 0.001mA (less that i can measure with my multimeter).
  • battery voltage gets checked every 5 seconds while running. Three consecutive readings below 3100 mV trigger peripheral shutdown.
  • the board powers up again when VBUS or LPCOMP measures 3.4v

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.

6 participants