Heltec Wifi LoRa V2 battery management

Thanks, Saber, this was helpful. BUT: In my application pin 37 is used as GPIO with external pull-up… this means the value read is meaningless. Further consequences: I have to re-design the schematics and PCB and throw away 700 PCBs I had already manufactured. Further problem: I have to maintain two sets of software releases, one for the >1500 items that are already out in the field, and another one for the new version. VERY disappointing.
To come up with a new release that changes pin assignments without notice in advance, and with the same version number, is very unprofessional, to say the least. Not to mention that there still is no up-to-date documentation (schematics) available.
Honestly, I do not know how to proceed from here. Creating a new version with your un-announced changes incorporated seems to be very risky - how long until you change the specs again? I need a supplier I can rely upon.

Hi @oe1wkl

We are very sorry for your problem. Because of the power management bug of ESP32 chip, ADC2 and WiFi cannot work at the same time. So we moved the ADC pins from the original GPIO 13 to GPI 37.

This is a terrible upgrade and we did not update the documentation in a timely manner. Such problems will never happen again in the future.

I think, you can continue to keep pin 37 as a GPIO function by turning off the MOS-FET. Is this okay?

I can use GPIO on Pin37, that’s not the problem - but I cannot at the same time measure the battery voltage, because I have an external pull-up resistor on Pin37, so the voltage is always close to 3.3V (and not around 1.3 through the voltage divider); but I also need the battery measurement in my application.
My question is: can I source around 700 of the older modules from Heltec? I still have 700 PCBs that I do not want to throw into the trash (they were expensive!). The WiFi problem with Pin13 does not disturb me - I only use WiFi for OTA and uploading files, and restart the module, before I measure battery voltage again.

Definitely yes, an agent has feedback your question to my colleague this afternoon.

How long is your time requirement? Production takes about two weeks, but January 20 to February 2 is the Chinese New Year holiday. This is a national holiday, and almost all suppliers and factories will stop working.

OK let’s finalize this via my supplier. We could do this in two batches - 250 before Jan 20, and the rest end of February or early March…

Hi guys,
I tried to find some sample sketch for reading the battery-level, but the only one i found quite helpful is this:

But looking though it, it neither contains “pinMode(13, OPEN_DRAIN);” nor something about GPI 37.

When i uploaded it to my Lora (V2) the battery voltage seems to slowly drop to zero, and the percentage goes to -45% … I guess it tries to read it from A4, so i changed it to analogPin = 37. But then the display stopped working so i changed it back to A4. Now the display works again but the reading doesnt make sense.
Could you please just tell me the few really essential lines i need?


GPIO32

Thanks for answering Saber,
but that doesn’t help me.
Does anyone have a sketch, that reads the battery (connected directly to the board) correctly?

@Saber I have more than 150 wireless stick lite here with me and I order more 150 to my supplier. I would like to now if the power detection pin is still at PIN 13. How can I check this?
Which is the best method to read the battery before the regulator, and after the regulator ?

Hello:

Lite’s battery detection pin is still GPIO13.

I have a WiFi_LoRa_32_V2 (868-915).

With reference to the posts by oe1wkl above about the change from GPIO13 to GPIO37 for battery voltage-divider reads:

Q. How do we tell what variant of V2 board we have? (i.e. how can I tell which GPIO pin Vbat is connected to)

Given the importance of holding GPIO21 high (to pull the voltage divider to GND and avoid Vbat voltage hitting the ADC ‘undivided’), I want to make sure I know which variant of V2 board I have before I start testing.

Thanks!

I think I just answered this with some DMM (Fluke 289) measurements on my board; for these measurements, I had USB connected together with LiPo (charging), where my Vbat was 4.15V.

  1. When GPIO21 was HIGH 3.3V, GPIO13 was 0V, GPIO37 was 3.58V, Vext was 2.92V.
  2. When GPIO21 was LOW 0V, GPIO13 was 0V, GPIO37 was 1.28V, Vext was 3.3V.

Ignoring the negligible Rds of the AO3401, with the 320K/100K voltage divider, for case (2) I expected approximately 3.2*1.28=4.096V, which was pretty close to my Vbat of 4.15V.

Also, G6EJD has shared a simple ESP32 voltage reading function on github which applies a polynomial correction to the ADC read. Here’s some example output from my test sketch (when my DMM was measuring Vbat of 4.16V:

-> analogRead(37): 1424
-> ReadVoltage(37): 1.30
-> Battery voltage: 4.17