1

I am working on a DIY home automation project using a Wemos D1 Mini as the controller, and I ordered some 4-channel 5v-triggered relay boards. The ESP8266 that Wemos D1 Mini's are built on has GPIO output voltage of 3.3v, ostensibly too low to trigger the relays.

I've read a Reddit post that was saying that as long as you use a separate 5v power suppy for the relay board, 3.3v should be enough to trigger the relays. Is that accurate, or do I need to use a transistor or something to provide the relay board inputs with 5v?

2 Answers 2

2

Yes, the Reddit post's approach is likely to work ok, as long as you correctly follow the cautions in it: • connect the VCC pin of the relay board to a 5V source, • connect together the Arduino ground, the relay ground, and the 5v-source ground.

Here is a typical relay-module circuit diagram (for one channel):typical relay-module circuit diagram (for one channel)

(Note, this diagram is from a home automation blog; for more discussion and similar diagrams, see eg 4-relay-shield-diagram at yourduino.com and stripboard-shield-relay-sm at startingelectronics.org.)

As you can see in the diagram, the Arduino pin that connects to JP2-2 will not be exposed to voltages. (The base of an NPN transistor effectively is at the junction of two back-to-back diodes.)

When the Arduino or ESP pin at JP2-2 is at about 0 V (ie, when the Arduino pin is off) IBE=0; that is, no Q2 base-emitter current will flow; thus, Q2 will be off, so that both of LED1 and relay U1 will remain off.

When the Arduino or ESP pin at JP2-2 is at about 3.3 V (ie, when the Arduino pin is on) IBE is about 2.5 mA, which should be enough to reduce VCE to about 1 V, leaving 4 V across the relay coil, or enough to turn it on.

Note, the 2.5 mA figure for this circuit is calculated as follows: IBE = (3.3-VBE)/1000 - VBE/10000 = (3.3-0.7)/1000 - 0.7/10000 = .00260 - .00007 = .00253 A = 2.53 mA. Note that the alternate circuit diagrams linked above don't have a 10KΩ resistor like that in the diagram above, so instead of about 2.5 mA would have about 2.6 mA drive.

If for some reason you don't have quite enough base drive – in which case you might be able to hear a slight click from the relay, even if it doesn't switch – you could increase the "5 V" line into the LED and relay to say 5.5 V or 6 V. As noted before, the back-to-back diodes structure of the NPN transistor will isolate that voltage from your Arduino or ESP.

1
  • Just to assure the OP - every 5V relay I've used works fine with 3.3v for the "trigger" Mar 2, 2018 at 8:52
0

Short answer : it will probably work.

If your relay board is opto-isolated, there is a small potential risk that 3V3 may not be enough to lit the optocoupler sufficiently, you will have to test it.

The reddit board is not using optical separation but only a transistor, like on the schematic of the answer above,. In that case, 3V3 is always enough to saturate the transistor. Anything above around 1V5 would probably do, but this can vary according to the resistors, relay consumption and transistor gain.

There is an extensive discussion of this topic at https://www.forward.com.au/pfod/HomeAutomation/OnOffAddRelay/index.html#Mods3v3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.