Hi, I also have an heltec lora v3.2 and I want to power the board with a 3.7V Lipo 5000mAh battery. The voltage I am measuring of the battery is 3.9V when fully charged but the board doesn’t give me the right value, every time it gives me 0.00V using this piece of code I found on the forum:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, RST_OLED);
#define VBAT_PIN 1
#define VBAT_READ_CNTRL_PIN 37 // Heltec GPIO to toggle VBatt read connection …
// Also, take care NOT to have ADC read connection
// in OPEN DRAIN when GPIO goes HIGH
#define ADC_READ_STABILIZE 10 // in ms (delay from GPIO control and ADC connections times)
float readBatLevel() {
int analogValue = analogRead(VBAT_PIN);
float voltage = 0.0041 * analogValue;
return voltage;
}
void setup() {
Serial.begin(115200);
Wire.begin(SDA_OLED, SCL_OLED);
// turn on vbat read
pinMode(VBAT_READ_CNTRL_PIN,OUTPUT);
digitalWrite(VBAT_READ_CNTRL_PIN, LOW);
// initialize OLED
delay(100);
Serial.println("Awake");
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 10);
display.println("hello");
display.display();
}
int count = 0;
void loop() {
display.clearDisplay();
display.setCursor(0, 0);
float v = readBatLevel();
display.println(String(v) + " Volt");
display.println(count++);
display.display();
delay(500);
}
Can you help me get this feature working?