Measuring battery voltage and capacity ESP32 Lite V1.0.0

it is possible to measure the voltage and capacity of the battery on the board ESP32 Lite V1.0.0?

I have not found a solution other then to add a voltage divider as there are no resistors serving that purpose on (the schematic of) this board.
I too would expect a divider installed like on the green Lolin D1 mini pro when buying a board with a battery connection.
Suppose that’s why they call it a ‘light’ version.

A simple voltage divider is the solution for measuring a voltage. You do know that you cant very accurately or even halfway accurately use the voltage to tell you how much capacity is available or how full your battery is as a % right? 0.3v is how much seperates 20% capacity left and 80% capacity left in an 18650 plus your using the battery your measuring so itll have a voltage drop during each measurement. People still do it and use the voltage to infer the capacity but its pretty much worthless.

One could indeed use the discharge measuring system or use EIS to accurately measure capacity or… but I’m not really sure that they are practical in this environment, no?
I am one of those people to use this ‘pretty much worthless’ method to see if it is time to replace my batteries and it shows that the voltage divider proves its purpose here.
Maybe you can enlighten us on a better method?

I really want to use this to help me think when I need to replace the battery.
how to add a voltage divider to the circuit?


I found this example

sensor:
  - platform: adc
    id: solar_plant_batt_voltage 
    pin: GPIO32
    attenuation: auto
    name: ${friendly_name} Battery Voltage
    update_interval: 1s
    accuracy_decimals: 1
    filters:
    #use moving median to smooth spikes
      - median:
          window_size: 10
          send_every: 10
          send_first_at: 10
      - delta: 0.1 #Only send values to HA if they change 
      - throttle: 30s #Limit values sent to Ha
#Convert the Voltage to a battery  level (%)
  - platform: copy
    source_id: solar_plant_batt_voltage
    id: solar_plant_batt_level
    icon: "mdi:battery"
    name: ${friendly_name} Battery Level
    unit_of_measurement: '%'
    accuracy_decimals: 1
    filters:
      - calibrate_linear:
      # Map from voltage to Battery level
          - 0.41 -> 0
          - 3.1 -> 100
      #Handle/cap boundaries
      - lambda: |
          if (x < 0) return 0; 
          else if (x > 100) return 100;
          else return (x);
      - delta: 0.5 #Only send values to HA if they change 
      - throttle: 30s #Limit values sent to Ha

It proves its purpose or it shows you capacities that “seem reasonable” and thats good enough? Have you ever pulled lets say a 40% capacity battery out and done an actual capacity test to verify the accuracy of a voltage based capacity?

Unfortunately, i agree with you. The other methods are much more accurate but, kind of overkill for this situation.

I repeat
I don’t need the exact battery capacity

I want to know that the voltage is much less and the battery needs to be changed

1 Like

That’s what I understood from your initial question and what I too expect from a voltage divider pre-installed on or added to a board.
I am also curious how to do it correctly on that specific board as I have a couple of them lying around. I switched to the Lolin D32 just because it has such a divider built in on pin 35.
Experience told me that it’s good to “play” with the ‘multiply’ and ‘calibrate’ values to bring the measurements close to reality to serve purpose as each set-up results in minor differences.
Note that I have much more intermediate points in my ‘calibrate’ part of the code. I come pretty close to tested remaining capacity.

- platform: adc
    id: batterij_temp007
    pin: GPIO35
    name: "Temp007 Batterij"
    update_interval: 18min  
    unit_of_measurement: "%"
    accuracy_decimals: 0
    icon: mdi:battery-medium
    filters:
      - multiply: 2.0
      - calibrate_polynomial:
         degree: 3
         datapoints:
          - 0.00 -> 0.0
          - 3.30 -> 0.0
          - 3.35 -> 5.0
          - 3.39 -> 10.0
          - 3.44 -> 15.0
          - 3.48 -> 20.0
          - 3.53 -> 25.0
          - 3.57 -> 30.0
#etc
          - 4.00 -> 80.0
          - 4.05 -> 85.0
          - 4.09 -> 90.0
          - 4.14 -> 95.0
          - 4.20 -> 100.0
      - lambda: |-
          if (x <= 100) {
            return x;
          } else {
            return 100;
          }

Edit: modified yaml code to reflect Lolin D32 settings where voltage divider is present on pin 35 (pin is not exposed!)

You repeat? You specifically asked about how to mesure voltage AND capacity in your OP. If anything youd want capacity as thats the metric you use to determine the charge state of a battery and accurately. Voltage is the least accurate metric to determine if a battery is even closer to 80% or 25% because you really cant know for certain.