Schema for 12V relay board ?

Anything not related to STM32
michael_l
Posts: 200
Joined: Mon Aug 24, 2015 6:11 pm

Re: Schema for 12V relay board ?

Postby michael_l » Sat Dec 31, 2016 9:42 pm

Pito wrote:But the schematics of mine is not the schematics of your board..


Ah.. sorry, misunderstood :-) Yes, it seems my board is somewhat a compromise. People generally want as simple interface as possible. But I believe this should work okay. Like using +12V for VCC and STM pin output for IN is a better choice. I think if I don't use STM's GND for GND pin then it's even better.

michael_l
Posts: 200
Joined: Mon Aug 24, 2015 6:11 pm

Re: Schema for 12V relay board ?

Postby 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 71 times

User avatar
martinayotte
Posts: 1123
Joined: Mon Apr 27, 2015 1:45 pm

Re: Schema for 12V relay board ?

Postby martinayotte » Tue Jan 03, 2017 10:25 pm

Your opto-coupler is wrongly wired ...

zmemw16
Posts: 873
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Schema for 12V relay board ?

Postby 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
Posts: 200
Joined: Mon Aug 24, 2015 6:11 pm

Re: Schema for 12V relay board ?

Postby 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
Posts: 873
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Schema for 12V relay board ?

Postby 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

User avatar
Pito
Posts: 535
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Schema for 12V relay board ?

Postby 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 40 times


Do it at your own risk, no warranties of any kind are provided, 12V is a lethal voltage for your MCU :)
PS: when drawing schematics always place a DOT where the wires are crossing themself and are connected together..
Last edited by Pito on Wed Jan 04, 2017 6:34 pm, edited 1 time in total.

michael_l
Posts: 200
Joined: Mon Aug 24, 2015 6:11 pm

Re: Schema for 12V relay board ?

Postby 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 ??

User avatar
ahull
Posts: 1300
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: Schema for 12V relay board ?

Postby 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.
- Andy Hull -

User avatar
Pito
Posts: 535
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Schema for 12V relay board ?

Postby 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.


Return to “Off topic”

Who is online

Users browsing this forum: No registered users and 1 guest