hello, I just bought a HTCC-AB01 so I’m still learning to use it. I’m trying to display the batterie level of an external 2000 mah 3.7V batterie connected to the board throught the back batterie pin connector. Itried both, the code in the Heltec example and your function but i don’t get anything usable. I tried to modify the code but nothing worked and I can’t get the batterie % or even the batterie voltage. Here the full code I used to test it :
#include “LoRaWan_APP.h”
#include “Arduino.h”
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
/* get the BatteryVoltage in mV. /
delay(10000);
float temp = 0;
float temp_m =0;
uint16_t volt;
uint8_t pin;
pin = ADC;
#if defined(CubeCell_Board) || defined(CubeCell_Capsule) || defined(CubeCell_BoardPlus) || defined(CubeCell_BoardPRO) || defined(CubeCell_GPS) || defined(CubeCell_HalfAA)
/
* have external 10K VDD pullup resistor
* connected to VBAT_ADC_CTL pin
*/
pinMode(VBAT_ADC_CTL, OUTPUT);
digitalWrite(VBAT_ADC_CTL, LOW);
#endif
for (int i = 0; i < 50; i++){ // read 50 times and get average{}
temp += analogReadmV(pin);
Serial.println(temp);
}
volt = temp / 50;
#if defined(CubeCell_Board) || defined(CubeCell_Capsule) || defined(CubeCell_BoardPlus) || defined(CubeCell_BoardPRO) || defined(CubeCell_GPS) || defined(CubeCell_HalfAA)
pinMode(VBAT_ADC_CTL, INPUT);
#endif
volt = volt * 2;
Serial.print("voltage: ");
Serial.println(volt);
}
If someone has an idea that may solve it.
Thanks in advance.