-
Notifications
You must be signed in to change notification settings - Fork 266
Open
Description
Battery Voltage Reading 0.00V on Heltec WiFi LoRa 32 V3 with E-Ink
Long and short iv used the example and the it shows 0.00 and no reading ?
Battery Voltage Reading 0.00V on Heltec WiFi LoRa 32 V3 with E-Ink
Board: Heltec WiFi LoRa 32 V3
Pin Used for Battery Voltage: GPIO7 (ADC1_CHANNEL_6)
Display: Heltec E-Ink Display (likely 2.13-inch based on project context)
Problem Description:
I'm attempting to read the battery voltage on my Heltec WiFi LoRa 32 V3. The voltage is consistently displayed as "0.00V" on the E-Ink screen.
Relevant Code:
-
Pin Setup in
setup():pinMode(7, INPUT); // analogReadResolution(12); // This was present in factory test, tried with and without
-
getBatteryVoltage()function:// Constants derived from factory test code const float RESOLUTION_FACTOR = 0.000244140625; // 1/4096 for 12-bit ADC const float ADC_REF_VOLTAGE = 3.3; // ESP32 ADC reference voltage const float DIVIDER_COEFFICIENT = 4.01; // Voltage divider factor float getBatteryVoltage() { int rawValue = analogRead(7); // Serial.print("Raw ADC (GPIO7): "); // For debugging // Serial.println(rawValue); float voltage = rawValue * RESOLUTION_FACTOR * ADC_REF_VOLTAGE * DIVIDER_COEFFICIENT; return voltage; }
-
Display Code Snippet (in
drawBackground()):display.setFont(&tahoma7pt7b); // Smaller font for battery float battVoltage = getBatteryVoltage(); char battBuffer[15]; snprintf(battBuffer, sizeof(battBuffer), "Batt: %.2fV", battVoltage); // ... (code to display battBuffer) ...
Context & Troubleshooting Steps Taken:
- The pin (GPIO7) and calculation constants (
RESOLUTION_FACTOR,ADC_REF_VOLTAGE,DIVIDER_COEFFICIENT) are based on the official Heltec factory test code for this board, which successfully reads the battery voltage. - The factory test code also included
analogReadResolution(12);. I have tried including this in mysetup()function, but it did not change the 0.00V reading. - The rest of the E-Ink display functionalities, GPS, and LoRa (though LoRa is not actively used in this specific test) seem to be working as expected.
- I've tried adding
Serial.printfor the raw ADC value, but I'm currently viewing output on the E-Ink. If serial debugging is crucial, I can set that up.
Factory Test Code Reference (Conceptual):
The factory test code had a function similar to this:
// #define Resolution 0.000244140625
// #define battary_in 3.3
// #define coefficient 4.01
// float battery_levl;
// void battery() {
// analogReadResolution(12);
// battery_levl = analogRead(7) * Resolution * battary_in * coefficient;
// }
// It also had a VextON() function:
// void VextON(void)
// {
// pinMode(18,OUTPUT);
// pinMode(46,OUTPUT);
// digitalWrite(18, HIGH);
// digitalWrite(46, HIGH);
// }
// And VextON() was called in its setup().
Metadata
Metadata
Assignees
Labels
No labels