Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MM: Improve battery reading accuracy #1712

Merged
merged 5 commits into from
Dec 22, 2024

Conversation

DevL0rd
Copy link
Contributor

@DevL0rd DevL0rd commented Dec 4, 2024

This PR fixes the following issues on the Miyoo Mini:

  • Fixes sudden low battery warnings or shutdowns do to unstable/unsmoothed voltage reading
  • Fixes inaccurate battery readings
  • Fixes inaccurate voltage droop curve
  • Prevent battery rising again due to system power draw changes. (about 80mv variance, a single percent on the battery)
  • Fixes device not cutting of for 40 minutes to 1hr after hitting 0% battery

The existing issue was due to reading ADC value as if it was 4.3V to 3.3V.
The correct range should be from 4.2V to 3.0V as the miyoomini has a li-ion, not a li-po battery.
Additionally I havee simplified the ADC to voltage reading, and interpolated the voltage across a lookup table to make the battery percentage relation completly linear.

I also collected 10 samples of the battery reading and averaged them together to better smooth the adc data.

These changes have completely fixed the wildly inaccurate and strange battery readings for the Miyoo Mini.
And they have made the battery drain curve completely linear, with proper power cutoff right at 0%.

If any one has a miyoo mini also, please give it a go :)

image

@DevL0rd DevL0rd force-pushed the mmv4-batteryaccuracy branch from 0388160 to dbdb3b2 Compare December 4, 2024 14:01
@Yin26
Copy link

Yin26 commented Dec 7, 2024

hi, would it be possible to share those changes with me? I seem to have battery drain problems and this sounds like it'd be really helpful!

Copy link
Member

@Aemiii91 Aemiii91 left a comment

Choose a reason for hiding this comment

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

Code looks good! We'll test it in beta 😉

@Aemiii91 Aemiii91 enabled auto-merge December 22, 2024 18:55
@Aemiii91 Aemiii91 added this pull request to the merge queue Dec 22, 2024
Merged via the queue into OnionUI:main with commit bae5a2a Dec 22, 2024
2 checks passed
@Aemiii91 Aemiii91 added the enhancement New or improved feature label Dec 24, 2024
@Aemiii91 Aemiii91 changed the title Fixed miyoo mini inaccurate battery readings. MM: Improve battery reading accuracy Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New or improved feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants