Skip to content

Battery Monitoring

Gal Zaidenstein edited this page Sep 20, 2018 · 4 revisions

Estimating battery capacity using Voltage-Discharge rate

The battery Monitoring in MK32 is based on measuring the voltage of the battery
and fitting the battery percent to a voltage-discharge rate graph:

* This is currently implemented using an approximation between max and cutoff voltage values. * It is important to note that for a better fit a table holding the voltage and corresponding battery percent would be better.
  • This method of implementing battery monitoring is currently used with a 2C 3.7V LiPo Battery.
  • The battery is connected via a voltage divider to an analog pin on the ESP32 where R1= 47[kOhm] and R2=22[kOhm].

* I have not tested the accuracy of this method.

Adding battery monitoring to your keyboard

  1. If you are using a 2C 3.7V LiPo Battery use a voltage divider as stated above to connect to an analog pin of your choice.
  2. In order to enable battery monitoring uncomment BATT_STAT in keyboard_config.h.
  3. Set BATT_PIN to the adc1 channel corresponding to your selected gpio pin.
  4. If you would like to modify the resistors and battery type please modify battery_monitor.h accordingly. Please make sure you have an understanding of what you are doing before doing so.