Reading signal from open drain connected to LED - Page 1
Forum section: electronics / projects

author: okw
author_rank: Frequent Contributor
timestamp: November 24, 2024, 11:53:30 pm
content: I'm trying to read the value of a charge status pin (TP4056, charge done, open drain) with LED are connected. LED anode is on the TP4056 VDD rail (USB, 5V), as I don't want the LED to draw anything when USB is not connected. However, I'm reading 2.56V when charging (status is low, LED lit) and 2.01V when charge is done (stauts floats, LED dark).How do I solve it so MCU can read a proper low, without affecting the LEDs?

author: Benta
author_rank: Super Contributor
timestamp: November 25, 2024, 12:15:10 am
content: Put a 47 kohm resistor between your test leads, redo the measurement and come back with the voltages you measured.

author: okw
author_rank: Frequent Contributor
timestamp: November 25, 2024, 12:33:17 am
content: 2.194V (charging) and 1.987V (done).

author: Someone
author_rank: Super Contributor
timestamp: November 25, 2024, 06:26:17 am
content: Quote from: okw on November 25, 2024, 12:33:17 amSeems like you'll need to provide significantly more detail. Why do you expect the chip to do anything specific when USB is not connected?How can a pull down read a higher voltage when pulled down than when floating?Quote from: okw on November 24, 2024, 11:53:30 pm

author: okw
author_rank: Frequent Contributor
timestamp: November 25, 2024, 09:40:52 am
content: Quote from: Someone on November 25, 2024, 06:26:17 amI don't expect that. And I don't care about the status when USB is not connected. I only care whether the battery is getting charged or not when USB is connected.Quote from: Someone on November 25, 2024, 06:26:17 amThat's why I postedNothing else is on the signal (i used to have a 200k 3.3V pull-up, but removed it). The charger (TP4056) STDBY pin --> 1k (and LED up to VCC 5V) --> MCU.If I remove the LED it reads correct, battery in reads high, and out low.

author: Someone
author_rank: Super Contributor
timestamp: November 25, 2024, 10:43:55 am
content: Quote from: okw on November 25, 2024, 09:40:52 amYou'll need to draw a schematic of exactly what configuration you have, and details of how you're taking the measurement. Photocurrent would tend to pull the open collector up not down.

author: okw
author_rank: Frequent Contributor
timestamp: November 25, 2024, 10:57:27 am
content: The MCU_CHARGE_DONE goes directly to the ESP32-C3. I also have a DW01 protection circuit, which I omitted for readability.

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 25, 2024, 12:01:26 pm
content: That is what you get when you measure between the series resistor and the LED. Connect it like shown in the attached image and you will measure ~0 when the LED is lit.

author: okw
author_rank: Frequent Contributor
timestamp: November 25, 2024, 08:03:34 pm
content: Thanks so much.By the way, I see dim flickering on the red LED when charging is finished (it should be completely off). Not sure if the TP4056 is from a bad batch or what's going on. I guess they're all knock-offs anyway...Any trick to mediate this?Could it be cause it's connected directly to the ESP32-C3?