Hi,
Ive just been trying out my Tracker v1.1 and testing it to read the VBAT off GPIO1.
I am powering the tracker through the JST 2.5mm battery connector underneath it with an 18650.
For some reason all I can see is a random voltage of about 1.14V.
Not sure whats going on but I had no such issues with the Wifi LoRa 32 V3’s
Here is my code, I am also looking at trying to get GPS lock too as I an new to the UC6250.
Any help appreciated.
#include “HT_st7735.h”
#include “Wire.h”
#include “Heltec.h”
#include <HardwareSerial.h>
HT_st7735 st7735;
HardwareSerial mySerial(1); // UART1 for GPS (RX=16, TX=17)
#define VBAT_CONTROL_PIN 2 // GPIO2 controls the voltage divider
#define VBAT_ADC_PIN 1 // GPIO1 = ADC1_CH0
void setup() {
Serial.begin(115200);
Heltec.begin(true, false, true); // OLED on, LoRa off, Serial on
st7735.st7735_init();
st7735.st7735_fill_screen(ST7735_BLACK);
st7735.st7735_write_str(10, 10, “Initializing GPS…”, Font_7x10, ST7735_WHITE, ST7735_BLACK);
// Set up GPS
mySerial.begin(9600, SERIAL_8N1, 16, 17);
// Set up VBAT reading
pinMode(VBAT_CONTROL_PIN, OUTPUT);
digitalWrite(VBAT_CONTROL_PIN, HIGH); // Enable the voltage divider
delay(10); // Small delay to allow voltage to stabilize
}
void loop() {
st7735.st7735_fill_screen(ST7735_BLACK);
// — Battery Voltage —
int vbat_read = analogRead(VBAT_ADC_PIN);
float batteryVoltage = (vbat_read * 4.9) / 4095.0; // According to Heltec
String vbatText = “VBAT: " + String(batteryVoltage, 2) + " V”;
st7735.st7735_write_str(10, 10, vbatText.c_str(), Font_7x10, ST7735_WHITE, ST7735_BLACK);
Serial.println(vbatText);
// — GPS Data —
String gpsData = “”;
while (mySerial.available()) {
char c = mySerial.read(); gpsData += c; delay(1); // short delay to catch full sentence
}
if (gpsData.length() > 0) {
st7735.st7735_write_str(10, 30, "GPS:", Font_7x10, ST7735_GREEN, ST7735_BLACK); st7735.st7735_write_str(10, 45, gpsData.c_str(), Font_7x10, ST7735_WHITE, ST7735_BLACK); Serial.println("GPS: " + gpsData);
} else {
st7735.st7735_write_str(10, 30, "Waiting for GPS fix...", Font_7x10, ST7735_YELLOW, ST7735_BLACK);
}
delay(2000); // Refresh every 2 seconds
}