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 2float 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);
}