Skip to content

Conversation

@nwilde1590
Copy link
Contributor

@nwilde1590 nwilde1590 commented Jan 24, 2026

This adds a module to Base-UI that displays battery stats and a discharge curve (similar to what can be found in the iOS app. It also adds battery calibration. Users charge their device to full, start calibration, and upon automatic low battery shutdown an updated OCV array is stored to persistent memory. The persistent OCV array is also loaded at boot and used to calculate battery percentage, if present.

First time making a contribution of this scale so very open to feedback. Still need a couple more weeks of charge/discharging my own device for beta testing, but figured I'd get the PR started in case others are available to test/provide feedback.

A couple misc. notes:
I have a branch with protobufs updates, not sure how that works for PRs, but it adds an array to store the actual OCV array under config.proto. Let me know where to make a PR for that and I'll get that set up.
showSimpleBanner - seems to not work in user modules, so added some logic to allow them to display after user/menu interaction.

Will need testers for regression - only tested on Wio Tracker L1 E-Ink

🤝 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
    • LilyGo T-Deck
    • LilyGo T-Beam
    • RAK WisBlock 4631
    • Seeed Studio T-1000E tracker card
    • Other (please specify below)
      Wio L1 E-ink. Will need assistance with other devices.

@CLAassistant
Copy link

CLAassistant commented Jan 24, 2026

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Xaositek Xaositek requested a review from HarukiToreda January 25, 2026 03:31
@fifieldt fifieldt added enhancement New feature or request requires-protos Requires changes to protobufs to work requires-docs Documentation must be updated labels Jan 25, 2026
@fifieldt
Copy link
Member

Thank you for this useful feature :)

This will need also patches to the docs https://github.com/meshtastic/Meshtastic and protobuf repo https://github.com/meshtastic/protobufs

Are you familar with the trunk linting tool? We use that to keep our code formatting consistent.

@noahwilde
Copy link

Thank you for this useful feature :)

This will need also patches to the docs https://github.com/meshtastic/Meshtastic and protobuf repo https://github.com/meshtastic/protobufs

Are you familar with the trunk linting tool? We use that to keep our code formatting consistent.

Sure thing! Protobufs repo has a PR out already, I’ll work on docs this upcoming week. I did add the trunk linting extension to vscode but it wasn’t showing anything. I’ll mess around with it or use the output from the trunk CI test at least. Thanks for the review!

@nwilde1590
Copy link
Contributor Author

Status for future reviewers:
Generated protobufs no longer in this PR
PR for documentation created
PR for protobufs created
Trunk linting set up/formatting cleaned up

Seems like next steps after review are to get protobufs updates merged so the CI tests can complete

@Xaositek
Copy link
Contributor

@nwilde1590 If you can please review your PR and investigate the build failures in CI, that would get us several steps closer in reviewing this PR.

@noahwilde
Copy link

noahwilde commented Jan 29, 2026

@nwilde1590 If you can please review your PR and investigate the build failures in CI, that would get us several steps closer in reviewing this PR.

@Xaositek

The build failures are due to protobufs updates not being merged yet. I included the updated protobufs previously to allow CI to pass, but was advised to remove any generated content from the PR and allow the submodules to update on their own.

screen->runNow();
}
} else if (selected == Reset) {
if (batteryCalibrationSampler) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we call a batteryCalibrationModule->stopCalibration(); here in order to preempt any issues?

Choose a reason for hiding this comment

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

Agreed 356a4e1

rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
screen->runNow();
} else if (selected == Apply) {
if (batteryCalibrationModule && batteryCalibrationModule->isCalibrationActive()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the node restarted due to low battery / brownout, will isCalibrationActive still be true?

I was trying to trace this in the code but can't confirm.

Choose a reason for hiding this comment

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

Theres nothing in persistent memory/protobufs right now for saving current state, so brownout/low battery shutdown would reset back to false (See BatteryCalibrationModule.h line 27)

Choose a reason for hiding this comment

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

I do have future ideas about saving the calibration data to memory periodically to resume after unintentional rebooting though. In testing, its a pain to have to start calibration from scratch if you accidentally hit the reset button several days in with a battery that lasts a week+.

@fifieldt
Copy link
Member

Protobuf patch:L meshtastic/protobufs#850

@nwilde1590
Copy link
Contributor Author

nwilde1590 commented Feb 11, 2026

Before and after calibration plots showing battery percentage over time with a fairly consistent load:

IMG_8794 IMG_8792

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

Labels

enhancement New feature or request requires-docs Documentation must be updated requires-protos Requires changes to protobufs to work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants