Adding a popular 5Volt 4 channel relay board to a 3V3 processor (beginners)

Chinese webshops sell a 5Volt 4 channel relay board that is quite popular amongst hobbyist. Sometimes I get the question if it can be used with a 3V3 microprocessor. This ofcourse is very basic Ohms law, so just skip this article if you already know, but for those who still have questions: read on.

Well in short: any relay can be made to work with any microprocessor, but lets look at how this can be done in an efficient way.

Normally, if you have a bare 5Volt relay, it would only require a transistor or a FET to drive the relay with any voltage sufficient to open the transistor. The relay board in question though already has some electronics around it, so lets have a look at the circuit:

It is quite clear that this is not the standard one transistor relay board: the Transistor driving the relay in itself is driven by an optocoupler, that also inverts the signal: It is a LOW on the INx input that will  bring the optocoupler to open, thus feeding the base of the transistor, that will subsequently open and activate the relay. The circuit also shows that the optocoupler can be fed from the same  voltage source as the  relay, or from a different voltage source.

First question we have to ask ourselves: is a 3v3 circuit enough to drive the board?
Well, suppose we feed the board entirely with 5Volt. If we then would connect a 3V3 processor pin such as from a raspberry or ESP8266 or  a modern Arduino, a LOW would indeed activate the relay, as described above, but what happens if we do a HIGH?
Well, with a HIGH there would be a voltage of (5-3.3=) 1.7 volt over the series resistor, the optocoupler and the LED. Given the fact that the  forward voltage of the  optocoupler is about 1.5 Volt and the forward voltage over the red LED is on average 2.2 Volt, that basically absorbs the 1.7 Volt making it safe to say there will be no current flowing through the optocoupler when the IO pin is made HIGH (3V3).
Factually, even if the ‘HIGH’  would only be 2.5 Volt, chances are slim that there would be any current flowing through the optocoupler.

Now ofcourse there are people who shrug at the idea of  having any 5Volt source connected to their 3V3 pins, so what happens if we  take away the Voltage jumper, feed the relay with 5Volt and the optocoupler with 3V3.

Well, suppose we again make the IO pin LOW, then there will be 3V3 over the optocoupler, the LED and the resistor.
The LED and the optocoupler will  have a voltage drop of 1.5+2.2=3.7 Volts. Ergo, there will not be any current flowing through the optocoupler and the relay will not be activated.

Therefore: yes, the relay board can be used with a 3V3 processor, but  you will have to feed the entire board with 5Volt. But beware, that means ONLY the entire relayboard. You do not feed your 3v3 processor with 5 volt

But, what if I do not want the signal to be inverted, if I want a LOW to deactivate the relay and a HIGH to activate it?

Well, that is fairly easy: do that with an inverter. One can either use an inverter IC such as a 7404, 7414 or a 4069, but ofcourse then you’d have to wonder whether 3V3 would be enough input for those IC’s  (it is).
Another possibility is just a transistor with a base resistor 470-1000 Ohm (1x for every channel).

Mind you though that with this circuit, your I/O pin may see a LOW on start up, something not every ESP8266 pin may be happy with (e.g. GPIO0, GPIO1, GPIO2) and one (GPIO15) that will be very happy with it.


5 thoughts on “Adding a popular 5Volt 4 channel relay board to a 3V3 processor (beginners)”

  1. Great writeup. May I present an alternative approach? IMHO the biggest problem in this PCB design is the LED in the input line. They should have put it in the base line of the switching transistor. under the assumption that the LED is not essential and you really want to keep things double separated (relays and opto couplers), the best thing to do is to simply short out the LED’s with just a blob of solder. It will run just fine with a 3.3 controller after that.

    1. A belated merry Christmas to you Jeroen.
      Yes you are absolutely right. I myself in the past have made similar designs when everything was still 5Volt based, but with 3V3 it is a different ball game.
      if indeed someone has reason not to feed the optocoupler with 5 Volt, shorting out the LED is a good solution, though you would lose the action indication.
      having said that, one still needs 5 Volts to supply the relay… although, mine worked at 3v3… but there is no guarantee someone else’s will.

      Main reason for getting this module is because it is cheap and handy. Ideally though I’d prefer the straight forward transistor with base resistor method to drive a relay. No inverted signals and basically any driving voltage of > 0.7 volt will do

      FYI, I drive it with a raspberry. just to play around with assessing the pins through Openhab, especially on another raspi than the one that has Openhab installed

      happy Newyear to you

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: