Meshtastic

TTGO LoRa32 V2.0 battery level

I’m using TTGO LoRa32 V2.0 (firmware-tlora-v2-EU433-1.1.23.bin)
I connected the GPIO 35 through a 2x 100k voltage divider to the battery, but no luck. “USB” still appears on the screen.
Is there any way to measure the battery level?

1 Like

hmm - the BATTERY_PIN definition is currently only defined for TLORA_V2_1_16. If you are willing to build it yourself and confirm it works I’d eagerly turn it on for TLORA_V2.

You’d want to add

#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage

to about line 295 in configuration.h. Build instructions are here: https://github.com/meshtastic/Meshtastic-device/blob/master/docs/software/build-instructions.md

actually - just turning this on should be harmless (though I don’t have a board like this to test with). So if you can confirm for me that your lora_v2 board normally doesn’t have anything connected to pin35 I’ll just change the code in master and include it with the next release (coming in a day or so)

OK, thank you
It doesn’t have anything connected to pin35. Lora V2.0 works fine with a connected voltage divider.

ok - it will be in the next release

The schematic confirms the divider on io35.

Your change should be safe.

1 Like

There is no internal divider, on io35 is 0.02V. China is cutting manufacture cost :wink:

I thought the same, but upon further inspection the schematic linked is for the T3 V1.6, not the Lora32 V2.0. The LilyGO Github is definitely sparse far as hardware details.

This is likely as good a place as any to mention that I’ve got (hardware) fixes in the works for the inaccurate voltage readings as well as the leakage current through the voltage divider. Will be testing it soon on my T3s, but the fix would be even easier for folks with a Lora32, since you don’t have to desolder the existing divider resistors.

1 Like

All we want are the manufactures to give us all their design documentation in an easily consumable and fully translated form. Is that too much to ask?

lol

Perhaps if we ask LilyGO nicely we can get schematics for all the meshtastic applicable radios. It’s nice that they have a github, but it seems like more of a dev dump/sandbox than a real developer resource.

1 Like

I just reread my earlier response, sorry if there was a little snark. Sometimes humor doesn’t come across in text.

Schematics would be nice, before asking them we could compile a list of all the boards that are supported (I think there’s a drop box of that?) and include links to known documentation. I know we have a lot in the GitHub repo, it’s just not well organized.

2 Likes

Battery voltage measurement works


I had to add a 20k potentiometer, 10nf capacitor and adjust the indication (the error was -0.68V and it drifted).
But now lora32 never sleeps as if it were connected to USB all the time. Even when I disconnect IO35.

3 Likes

hmm - are you able to build and run the github version of the code yourself? (it isn’t too hard - there are build instructions in the docs/software directory).

If so, I bet it has something to do with this test:

You could add some calls to DEBUG_MSG(“considering getBattVoltage is %d\n”, getBattVoltage());

(alas - I don’t have one of these boards to try). I’m happy to help with questions if you want to make a stab at this?

also - isBatteryConnect() should return true if you have no battery plugged in. Perhaps the expected voltage in that case is wrong?

I made some tests:
when io35 is connect to the voltage divider: usbPower=1, isCharging=1, batMv=4195, batPct=100
when io35 is disconnect : usbPower=0, isCharging=0, batMv=0, batPct=0

DEBUG_MSG(“considering getBattVoltage is %d\n”, getBattVoltage()); and DEBUG_MSG(“considering getBattVoltageMv is %d\n”, getBattVoltageMv()); doesn’t work

How to lock the power status to always run on battery?
My lora32 board will work as solar repeater.

Oh, nice project, to build a repeater!! it will be my next step … to build one.

I built firmware 1.1.32 without #define BATTERY PIN 35.
No changes, lora32 never sleeps (the battery icon has disappeared from the display).
How to lock the power status to always run on battery?

@msws

Your node sounds like a router node. I think as long as you run a recent device load (1.1.30 or later), you should be able to use the python tool to tell the node it is a router and it will try to sleep as much as possible (regardless of battery), but it will leave the lora radio on and forward as needed.

Steps:

  • Run “meshtastic --set is_router true”
  • reboot the node

Until you --set is_router false, it will remain in this mode.

hmm - I think you’ve accidentally found a bug (if the BATTERY_PIN is defined but no divider network is attached, the battery sense will be wrong). Someday we coulde fix this:

1 Like

No effect, oled always on.
Lora32 was flashed using firmware version 1.1.23 and two T-Beams were ordered. :grinning:
Thank you for your help, I think lora32 is not worth our effort. The T-Beam is only $ 5 more expensive.