4n35 Optocoupler as Switch

Hello..

Im working on a project that is going to use a bistable (locking) relay in a 5/12V DC application. I would like to test if the relay is providing power. My thought was to use a 4n35 and hook pins 1,2 with proper resistor to the relay power output side. Can the base and emitter on the 4n35 act as a NO/NC switch that I can test with a digital pin on an esp-12e?

That should work.
See internet images for schematic.

https://www.google.com/search?tbm=isch&source=hp&biw=980&bih=625&ei=WMDsWvCqI8iS0gKOuafwCg&q=4n32+circuit+example&oq=4n32&gs_l=img.1.1.0l2j0i30k1l3j0i24k1l5.3150.23040.0.25163.26.16.10.0.0.0.113.1084.7j4.11.0....0...1ac.1.64.img..5.20.1174.0..0i5i30k1j0i10k1.0.Ocr4hfCM-Bk

You also need a pull-up resistor on the output (collector) as shown in Larry's link and the easiest thing is to enable the Arduino's internal pull-up. Without a pull-up there is no voltage to "switch". :wink:

And you connect to the collector & emitter. It's a photo-transistor so there's normally no electrical connection to the base.

What does the opto buy you? You’re already got a relay that provides isolation. A resistive divider may be a cleaner solution. All things considered, without a schematic, all you’re getting are guesses as to the appropriateness of an optocoupler.

Further, depending upon the relay design, I’d be concerned that’s not enough current to ensure proper contact engagement since power relays cannot be counted on to switch microamp signal levels.

avr_fred:
What does the opto buy you? You’re already got a relay that provides isolation. A resistive divider may be a cleaner solution. All things considered, without a schematic, all you’re getting are guesses as to the appropriateness of an optocoupler.

Further, depending upon the relay design, I’d be concerned that’s not enough current to ensure proper contact engagement since power relays cannot be counted on to switch microamp signal levels.

I agree the relay is already providing the isolation. The circuit is pretty straight forward. esp-12e triggers relay via low pulse (see below), load power is then applied to device I want to control. Since the relay is latching you never know what position it is in.

https://www.ebay.com/itm/1ch-5V-Latch-Relay-Module-Flip-Flop-Bistable-Self-locking-Trigger-Switch-Board-/112234912755

Thank you for the link, most helpful.

As with most eBay stuff from China, the reality and the description are two different things. What you have there is a not true bistable/latching relay. No, it’s your run of the mill 50 cent 5 volt relay with some mystery four leaded device that does the trigger/hold of the relay. A true bistable relay holds its position without power, the relay you’ve linked to does not and it will always be off upon power up.

The bad news is that this relay will require 60-80ma at all times when the relay is engaged. If you had intended to use this as a zero power latch for battery operation, it’s not going to work.

The good news is that it will most likely not need more than a few milliamperes on the trigger signal pin to get it to change state. You’ll need to source current to the trigger pin so given the original connection diagrams, a low digital output to the opto input led will active the relay rather than a digital high.

Edit: You could always read the coil voltage thru a voltage divider to know the relay state, if that matters to you.

avr_fred:
Thank you for the link, most helpful.

As with most eBay stuff from China, the reality and the description are two different things. What you have there is a not true bistable/latching relay. No, it’s your run of the mill 50 cent 5 volt relay with some mystery four leaded device that does the trigger/hold of the relay. A true bistable relay holds its position without power, the relay you’ve linked to does not and it will always be off upon power up.

The bad news is that this relay will require 60-80ma at all times when the relay is engaged. If you had intended to use this as a zero power latch for battery operation, it’s not going to work.

The good news is that it will most likely not need more than a few milliamperes on the trigger signal pin to get it to change state. You’ll need to source current to the trigger pin so given the original connection diagrams, a low digital output to the opto input led will active the relay rather than a digital high.

Edit: You could always read the coil voltage thru a voltage divider to know the relay state, if that matters to you.

Yes, ebay china stuff isnt all that great. My first experience with bistable/latching relay. I wouldve seen its power usage during some tests. What would you recommend for my car application for a zero power latching relay? In my parts box I have some of those 5v relays and some 12v car relays.

Lastly the voltage divider/4n35 was going to go on the load power side to detect the relay has switched and NO is providing power.

Next time Ill have a wiring diagram

I’m not necessarily discouraging eBay but many times the stuff isn’t what they say it is. It can be a great resource when you’re on a budget. Just remember the old phrase “buyer be aware” as it really suits the situation.

Project requirements drive part specs and since you haven’t provided any details, there is little point in speculating.

FWIW, here is a DigiKey parametric search of the dual coil relays with contacts above 2 amps, sorted by price. These search tools are the easiest way to find a part for a specific application.

Digikey latching relay search

avr_fred:
I’m not necessarily discouraging eBay but many times the stuff isn’t what they say it is. It can be a great resource when you’re on a budget. Just remember the old phrase “buyer be aware” as it really suits the situation.

Project requirements drive part specs and since you haven’t provided any details, there is little point in speculating.

FWIW, here is a DigiKey parametric search of the dual coil relays with contacts above 2 amps, sorted by price. These search tools are the easiest way to find a part for a specific application.

Digikey latching relay search

I looked through digikey which I have used before. Didnt find anything that seemed appropriate. I decided to draw a quick diagram. Can you look at the below and give any recommendations?

Imgur

How do you plan to power the relay coil(s)? Is the esp-12e outputs 5 or 3.3V?

outsider:
How do you plan to power the relay coil(s)? Is the esp-12e outputs 5 or 3.3V?

3.3v is esp12e. Was planning on using cars 12vdc for the relay

So you're going to buy a relay with 12V coil(s), you will need transistor(s) to switch the 12V coil current with the 3.3V esp-12e outputs. Correct?

I've been using this for my 12v power applications. works pretty good for the lower amperage stuff. still working on figuring out some of my higher amperage projects with it.

newegg

midiean:
I've been using this for my 12v power applications. works pretty good for the lower amperage stuff.still working on figuring out some of my higher amperage projects with it.

Higher, but not too high.
That board uses older style IRF540 mosfets with a rather high 'on' resistance.
Wise to keep the load under 10Amp.
Leo..

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

OPs Circuit;


Can you please post a copy of your circuit as a picture of a hand drawn circuit in jpg, png?
Your hand has more component symbols in it than any CAD or picture program.

Tom.... :slight_smile:

outsider:
So you're going to buy a relay with 12V coil(s), you will need transistor(s) to switch the 12V coil current with the 3.3V esp-12e outputs. Correct?

actually the coil is 5v and going to switch the 12v on the com side

Been researching relays more. What im looking for is a 5vdc relay that will latch to apply 12vdc to a dc device. I want the relay to not require power so my circuit is energy efficient. The relay will be driven by an esp-12e. Is below the relay I should've used?

https://www.ebay.com/itm/1-pc-Bistable-latching-2-coil-relay-5V-coil-16A-contact-SPDT-RT314F05/362154527599?hash=item5452178b6f:g:9FAAAOxyY3ZRkQUO

or

https://www.ebay.com/itm/Bistable-Latching-DPDT-8A-Power-Relay-Module-DC5V-Coil/191122298692?_trkparms=aid%3D555019%26algo%3DPL.BANDIT%26ao%3D1%26asc%3D50686%26meid%3D68a7e9ddbf9b4c78b78e8087b5271c89%26pid%3D100754%26rk%3D1%26rkt%3D1%26%26itm%3D191122298692&_trksid=p2045573.c100754.m4842

Do you have a 5V power supply for the relay coils? How are you going to switch the 5V, 110 mA pulse required by the coils with 3.3V outputs? That relay is available in a 3V version but you still face the problem of switching a high current (probably around 180 mA at 3V) with a 12 mA rated output, even though it should be a short (10 mS) pulse?

outsider:
Do you have a 5V power supply for the relay coils? How are you going to switch the 5V, 110 mA pulse required by the coils with 3.3V outputs? That relay is available in a 3V version but you still face the problem of switching a high current (probably around 180 mA at 3V) with a 12 mA rated output, even though it should be a short (10 mS) pulse?

have cars 12vdc, so have power. After that part Im a novice with relays on the esp-12e. Though I see a ton of people using a regular srd-5vdc which takes a similar voltage to switch?

If you go with the 12 volt version of the relay, you can drive it directly from two esp8266 outputs and the power is supplied by the vehicle.

All that aside, if the device you’re powering is on when the esp8266 is on, you can create a high side switch with p channel mosfet which would eliminate the need for the rather expensive relay. That’s just a guess though as you’ve never explained what you’re doing with the 8266 and the device being controlled by the relay.