meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3.3k stars 800 forks source link

lora32 battery level voltage divider values are slightly wrong. #330

Closed DylanHoen closed 2 years ago

DylanHoen commented 4 years ago

I had some v0.7 TBeams running off of the 18650 batteries. I came back 36 hours later, and the batteries measured below 2.0V, which wrecks the 18650 batteries. The TBeam LEDs appeared to be off, and the cpu might have been off, but the OLED screen was still showing the last image. It happened a while ago and I can't remember which firmware version I was experimenting with. Somewhere between 0.7 and 0.91. I have since ordered some protected 18650 cells, but they aren't supposed to arrive until October. The firmware should have a setting to monitor and protect the cell from under-voltage. Maybe have a cell phone app page where you can choose your under-voltage shutdown voltage, and your charging battery full voltage. I would probably chose to charge to 4.05V and discharge to 3.2V to extend battery life. If you are powering down due to under-voltage, maybe display a warning message on the OLED for a couple seconds, then make sure to turn the OLED screen off before turning off the TBeam. I assume the OLED screen uses less power when most of the pixels are black, so the warning message should have as few bright pixels as possible. Maybe skip the warning message if the battery is below 2.5V.

geeksville commented 4 years ago

thanks! we have undervoltage shutoff but it was only recently added to the tbeam0.7 (last couple of weeks). Until recently we weren't reading battery voltage at all on that model.

geeksville commented 4 years ago

I think this is now fixed (though I don't have a tbeam 0.7, if you could download the latest binary and look for a serial log message that says "Battery xxxmV yy%" and confirm that it matches the voltage you measure across your battery that would really help.

geeksville commented 4 years ago

(please add a comment with what you find and if still not right reopen the bug) thanks

DylanHoen commented 4 years ago

Battery 3918mV 69% Multimeter says 4.16V When I connect to it with the android app, which I updated today, the app says: tbeam0.7 1.0-US/0.9.5

Earlier log with battery installed: Battery 3970mV 75% Battery 3950mV 75% Battery 3963mV 74% Battery 3970mV 75% Battery 3976mV 75% Battery 3963mV 75% Battery 3970mV 75% Battery 3957mV 76% Battery 3970mV 75% Battery 3976mV 75% Battery 3983mV 76% Battery 3970mV 75% Battery 3976mV 75% ... Battery 3950mV 72% Battery 3944mV 72% ... Battery 3944mV 71%

Even earlier log with with no battery installed (maybe the charger should be turned off a second before taking voltage measurements): Battery 3660mV 104% Battery 3673mV 81% Battery 3789mV 63% Battery 4247mV 65% Battery 3931mV 91% Battery 4208mV 61% Battery 3718mV 101% Battery 4073mV 43% Battery 4305mV 85%

I guess I will disconnect USB power and wait for the LEDs to shut off and see what the final multimeter voltage is. If I was less lazy, I would cut the +5V lead from the USB cable, and log the serial data until it shut off from dead battery.

geeksville commented 4 years ago

ooh that is super useful, it seems like the voltage divider values I guessed at might be a bit wrong for the lora32 (I don't have one of those boards). Based on your measurement I'll tweak the formula.

DylanHoen commented 4 years ago

You said "lora32", but this was about TBeam v0.7. The measurements without the battery installed had the % not corolating with the milivolts, like they were calculated from taking separate measurements. Its just sitting there with the dim blue LED, a day longer than expected to die. The multimeter says 3.4V, but when I try to wake it with the middle button, it ends up in a reboot loop. I wasn't going to sacrifice another good 18650 battery, so I used a cheep one that came free with a flashlight a few years ago. I guess it boots until it tries to do a long range lora transmit, then the voltage drops so low that it resets. Maybe my multimeter battery is dying and it is producing inaccurate voltage measurements. I guess I have to buy a new 9V battery for it to know for sure.

PA7John commented 4 years ago

"it seems like the voltage divider values I guessed at might be a bit wrong for the lora32" Interesting you mention that because that is also my feeling on a T3 Lora32 board. My board cuts off charging around 4v / 78% . No mayor issue, will try to get another battery for it and test

geeksville commented 4 years ago

(yeah the bummer is I don't have either of these boards - the software support for them was donated by others).

If either of ya'll are up for it. Finding the correct values for your boards should be fairly easy using:

This is the formula that is probably wrong (from src/Power.cpp):

1000.0 * analogRead(BATTERY_PIN) * 2.0 * (3.3 / 1024.0);

So the ratio 1/2 is not correct. If you could measure and then give me back an appropriate scaling factor (and your board type) - I can plug it in.

@DylanHoen and @PA7John

mc-hamster commented 3 years ago

https://github.com/LilyGO/TTGO-T-Beam/blob/master/t22_gps_v07(1).pdf

That says R42 and R43 are both 100k resistors.

Black6spdZ commented 3 years ago

(yeah the bummer is I don't have either of these boards - the software support for them was donated by others).

If either of ya'll are up for it. Finding the correct values for your boards should be fairly easy using:

This is the formula that is probably wrong (from src/Power.cpp):

1000.0 * analogRead(BATTERY_PIN) * 2.0 * (3.3 / 1024.0);
  • The 1000 is just to scale to millivolts
  • The 3.3 / 1024 at the end is correct (that converts things for how the ADC reads values - scales for CPU voltage.
  • The problem is the crummy 2.0 parameter that I plugged in assuming that R1 and R2 in the voltage divider was dividing the voltage in half.

So the ratio 1/2 is not correct. If you could measure and then give me back an appropriate scaling factor (and your board type) - I can plug it in.

@DylanHoen and @PA7John

any plans to add a method to calibrate the measured voltage?

slavino commented 3 years ago

https://github.com/LilyGO/TTGO-T-Beam/blob/master/t22_gps_v07(1).pdf

That says R42 and R43 are both 100k resistors.

Well, on the schema/drawing it also says that the board has NEO7 GPS and SD card. The correct statements ae NEO6M and no SD card slot.

20210301_090605 20210301_090617 20210301_090634

I was busy with other projects and didn't follow too much what's going on in Meshtastic.

sachaw commented 2 years ago

closed in favor of #980