cant measure voltage from powerbank
Im using a pymkr v3.1 board with a lopy4.
Im trying to read the voltage from a powerbank that is powering the pycom, then send it over LoRa -> ubidots just to get a headsup when the battery is about to die. So I dont really care about exact measurements, I only want to see some kind of difference in my readings when at full battery vs just before dying... Which I dont, since it keeps sending the same number from start to finish.
The code I use to read(from P16) is:
adc = ADC() p_bat = adc.channel(pin='P16', attn=ADC.ATTN_11DB) vol_bat = p_bat.voltage() print(vol_bat)
What do I have to think about when reading voltage? Am I trying to do something impossible? I've read countless of threads now and I still can't get it to work.
All help appriciated!
robert-hh last edited by
@Hejsan-Svejsan You can hook up a lithium battery directly to the Pycom device and measure the voltage of the battery. Any 1 Cell Li-Ion battery with sufficient capacity will do. Using for instance the Pycom expansion board makes that a little bit more convenient, since that contains the charger and a voltage divider to directly measure the battery voltage. There are also small breakouts with the MAX17043 LiPo Fuel Gauge Battery Detection chip available, which gives you even better estimation of the energy level.
@Hejsan-Svejsan you need to get access directly to the battery terminals and measure the voltage there. No point really measuring the regulated supply. You will need at least a few seconds of backup if you want to do anything sensible prior to the power supply collapsing.
@jcaron Yeah I've seen some crazy videos on that... So what is your recomendation? If im using a standalonedevice powered by some kind of battery, connects to lora once a day or on pin interrupt and that cannot be charged since there will be periods of below 0 degree celcius to -15 at lowest, (which for lithiumbatteries is a no go when it comes to charging, effectwise it's not optimal either but it is what it is).
All I want is a headsup if the battery is about to die, doesnt even have to be by much, just an indicator
@Hejsan-Svejsan it’s probably impossible to infer the battery’s voltage from the USB voltage, and even less from the 3.3V voltage, as this goes through yet another regulator.
If you try to take the battery out of the powerbank you need to be very careful to make sure you still have a protection circuit. I haven’t opened any powerbanks, but I wouldn’t be surprised if in many cases the protection circuit were integrated together with the USB stuff. Also you may need to solder new connectors on the battery, which can be tricky (and dangerous).
Remember that LiPo batteries (and all other Lithium-based chemistries) can be very, very dangerous. They can burn or explode if not manipulated very carefully, you need to make sure you don’t overcharge them, they’re not under too high a voltage, they don’t get too hot, they’re not punctured, etc.
Hello and thank's for replying @jcaron, yes Ive been using a normal powerbank(for phones).
So I can't even expect the tiniest difference in voltage numbers? Not even in milivolt? What if I disemble the powerbank and take out the LiPo inside?
@Hejsan-Svejsan when you say a powerbank, do you mean an actual powerbank with an USB output that you use to power the board, or a LiPo battery connected to the LiPo connector?
If the former, the powerbank regulates its output to 5V, so there’s no way to know the actual battery voltage.
I can add that Im reading from 3v3 to pin16 right now.
Also since Im a new user I can only reply once every 600th second FYI