Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Battery voltage measurement always gets an invalid first reading after reset #5276

Closed
dm5tt opened this issue Nov 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dm5tt
Copy link

dm5tt commented Nov 7, 2024

Category

Other

Hardware

Other

Firmware Version

2.5.11 and master

Description

Hardware: HT-CT62 (ESP32C3)

Looks like the first reading coming from the ADC is always invalid and then triggering the first shot of the low voltage battery warning.

My variant.h configuration

#define BATTERY_PIN 1
#define ADC_CHANNEL ADC1_GPIO1_CHANNEL
#define ADC_MULTIPLIER 2 * 1.02
#define BATTERY_SENSE_SAMPLES 5

Relevant log output

DEBUG | ??:??:?? 1 SX126X_RXEN not defined, defaulting to RADIOLIB_NC
DEBUG | ??:??:?? 1 SX126X_TXEN not defined, defaulting to RADIOLIB_NC
DEBUG | ??:??:?? 1 Use MCU pin -1 as RXEN and pin -1 as TXEN to control RF switching
INFO  | ??:??:?? 1 Set RX gain to boosted mode; result: 0
E (3381) gpio: gpio_isr_handler_remove(482): GPIO isr service is not installed, call gpio_install_isr_service() first
INFO  | ??:??:?? 1 SX1262 init success
INFO  | ??:??:?? 1 Not using WIFI
DEBUG | ??:??:?? 1 LoRA bitrate = 118.500000 bytes / sec
INFO  | ??:??:?? 1 PowerFSM init, USB power=1
DEBUG | ??:??:?? 1 State: BOOT
DEBUG | ??:??:?? 1 [Power] Battery: usbPower=0, isCharging=0, batMv=3100, batPct=0      <- Invalid first reading
DEBUG | ??:??:?? 1 [Power] Low voltage counter: 1/10
INFO  | ??:??:?? 1 [RangeTest] Range Test Module - Disabled
INFO  | ??:??:?? 4 [PowerFSM] Loss of power in Powered
INFO  | ??:??:?? 5 [PowerFSM] Loss of power in Powered
DEBUG | ??:??:?? 5 [PowerFSM] State: ON
INFO  | ??:??:?? 11 [EnvironmentTelemetry] Environment Telemetry: init
INFO  | ??:??:?? 11 [EnvironmentTelemetry] Init sensor: SHT31
[ 11659][W][Wire.cpp:301] begin(): Bus already started in Master Mode.
INFO  | ??:??:?? 11 [EnvironmentTelemetry] Opened SHT31 sensor on i2c bus
(...)
DEBUG | ??:??:?? 21 [Power] Battery: usbPower=0, isCharging=0, batMv=3963, batPct=77  <- Correct second reading.
@dm5tt dm5tt added the bug Something isn't working label Nov 7, 2024
@dm5tt dm5tt changed the title [Bug]: Battery voltage measurement always gets an invalid first reading after reset. Triggers "Low Battery" warning. [Bug]: Battery voltage measurement always gets an invalid first reading after reset Nov 7, 2024
Blake-Latchford added a commit to Blake-Latchford/firmware that referenced this issue Nov 13, 2024
Power::readPowerStatus is called on startup,
but AnalogBatteryLevel::getBattVoltage
skips the read because 5 seconds have not
elapsed since last_read_time_ms, which
is initialized to zero.

`batMv=3100` is reported because
AnalogBatteryLevel::last_read_value is
initialized as:
```
float last_read_value = (OCV[NUM_OCV_POINTS - 1] * NUM_CELLS);
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant