HTCC-AB01 V2 does not show the battery level

The previous version of this development board showed the battery level using the instruction: “getBatteryVoltage()”

uint16_t voltage = getBatteryVoltage();

With version v2 the result of the battery level is zero.

I have tried others functions (level=analogRead(ADC); voltage=analogReadmV(ADC);), but the results are not as expected.

Anyone to help me?

I’ve only just started playing with my new V2 boards. I have a different problem with one of them, but the battery reading seems to be OK on the one that’s working. I can’t be 100% sure right at the moment, because the battery is still fully charged, but it’s showing 4.21V (not zero).

I’m also running exactly the same code as I run on my V1 boards, but I did update my Arduino IDE and Heltec [CubeCell] libraries before working with the V2 board.

Indeed the problem comes from using PlatformIO.
With Arduino IDE the instruction works correctly. Thank you

I have the latest Arduino 1.50 release and I’m still getting 0.03V from the V2 board. I’ve tried 1.x and 2.x IDEs, with and without battery, still nothing.
Measured voltage at AO7801, pin 1 = 4.2V
Measured voltage at AO7801, pin 6 = 4.2V
Measured voltage at ADC pin (Header P3, pin 11) = 0.03V
Is it possible the 0R resistor is missing ? If so, where’s it located on the board ?

Try this:

uint16_t voltage = getBatteryVoltage();
Serial.println(voltage);

It will give you the battery level.

I’ve done that - 10:45:28.389 -> BatteryVoltage: 0.00

Can you show your complete code?

#include “LoRaWan_APP.h”
#include “Arduino.h”
#include <Wire.h>
#include “softSerial.h”
#include “TinyGPS++.h”
#include <CayenneLPP.h>

void setup() {
boardInitMcu();
Serial.begin(115200);

#if(AT_SUPPORT)
enableAt();
#endif
pinMode(VBAT_ADC_CTL,OUTPUT);
digitalWrite(VBAT_ADC_CTL,LOW);
uint16_t batteryVoltage = getBatteryVoltage();
float fVoltage = (float)batteryVoltage / 1000.0;
Serial.print(“BatteryVoltage: “);
Serial.print(batteryVoltage);
Serial.print(”, fVoltage: “);
Serial.print(fVoltage);
Serial.print(” (Vext: “);
Serial.print(Vext);
Serial.print(”, VBAT_ADC_CTL: “);
Serial.print(VBAT_ADC_CTL);
Serial.println(”)”);
}

void loop()
{
}

Whether I’m doing the ‘right thing’ or not, all I have in my main loop, where I do my periodic check of all of my sensors, is:

  digitalWrite(Vext, LOW);    // Turn on the external power supply
  delay(10);                  // Give everything a moment to settle down

// other unrelated stuff

  batteryVoltage=getBatteryVoltage();
  Serial.print("[loop-ReadVoltage] Battery Voltage: ");
  Serial.print( batteryVoltage );
  Serial.println(" mV");

There’s no detail in the board schematic that would explain why I might need to turn on Vext to read the battery voltage (nor why I might not have to do anything with VBAT_ADC_CTL), but you could give that a try.

The only other thing I’d suggest is creating a sketch without any unnecessary libraries, in case there’s some conflict in there somewhere. Just for the record, my sketch includes the following:

#include <LoRa_APP.h>
#include <Arduino.h>
#include <AT24C32N.h>
#include <Seeed_BME280.h>
#include <Wire.h>

No luck either way. I’m coming to the conclusion the board is faulty or the 0R is blown. Would be nice to know where it is on the board. Thanks for your suggestions.

I don’t know whether or not this FAQ might help (if you haven’t already seen it). It seems to indicate the location of 0R, and maybe even why Vext needs to be ON.

Thanks for the FAQ UniquePete, although it appears to contradict itself, or am I reading it wrong. The ADC section shows the VBAT feeds the ADC controlled by GPIO7. But the Vext section shows VBAT to ADC controlled by GPIO6 and different resistor values.

Yes, I agree there appears to be a conflict there, but other than that I don’t really have an answer. The first diagram looks more consistent with other CubeCell schematics and the later, ESP32-S3 boards. The second one is the configuration that was presented in schematics of earlier versions of the ESP32 boards.

I think Heltec probably needs to provide some clarification on what’s going on there.

Hello, good afternoon. I am trying to read the Voltage of a battery in my Cube Cell HTTC-AB01 v2, and I only read 0v.
I am connecting a 3.6v battery to the rear connector of the Cube Cell and using the method:
uint16_t batteryVoltageMV = getBatteryVoltage();
I have tried to remove the BR0 resistor but it still shows me 0v.
Anyone know what might be happening?

Here is a sketch, stripped down to the bare essentials, that I am able to use to measure battery voltage on a CubeCell V2 dev board. I am using revision 2.0.3 of the Arduino IDE and 1.2.0 of the CubeCell hardware support package on macOS. I select the relevant port and CubeCell-Board-V2 (HTCC-AB01-V2) from the drop-down menu at the top of the sketch window. The board is as shipped from the factory (I have not modified anything) and the battery is connected through the JST-type connector on the back of the board.

uint16_t batteryVoltage = 0;

void setup() {
  Serial.begin(115200);
  delay(200);
  Serial.println("[setup] CubeCell Battery Voltage Read");
 }

void loop() {
  batteryVoltage=getBatteryVoltage();
  Serial.print("[loop] Battery Voltage: ");
  Serial.print( batteryVoltage );
  Serial.println(" mV");
  delay(5000);
}

If I disconnect the battery, I see a voltage of around 4130 mV (while powered through the USB port), so I don’t think this method is, strictly speaking, always measuring battery voltage. But the same battery measurement code runs on all of my CubeCell dev-boards and does show the battery voltage (as independently measured with a multimeter) running down over time (when only running on battery and reporting battery status via LoRa) until it will no longer power the board.

Thank you for answering. But I have tried to select the HTTC-AB01 v2 board and when compiling I get the following error in the Arduino IDE:

Error resolving FQBN: board

Compiling error for CubeCell-Board-V2(HTCC-AB01-V2).

I have tried different versions of the devManager CUBECell and the error keeps coming out

OK, that’s a different problem. If you search the 'net for that error message you will find several posts on the Arduino forum that offer causes and possible solutions. Basically, it’s a problem with the IDE installation.

Did you choose the correct platform/board?
See here… https://docs.platformio.org/en/latest/boards/heltec-cubecell/cubecell_board.html

For v2 its

platform = heltec-cubecell
board = cubecell_board_v2

2 Likes

That was helpful, thanks!
Turned out, there was

platform = asrmicro650x
board = cubecell_board

in my platformio.ini, which I found somewhere in documentation. getBatteryVoltage always returned 0.
Changing that to

platform = heltec-cubecell
board = cubecell_board_v2

fixed the problem. Now getBatteryVoltage returns proper millivolts.

1 Like

gracias, esa fue mi solución también.