Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions variants/heltec_v4/HeltecV4Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,19 @@ void HeltecV4Board::begin() {
}

uint16_t HeltecV4Board::getBattMilliVolts() {
analogReadResolution(10);
analogReadResolution(12);
analogSetPinAttenuation(PIN_VBAT_READ, ADC_2_5db); // divider puts pin at 0.61-0.86V; 2.5dB gives headroom over ADC_0db for chip variation
digitalWrite(PIN_ADC_CTRL, HIGH);
delay(10);
uint32_t raw = 0;
uint32_t raw_mv = 0;
for (int i = 0; i < 8; i++) {
raw += analogRead(PIN_VBAT_READ);
raw_mv += analogReadMilliVolts(PIN_VBAT_READ);
}
raw = raw / 8;
raw_mv /= 8;

digitalWrite(PIN_ADC_CTRL, LOW);

return (adc_mult * (3.3 / 1024.0) * raw) * 1000;
return adc_mult * raw_mv;
}

const char* HeltecV4Board::getManufacturerName() const {
Expand Down
2 changes: 1 addition & 1 deletion variants/heltec_v4/HeltecV4Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "LoRaFEMControl.h"

#ifndef ADC_MULTIPLIER
#define ADC_MULTIPLIER 5.42
#define ADC_MULTIPLIER 4.9 // (R1+R2)/R2 = (390k+100k)/100k
#endif

class HeltecV4Board : public ESP32Board {
Expand Down