Wireless Tracker Battery

Heltec Wireless Tracker V1.1
I tried to read the battery voltage without success.
I used Vbat_Read (GPIO_1) and ADC_CTRL (GPIO_2) as shown in the HT-Tracker V1 pin map. The result is always 0, even though the board runs on the battery. Battery voltage measured with my multimeter is 3.85V.

#include <Wire.h>
#include “HT_st7735.h”

HT_st7735 st7735;

#define VBAT_READ 1
#define ADC_CTRL 2

float readBatLevel() {
USBSerial.println(“readBatLevel”);
pinMode(ADC_CTRL,OUTPUT);
digitalWrite(ADC_CTRL, LOW);
delay(50); // let GPIO stabilize
int analogValue = analogRead(VBAT_READ);
USBSerial.println("BatLevel = " + String(analogValue));
float voltage = 4.9 * analogValue;
USBSerial.println("Voltage = " + String(voltage));
return voltage;
}

void setup() {
USBSerial.begin(115200);

// initialize OLED
st7735.st7735_init();
st7735.st7735_fill_screen(ST7735_BLACK);
delay(1000);
}

void loop() {
float bV = readBatLevel();
st7735.st7735_fill_screen(ST7735_BLACK);
st7735.st7735_write_str(0, 0, “Battery”);
st7735.st7735_write_str(0, 40, "Volt: " + String(bV,2));
delay(2000);
}

The Tracker has inverted logic - write CTRL to High!

Or, even better, set ADC_CTRL to INPUT_PULLUP as mentioned in the Tracker power consumption thread and proven by your measurements, @bns. I really do not like the idea that the whole current a GPIO can output is shorted to GND when setting ADC_CTRL to HIGH. I have no clue why anyone would implement an ADC enable logic in this way, it does not make any sense. But this is what we need to deal with. At the very least, if you really do want to pull the ADC_CTRL pin hard to HIGH for whatever reason, just do this right before reading the ADC and set it to LOW again immediately afterwards.