Author Topic: 4n25/35 optocoupler detect led on/off  (Read 1512 times)

0 Members and 1 Guest are viewing this topic.

Offline StealthrtTopic starter

  • Regular Contributor
  • *
  • Posts: 82
4n25/35 optocoupler detect led on/off
« 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?



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.
 

Offline george.b

  • Frequent Contributor
  • **
  • Posts: 383
  • Country: br
Re: 4n25/35 optocoupler detect led on/off
« Reply #1 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.
 

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: gb
Re: 4n25/35 optocoupler detect led on/off
« Reply #2 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.



 

Offline george.b

  • Frequent Contributor
  • **
  • Posts: 383
  • Country: br
Re: 4n25/35 optocoupler detect led on/off
« Reply #3 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.
 

Offline StealthrtTopic starter

  • Regular Contributor
  • *
  • Posts: 82
Re: 4n25/35 optocoupler detect led on/off
« Reply #4 on: October 19, 2017, 06:38:35 am »
im hooking the 4n25 up to the hm-10 led:
 

Offline woody

  • Frequent Contributor
  • **
  • Posts: 291
  • Country: nl
Re: 4n25/35 optocoupler detect led on/off
« Reply #5 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  :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf