Battery status

Maybe it’s a good idea to rework the firmway on how the battery status is calculated.
My phone status is like full-full-full-full-75%-75%-dead!
Anyone any ideas on how to do that?

cu, Chris

1 Like

Looking at the source code, the firmware reads the battery’s voltage via an A/D converter. The indicator is set as follows:
> 4.1 volts: charging
> 3.85 volts: full
> 3.75 volts: high
> 3.65 volts: medium
> 3.6 volts: low
< 3.6 volts: empty

If you read this discussion: LIPO Voltage to charge state
You’ll see the typical discharge curve, but also that measuring voltage under load is not a very good way to calculate remaining charge.

The battery in the Makerphone is only a 2-terminal device (i.e.: it provides power only). Many cell phone batteries, as well as laptop batteries have 3 or more terminals and internal circuits that monitor current in and out and report the state of charge to the device, but that is not available here, so voltage is the only (rough) indication of remaining charge. This varies over a very narrow range, maybe a half volt difference or less between fully charged and nearly dead, so you can see why it’s not a very good measure of charge.

It’s possible that the voltage thresholds in the firmware could be adjusted slightly to give a bit better estimate of charge, but even then there is going to be enough variation from battery to battery that it can’t be all that precise. You can play with those thresholds if you compile the firmware from source (the subject of another topic here: How to build the firmware.bin file).

Hey Chris and Frank,

Yes, the battery percentage presented on the lockscreen does not always represent the exact battery level, since that is nearly impossible in this case. (as Frank explained)

It was even worse at the beginning but our engineers fixed the problems as much as they could so now we have somewhat dependable results because measuring voltage just doesn’t work perfectly!

The battery can last for a few days of moderate usage so charge it whenever you feel like you used it a lot over the past few days.

Cheers,
Robert

Just for kicks, I watched as the battery indicator first started to go down from full to high. With the display on full-time, over the course of about 45 minutes to an hour from then, it went through all the stages… high, medium, low, and empty. A minute or so after it showed empty, the message about Battery Critical came up and power shut down.

So the point is that once it starts showing the high (but not full) icon (75%), you can expect it to go dead in about 45 minutes to an hour if the display is on much of the time (probably less if you have a 4G network module, since it surely uses more power).

It should be possible to slightly tweak the upper three voltage thresholds in MAKERphone.cpp to get a more linear representation of the dropoff; maybe I’ll play with that when I get a chance. It’s an imprecise process at best.

2 Likes

Chris, I’ve tweaked the voltage thresholds a bit. I tried:
> 3.95 Volts = Full
> 3.85 Volts = High
> 3.75 Volts = Medium
> 3.65 Volts = Low
< 3.65 Volts = Empty

I tested this by fully charging the battery, then leaving the lock screen display on all the time at full brightness. Under these conditions the battery goes from full to shutdown in about 3.5 hours, going through this discharge profile:
0:00 - Full Battery Icon
1:08 - 75% Battery Icon
2:03 - 50% Battery Icon
2:40 - 25% Battery Icon
3:18 - Empty Battery Icon
3:27 - Battery Critical Shutdown

While not perfect, this seems much better than what you had originally observed. This was tested with a 2G module.

This source code modifications for this (plus some others) can be found in the zip file referenced in this topic: Experimental changes to firmware

2 Likes

I’ve tested the new battery settings and can confirm, that it s indeed alot better now.
So, I suggest that the new voltage settings go into the next official firmware.

1 Like

@Sejin @frankprindle

Thank you for your effort and tinkering with this.

We unfortunately cannot implement thins into the official firmware since every phone reads the voltage differently :slight_smile:

Let me explain - when we were building prototypes, we’ve did the same thing you folks were doing and thought that it should be sufficient for battery level detection.

When we manufactured 3000 phones, we’ve figured out that ESP32 has the worst ADC we’ve ever seen in a microcontroller. Google it, it’s non-linear and has a different offset and different non-linearity for every chip (despite us taking the original ESP32s from Espressif and all from the same batch)

That’s why we had to calibrate every brain board after reflowing them and save the offset value in the flash memory of every chip (this was done by hand in our calibration jig and it was A LOT of fun laughing anxiously).

The only reliable way we could do this was by a simple 1-point calibration and hence the non-linearity in battery detection in some of the phones. The battery levels work differently depending on how the esp32 on your phone works.

The only real solution for this is adding a coulomb counter to the hardware and using it for battery measurement.

TBH this was our first time doing hardware for a device this complex and we’re fix this issue in the future product iterations.

Thank you for your understanding, folks :slight_smile:

2 Likes

I am enlightened! Great explanation.

Thank you for your understanding! :slight_smile:

I’m glad you found this interesting

Same for me. I was blown away by the task and the effort you put into it.

1 Like

Thanks! A lot of effort and a lot of experimentation went into the whole design. We did our best to make a really good product and there’s still a lot to improve in the future versions.

Btw this is what this calibration jig looks like.

I’ve designed this frankenstein myself

2 Likes