Not a microcontroller question but a Electronic problem.

Hello my project involves a DIY emergercy light project. But the problem I'm having is that i need to figure out a way to detect when there is no power coming in the charger port. I'm using a TP4050 to charge the 18650 battery. I just can not figure out a way to detect when the power is out to turn on the Leds. Does anyone have a idea on how i can do that without having to put in a micro controller?

Joseph

Mains relay?

Hello AWOL i was looking to do something on the DC side of detecting maybe? But i never did anything without a microcontroller. only problem is i have a tight space. of 4 inches by 2 inches by 2 inches.

Joseph

Can you give us more information about your circuit? For instance, how is the TP4050 powered?

If it is powered by the USB input you could use a 5V relay or a Pchannel MosFet.

josephchrzempiec:
Hello AWOL i was looking to do something on the DC side of detecting maybe? But i never did anything without a microcontroller. only problem is i have a tight space. of 4 inches by 2 inches by 2 inches.

Joseph

Mains is AC so no easy getting around that. A small mains relay is one approach. There are also opto-couplers made for detecting AC mains power. Pretty much a matter of what you want to do when mains power goes away and how you plan to do it.

Ron

Hello Sorry if i didn't add that part how is it all wired up. Right now for test I'm using a TP4050 which can be found here. How how i have it wired up is input has 5v DC coming in and the output is a 18650 battery connected directly to a LED for Test i have a toggle button to turn it on and off. going from the batterry has a plus and minus to the TP4050 on the output to charge it. Sorry i do not have a wiring diagram. But basically it's just a simple wiring.

Joseph

What I'm trying to do is if there is no DC side coming in that means main is off. I need to figure out a way to detect that Dc 5v coming into the TP4050 is nothing is coming in to turn on the leds. and to turn it off if there is mains power on.

This is more like a automatic emergercy light that you see in stores when the power is off.

Joseph

josephchrzempiec:
What I'm trying to do is if there is no DC side coming in that means main is off. I need to figure out a way to detect that Dc 5v coming into the TP4050 is nothing is coming in to turn on the leds. and to turn it off if there is mains power on.

This is more like a automatic emergercy light that you see in stores when the power is off.

Joseph

So you are just looking at 5 volts which is there or not there. Drive a small 5 volt coil relay. A 5 volt coil DPDT relay and use the contacts to switch whatever you want to switch. Just use the relay contacts. A Google of 5 Volt Coil DPDT relay will bring up a dozen or more which fall under "miniature" and should fit in a confined space. Just place a small flyback diode like a 1N4002 across the coil.

Ron

All the emergency lights I have seen all use a 6 volt lead-acid storage battery that is kept charged by the AC power and it also has a relay the is held closed by the AC power. When power goes off, the 6 volt battery powers the emergency light for an hour or so. Why do you need to design a high-tech version?

Paul

Hello paul I'm not trying to design a high tech version. But in fact a low tech one. Which just a 18650 battery a charger and some leds. Nothing high tech about it. My only problem is to detect when the dc side charging the battery is off the leds comes up. I'm not trying to do anything with mains power. It's not that i don't work with mains power I'm trying to do something in the low end power.

Joseph

josephchrzempiec:
Hello paul I'm not trying to design a high tech version. But in fact a low tech one. Which just a 18650 battery a charger and some leds. Nothing high tech about it. My only problem is to detect when the dc side charging the battery is off the leds comes up. I'm not trying to do anything with mains power. It's not that i don't work with mains power I'm trying to do something in the low end power.

Joseph

Your charger board has 2 LEDs, a red one and a green one. One or the other will always be lit if the charger is connected and working. Can you determine if both LEDs are off? That means no charging.

Paul

The charging module is a tp4056.
You should be able to achieve power fail detection, lighting a led using two npn transistors and 3 resistors.
Transistor 1 is switched on when 5volts from the dc supply is available.
This transistor, when switched on, pulls the base of transistor 2 to the common ground, against its pull-up resistor powered from the battery side, keeping transistor 2 switched off.
When the 5volt supply fails, transistor 1 switches off and transistor 2 switches on and, as a low side switch, controls the emergency lighting led.