meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3k stars 715 forks source link

[Feature Request]: Battery Chemistry Type Selection #3910

Closed CheeseIsGood27 closed 1 month ago

CheeseIsGood27 commented 1 month ago

Platform

NRF52, ESP32, RP2040, Linux Native, other

Description

Feature request to add a drop-down menu or way to select battery chemistry for INA219, INA260, or INA3221 sensor under the power config menu.

Lines 14-28 of power.h seem to define several battery chemistry types under the "OCV_ARRAY" variable:

ifndef OCV_ARRAY

ifdef CELL_TYPE_LIFEPO4

define OCV_ARRAY 3400, 3350, 3320, 3290, 3270, 3260, 3250, 3230, 3200, 3120, 3000

elif defined(CELL_TYPE_LEADACID)

define OCV_ARRAY 2120, 2090, 2070, 2050, 2030, 2010, 1990, 1980, 1970, 1960, 1950

elif defined(CELL_TYPE_ALKALINE)

define OCV_ARRAY 1580, 1400, 1350, 1300, 1280, 1250, 1230, 1190, 1150, 1100, 1000

elif defined(CELL_TYPE_NIMH)

define OCV_ARRAY 1400, 1300, 1280, 1270, 1260, 1250, 1240, 1230, 1210, 1150, 1000

elif defined(CELL_TYPE_LTO)

define OCV_ARRAY 2700, 2560, 2540, 2520, 2500, 2460, 2420, 2400, 2380, 2320, 1500

else // LiIon

define OCV_ARRAY 4190, 4050, 3990, 3890, 3800, 3720, 3630, 3530, 3420, 3300, 3100

endif

endif

REQUEST: A drop-down menu, or even a few lines to define a custom "OCV_ARRAY" value in the power config would be very useful for alternative battery chemistries.

CONCERN: Most boards used for Meshtastic have an on-board LiPo charge circuit wired direct to an ADC pin for voltage reading. I don't think the modified "OCV_ARRAY" would cause an issue related to the ADC circuit and voltage divider, but I'm uncertain.

ISSUE THIS SOLVES: Currently, I have a single LTO cell boosted to power a Heltec V3 using an INA219 for voltage sensing. The INA219 works perfectly and replaces the ADC voltage reporting as expected (#3283 ). The problem is that when the voltage is reported back at 2.8v (full charge for an LTO) the Heltec goes to sleep because it's below the 3.2v cutoff of a standard LiPo. I cannot currently monitor my battery voltage and keep my node awake simultaneously without custom-editing the firmware or hacking the ADC voltage divider to fake the expected voltage.