Schema for 12V relay board ?

michael_l
Sat Dec 31, 2016 2:50 pm
Anybody happen to have schematic for this particular board with IN, VCC and GND and optocoupler ?

http://www.ebay.com/itm/12V-1-Channel-R … Sw7s5Xgzcv

Would like to know how VCC and IN are separated – is there any risk to have VCC leaked into IN pin. Thanks.


fredbox
Sat Dec 31, 2016 4:27 pm
A search for “Arduino Relay Schematic” in Google images should find it. Chances are, it is this one.
If not, there are may more examples there.

michael_l
Sat Dec 31, 2016 4:39 pm
Thanks, I’ll check that.

I’m worrying if I put +12V in VCC and +5 IN from STM that I got no isolation between the relay and the microcontroller.


Pito
Sat Dec 31, 2016 5:38 pm
From the picture it seems the Input IN goes via 1k and the optocoupler’s diode to GND – that is the “isolation”.
The VCC will be 12V, the optocoupler’s transistor drives the external transistor which then drives the 12V relay against VCC to GND.

GND is common to 12V VCC and IN, therefore no galvanic isolation between 12V and IN. You would need a separate pin called “IN_GND” (for the optocoupler’s diode return) in order to get full galvanic isolation of the 12V VCC from an MCU connected to IN..


michael_l
Sat Dec 31, 2016 6:21 pm
Thanks for the explanation. It seems my board seems to be a bit different.

IN is wired straigth into optocouplers kathode and VCC goes through 222 resistor into anode.

Image


Pito
Sat Dec 31, 2016 6:56 pm
Then it is even worse :cry:
The optocoupler there has no specific reason to exist then.. :)

michael_l
Sat Dec 31, 2016 7:05 pm
Hmm.. Yeah it doesn’t make sense. I’ll have to recheck :)

Pito
Sat Dec 31, 2016 7:24 pm
This is how it should be wired to make us happy (LED and other jelly beans exclusive):

Ardu relay.JPG
Ardu relay.JPG (19.91 KiB) Viewed 775 times

michael_l
Sat Dec 31, 2016 9:29 pm
Pito wrote:This is how it should be wired to make us happy (LED and other jelly beans exclusive):
Ardu relay.JPG

Pito
Sat Dec 31, 2016 9:33 pm
But the schematics of mine is not the schematics of your board..

michael_l
Sat Dec 31, 2016 9:42 pm
Pito wrote:But the schematics of mine is not the schematics of your board..

michael_l
Tue Jan 03, 2017 9:05 pm
drew the relay board. Seems a bit of a so so.. don’t know if I want to test it with my STM.

If VCC is +12V and GPIO pin (IN) from STM is set to LOW then I believe relay is switched. But what happens if IN is set to INPUT or HIGH. VCC is going into optocoupler through resistor so current is small but voltage is still +12V. So there will be current going against pin’s protective diode or ?

relay.png
relay.png (46.23 KiB) Viewed 628 times

martinayotte
Tue Jan 03, 2017 10:25 pm
Your opto-coupler is wrongly wired …

zmemw16
Tue Jan 03, 2017 11:49 pm
swap opto pins 1 & 2 and use 3v3 or 5v to it, not 12v
might want to recalculate that led resistor as well.
input low => relay energized

pretty sure the relay diode should not be a zener type !

srp


michael_l
Wed Jan 04, 2017 6:16 am
Martin: Not my design :-) But you’re right in the picture opto’s 1 and 2 should be swapped..

Yeah, this board was for under $1 but does this even work and will it kill my board ? I mean why they sell these…

EDIT: I added 1K5 resistor between IN and GND to lower voltage into ~4.85V, should be safe for GPIO pin…


zmemw16
Wed Jan 04, 2017 11:39 am
change that 1k5 to something to give 3v3 max and it’ll be safe, work for both and forget needing to check it in the future :)
srp

Pito
Wed Jan 04, 2017 11:49 am
In an urgent need I would desolder the resistor which goes from opto diode to +12VCC (the resistor on your board), I would solder a wire to the diode (at the free pad from the desoldered resistor – doublecheck the pad goes to the anode of the diode!)) and a 1k5 resistor in series with the wire – and you get the schematics of mine – and you are fully isolated from 12V, and from relay.

Wire the 1k5 resistor to 3V3+ on the duino board (+IN below) and the existing -IN(below) header to the PINx at your duino board.
Do not connect GND of your duino board with GND of the 12V source!

Low at the PINx = the current (about 1mA) flows from +3.3V via the 1k5 and via the optodiode into the PINx = relay is activated

High at the PINx = no current flows as the +3.3V and the PINx have the same potential = relay is deactivated

Really isolated.JPG
Really isolated.JPG (46.08 KiB) Viewed 597 times

michael_l
Wed Jan 04, 2017 12:29 pm
Thanks Pito for good explanation and the picture. Much appreciated !

Pito: any idea why they’re selling this if a) it does not work and b) could brick your board by letting +12V in IN pin ??


ahull
Wed Jan 04, 2017 1:27 pm
There are lots of things on ebay that don’t work. Some are down right dangerous.. on the plus side they are cheap. The schematic you have drawn is a little weird in the sense that vcc goes to both sides of the optoisolator, which entirely defeats the purpose of it as there would be no isolation to speak of.

Pito
Wed Jan 04, 2017 6:23 pm
I recently had a discussion with an ebay_maker of a board ($30) on some really annoying issue – the answer was “we always try to balance quality and price, thanks for hint, we may improve in the next batch” :)
Most probably a “designer” got the task to reduce the number of pins on the header from 4 to 3.
So he/she wired the optocoupler’s diode to only voltage available: +12V. Task done !

The dangers of having connected ground and 12V Vcc of that board to a low voltage MCU board are mainly 2:
1. the relay coil, when not protected by the parallel diode (it can break as well), can produce hundreds of volts peaks and destroy the transistor and propagate via 12V rail
2. the relay contacts, which may drive 230V/10A can break and short to the coil and therefore to 12V rail.

PS: another small detail – always ground the base of a transistor (bipolar or fet) which switches loads via a Base-Emitter resistor (see my schema for example) – when left base floating (when connected directly to an MCU’s gpio and the gpio is set input or analog, ie. during reset) or at higher impedance (ie when the optocoupler’s transistor is off) it may randomly switch the collector load off/on/off, based on the noisiness of the environment.


Leave a Reply

Your email address will not be published. Required fields are marked *