EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: Stealthrt on October 18, 2017, 05:32:29 am

Title: 4n25/35 optocoupler detect led on/off
Post by: Stealthrt on October 18, 2017, 05:32:29 am
Hey all i am just wondering if my drawing below is correct in order to have an arduino detect an on or off led on another board using a optocoupler?

(https://i.stack.imgur.com/lxtH1.jpg)

My thoughts of the above drawing is that when the led is on it will trigger the relay inside and send 5v to the arduino digital pin to read. 0v if the relay inside is not connected.

I also would possibly need to tell the arduino digital pin that its an input pullup like this:
Code: [Select]
pinMode(pin, INPUT_PULLUP);
please advise if this is correct or not.
Title: Re: 4n25/35 optocoupler detect led on/off
Post by: george.b on October 18, 2017, 06:07:17 am
Hey all i am just wondering if my drawing below is correct in order to have an arduino detect an on or off led on another board using a optocoupler?

Kinda, yeah. It'd be good to add a 1k to 10k resistor from pin 4 to ground.

My thoughts of the above drawing is that when the led is on it will trigger the relay inside and send 5v to the arduino digital pin to read. 0v if the relay inside is not connected.

There is no relay as such inside - it's a phototransistor ;)

I also would possibly need to tell the arduino digital pin that its an input pullup like this:
Code: [Select]
pinMode(pin, INPUT_PULLUP);
please advise if this is correct or not.

Nope, if anything, you'd need a pulldown. You could save the one resistor I mentioned by setting the input as you said, then connecting optocoupler pin 5 to the digital input, and pin 4 to ground.
Title: Re: 4n25/35 optocoupler detect led on/off
Post by: eblc1388 on October 18, 2017, 07:57:37 am
Hey all i am just wondering if my drawing below is correct in order to have an arduino detect an on or off led on another board using a optocoupler?

You cannot directly connect the optocoupler inputs to the LED you want to monitor. The original LED will not be able to light anymore if you do so.

There are two possible ways to do so as shown in the image. Method#1 is the preferred method.



Title: Re: 4n25/35 optocoupler detect led on/off
Post by: george.b on October 18, 2017, 11:21:09 am
You cannot directly connect the optocoupler inputs to the LED you want to monitor. The original LED will not be able to light anymore if you do so.

Ah, true, the LED in a 4N25/4N35 is infrared, with a lower forward voltage than a red LED. I didn't think of that.
Title: Re: 4n25/35 optocoupler detect led on/off
Post by: Stealthrt on October 19, 2017, 06:38:35 am
im hooking the 4n25 up to the hm-10 led:
(https://i.stack.imgur.com/7y1Pq.jpg)
Title: Re: 4n25/35 optocoupler detect led on/off
Post by: woody on October 19, 2017, 07:06:14 am
I skimmed the datasheet on the HM10 for 30 seconds so I might be completely wrong, but it seems there is a command to query the status of the system LED:  AT+PIO1?

If that works it saves you a couple of components  :)