ESP32 + Lipo questions

Hi all,

I appreciate this might be as much a general battery / electronics question but as it’s based around an ESP32, I thought I’d try here first and I imagine many may have experience of such etc.

I am in the process of building an ESP based wind speed indicator to feed my HA system (to gauge good drone flying weather ) and in the process have been experimenting with battery powerable ESP32’s, in this case, the WEMOS Lolin ESP32 lite.

The battery may well be the main power store, if I find a solar solution that can feed it suitably or may just be a buffer etc.

I have added a voltage divider to an ADC input of the ESP32 and have now calibrated it against my DMM to give reasonable voltage readout results (to 2 dp).

I have a couple of questions though:

The battery I have on there at the moment is a 3700 mAh and I believe I spotted somewhere that the battery for this board shouldn’t be greater than 3x the max charging current. That is supposed to be 500mA in which case the max battery would be 1500 mAh?

I wasn’t sure why this might be, other than either the battery might not appreciate being charged slower than 1/3rd it’s nominal capacity or that the charge cut-off might not be that good if it isn’t charging the battery hard enough?

The second question is re the resister divider. I’m currently using 100k+220k that seems to put the 4.2V max in the right range but would those values be ok for noise? By that I mean if I would get less noise by using lower values at the expense of more energy consumption, I might prefer to deal with the latter over the former.

This is the log I got this morning with the ESP32 just on the bench from idle, on charge (till the charging LED went out) and back on battery only again.

Any thoughts appreciated. :wink:

You could use 18650 batteries in a battery holder, which means they can be charged in a separate charger and you could have multiple sets of batteries.

1 Like

Yes you will get a more stable reading by lowering the resistors but keeping the ratio the same. A small capacitor may also help.

I ended up similar resistor values to yours and use a 1uF capacitor as well. Mines stable to around ±0.01V which looks to be worse then yours :slight_smile:

I have an ESP8266 powered by a 5000mah lipo, and solar battery charger/regulator and havent had any issue with that combo. Charger is only 500mah and keeps the 5000mah battery topped up fine.

1 Like

load resistance
The load resistance will have an effect on the voltage divider that you can’t change. It will be in parallel with R2. Temperature of the cell will affect it’s capacity and the voltage
you will read. It’s all a bit of a rabbit hole involving solar charging, battery management, deep sleep, keeping water out and luck.

1 Like

Thanks for the 18650 thought (I have a new / unwanted laptop battery pack I can strip). :wink:

However … and whilst likely not the most efficient solution, I was thinking of a reasonable sized solar panel (I have a few), a small 12V battery (I have a few), a 12 > 5V buck converter then powering the ESP with it’s battery etc.

Like I said, not likely to be the most efficient but possibly the cheapest and easiest for me to implement. :wink:

What type of cap did you use OOI as I think some are more suited to that sort of ‘smoothing’ role than others?

I guess it all depends on what sort of thing we want to glean from this info? For me the battery thing is sort of aside, making sure the battery is being fully charged but not overcharged and is able to support the ESP for a reasonable period if needed. Here is the updated run chart …

Obviously the greater the rage of battery drop the smaller the noise actually becomes in proportion.

I found the heart of the code on the net and tweaked it a bit to suit but am not sure if it’s ‘right’ or not.

sensor:
  - platform: adc
    id: batt_voltage 
    pin: GPIO33
    attenuation: 11db
    name: Battery Voltage
    icon: "mdi:battery"
    update_interval: 3s
    accuracy_decimals: 3
    filters:
      - multiply: 1.439
      - median:
          window_size: 10
          send_every: 10
          send_first_at: 10

At least it works so that’s good for me! :wink:

I was aware of the input load but not what it was so couldn’t really include it etc ( R(L) compared with R(2) on the diagram etc).

I believe from my electronics experience my R(2) would need to be lower than R(L) for R(L) not to play a big part (or at least brought into the calculation).

I started off with 330k & 100k but I think the 330 meant the resultant was a bit too high (as I was getting a raw of 4095 (is it?) even when the voltage was dropping).

The multiply factor will be slightly different for every circuit. Try turning off the multiply factor and see what the raw voltage or measure voltage between ground and adc pin. For a ESP32 it mustn’t get above 3.3V or it will be damaged. Measure the actual voltage across the cell and then adjust the factor to give you the 4.2V for fully charged cell. That will take into account extra resistances. ESP8266 can only measure to 1.0 to 1.1V max so on one device the factor is 4.6 and 4.35 on another .


Voltage is only a guide to capacity.

1 Like

Yeah, that’s basically what I did with my DMM across the battery and the direct values as reported by the ESP32. The division of one into the other got me the multiplier and then after letting it all settle and some more tweaking, got me fairly close. :wink:

I believe the value windowing also helps smooth out any noise.

At the end of the day, I was really checking that 1) The Lolin32 stopped charging the LiPo at the right voltage (it seems to) and 2) now I can get a real world idea of how long this system will run from that 3700mAh cell.

Amazon have just delivered some INA219 Hall Effect current sensors and I’ve ordered some JST-PH 2.0 inline connectors as I’d like to make up a loom that allows for non-destructive measurement of the actual battery charge / discharge currents (probably via another ESP32, set up as a general purpose diagnostic / measurement tool).

Edit: According to my last graph and the one you presented for Li it looks like the discharge ‘curve’ to 80% DOD is pretty linear. If I’m seeing a drop of .05V every 3 hours and we assume 80% capacity is 3.7V, I think that works out to a 30 hour runtime?

Do report how long it lasts on that charge.

1 Like

Will do.

This is in a ‘best case’ situation of course with no wind speed data etc.

Morning,

This is the case so far … (nearly 24 hours).

1 Like