I have two active low signals (CHRG and STDBY) from a single li-ion battery charger IC TP4056 Datasheet.
CHRG is high impedance when charging is not taking place and Low when charging is taking place STDBY is high impedance when charging is not complete and low when charging is complete.
I am using this IC within an embedded circuit controlled by ESP32, but I only have one GPIO left and I want to detect whether charging is taking place and if the battery is fully charged.
Kindly suggest some solutions
ESP32 logic signals are 3.3V
So, I have attached a pullup, this way now the CHRG is low when batt is charging and high otherwise, and STDBY is low when the battery is fully charged and high otherwise.
So using this can anyone suggest a solution?
If both are at the high impedance state voltage will be VCC
if CHRG gets low, the voltage will be pulled to 66%VCC
if STDBY gets low the voltage will be pulled to 50% VCC
In case it's needed, if both get low it will be pulled further down, below 50% of VCC.
OK if they are possible then as you can't get 4 possibilities with only 1 bit, you either need 2 bits (2 GPIOs) or indeed move to the analog representation
Yes, but it depends on what he really needs to know. Will he be doing something different depending on whether the battery is charging or is fully charged? Or does he just need to know that one or the other is true, and that no "impossible" is taking place. In that case a SN74LVC1G86 would work. But as you say, a second GPIO is really the answer if he can find one.
This is indeed a way to know. I was trying to make out a solution with a MOSFET. I think I would need to use a PMOS. just need to figure out the configuration
I did not take consideration of the fact that battery not present or faulty would also be one of the states, moreover I also need to take care of low battery State. My circuit contains an LCD which would show all these status i.e.
Charging
Fully charged
Battery fault/ not present
Low battery
I dug out my supply of TP4056 modules, and found that when there is no battery present, the charging LED flashes, and the fully-charged LED is on solid. I suspect that behavior may vary from one manufacturer to another.
I have never tried it, but my suspicion is that if the battery discharges to the point that the protection circuit kicks in, it would behave like no battery present. That's because the protection circuit disconnects the negative battery terminal from the circuit ground. But I've never tested it.
My memory from trying to get the TP4056 to work with solar panels is that at certain intermediate voltages both LEDs may light up solid. But that should not happen if you are charging from 5V USB power.
What if you just measure the battery voltage on an ESP32 analog pin through a resistive divider, and show that number on the display. Then the user could draw his own conclusions about the state of the battery. Of course the divider would draw current, which is not ideal.