# How to detect if LED is switched on in external circuit using Arduino NANO?

I want to detect when an LED is powered on using an Arduino NANO. The LED is part of an external circuit. The LED uses about 1.8V. Would the circuit below allow me to detect when the LED is switched on? Is this the correct method of doing it? (The LED in the diagram represents the external circuit).

• What's that component hiding under that blue wire on rows 6 to 10, column B, on the breadboard? (this is just for my benefit, I can't see it)
– user23244
Commented Aug 21, 2017 at 16:53
• You could use A0 to sense the actual voltage or use an light-depended-resistor (LDR) to measure if the LED is lit (but take environmental light into account).
– aaa
Commented Aug 21, 2017 at 16:58
• @KingDuken a pushbutton, one of the single row types. (Which is why schematics are usually preferred)
– aaa
Commented Aug 21, 2017 at 16:58
• @KingDuken It's a push to connect button switch.
– user37547
Commented Aug 21, 2017 at 16:58
• @Paul How would the circuit be setup to use A0 to detect the voltage? Would the above method also work?
– user37547
Commented Aug 21, 2017 at 17:08

I'm afraid your circuit does not work. In fact, the base of the transistor is always connected to the power, regardless the LED being ON or OFF. Therefore the BJT would be always in the ON-state. Also a current limiting resistor in series to the LED is missing (but I think that it was just for sake of simplicity).

Assuming that:

• you can mount in series something to the LED

• an additional 1.3-1.5V voltage drop will not cause too much issues (to be short: if the external circuit power supply is "large enough", and if you will not be too much upset if the LED luminosity will be smaller).

• You want to sense a signal LED, i.e. let's say with a current smaller than 20 mA.

Then, the safest way would be to use an optocoupler, such as 4N25-4N35. Put the LED of the optocoupler (transmitter side) in series to the LED you want to "sense", and use the phototransistor side to sense the LED status: it's emitter goes to the GND to your Arduino Nano, the collector to any input, with pull-up (The pull-up is mandatory!).

In this way, when current flows across the LED, it will also flow in the optocoupler LED, therefore the optocoupler phototransistor will be ON.

Also, using the optocoupler the two systems are electrically insulated each other (and you won't need to share the grounds).

Below you can find an example.

EDIT: If you cannot wire the optocoupler LED in series (e.g. not enough voltage headroom because the power supply is too close to the LED Vf, or your LED is already on a PCB), you can connect the optocoupler in parallel. Assuming the LED current is much larger than 1mA, you can use the following circuit. Choose RO so that the current flowing on the optocoupler will be 1mA (390-470 Ohm in your case). Usage of high current-transfer-ratio (CTR) optocoupler is suggested, but this might work also with a 4N25 or 4N35 (you'll be pretty close to the limit...)

• Unfortunately I am unable to mount anything in series to the LED, only in parallel as it is on manufactured PCB.
– user37547
Commented Aug 21, 2017 at 18:43
• Then you could connect the series of a 470-Ohm resistor and the optocoupler's LED in parallel to the LED you want to sense. When the LED is ON, there will be 1.8V across it. 1.4 V fall across the optocoupler's LED, and the remaining 0.4V across the 470-Ohm resistor. You'll have therefore 0.85mA into the optocoupler's LED, and assuming a 0.2 CTR (current transfer ratio) for the 4N35, you'll get 170 uA out of the collector. If the internal pull-up is something about 30k, that should be enough. Instead of 4N35, I suggest using a SFH618A, which is low-input current and has far higher CTR values. Commented Aug 21, 2017 at 19:02
• Would this prevent the LED on the actual device from illuminating?
– user37547
Commented Aug 21, 2017 at 20:24
• No, as you're not directly connecting in parallel the optocoupler's LED to your LED (this would prevent the original LED from turning on, as the optocoupler has a lower forward voltage than your LED). Instead, you're connecting the series "resistor + optocoupler's LED" in parallel to the LED you need to sense. Of course, the LED you need to sense will be a bit dimmer, as 850 uA will flow in the optocoupler's LED instead of the original LED. However I assume that the LED you're sensing is driven with a much higher current (5-20mA), so 850uA make little difference. Commented Aug 22, 2017 at 6:12
• Edited the answer to include the parallel connection. Commented Aug 23, 2017 at 7:11

An led is on if

1. There is voltage across I th or

2. There insufficient voltage across it, or

3. There is current through it, or

4. It generates light output, or

5. It generates sufficient light output.

...

Based on each of the above, there is an answer to your question.

No, you will not detect the LED state at all, as your transistor base is connected to the target circuit's supply rail, not a switched node.

Additionally, your circuit risks burning out the LED as it lacks a current limiting resistor.

Speaking more generally, the only safe way to do this with a fully unknown circuit is to have an optical sensor looking at the LED.

If you can determine that it is safe to make an electrical connection to the circuit (ie, that the internal ground is not riding on mains voltage) and that the point of the circuit you want to measure is within an allowed voltage above that, then you can connect the grounds and measure the switched side of the LED / resistor. But until you have far more electrical engineering experience, you are probably not in a position to make this safety determination. Even battery powered devices can generate dangerous voltages internally.

It's important that you not connect between the LED and resistor, but rather to whichever side of that series unit is not connected to a supply rail, as the voltage drop on the LED itself may not be sufficient to register.

Certain fancier LED drivers may give you problems, for example if they regulator current internally. Also, LEDs with PWM brightness control may require filtered polling, or even interrupts / hardware pulse-in.