Modify Arduino 5v relay module to work from 3.3v

I am implementing a power-off function for my Ender 3 using OctoPi. For that, I need a relay and I happened to have one.

Relay module I had
Relay module I had

Unfortunately, after connection relay to Raspberry Pi GPIO pin, the relay was always on and not listening to any commands from OctoPi.

It appears this module was designed for 5v logic levels and Raspberry Pi works with 3.3v logic levels.

After investigating relay one can see that its circuit is:

Original schematics of relay module
Original schematics of relay module

For JC817C forward voltage Vf=1.2V and forward current If=20mA

For Raspberry Pi output high (when VDD is 3.3V) is VO=2.3V 17mA

So, it seems that the output of Raspberry Pi is not enough to drive JC817C.

To solve this I decided to remove optocoupler from the module and connect the input pin directly to Q1 transistors base.

Modified relay module
Modified relay module
Relay module with optocoupler replaced by resistor
Relay module with optocoupler replaced by a resistor

To connect the output pin to a transistor you should limit output to appropriate current. You can do that by choosing the appropriate resistor value.

I calculated it like that.

From S8050 (J3Y) transistors datasheet:  DC current gain hfe ~ 120

From relay datasheet: Rrelay=70Ohm Vrelay=5V so calculated Irelay=Vrelay/Rrelay=5/70=71mA

Let’s choose Ic=100mA

To turn it on, we must have ~ Ib=Ic/120=100mA/120=833uA ~800uA

Vbe usually is ~0.7V

R9 voltage would be Vr9=Vinput-Vbe=3.3V-0.7V=2.6V


So I chose 3K resistor.




  1. This does not seem to work with more than one of these at a time. I daisy chained 3 together and only 1 works. Any ideas?

    • Yes, that’s right. I actually managed to get it working by using lower ohm resistors. Through a bit of trial and error, I found that using a 350 ohms resister on each provided enough current to trigger each relay.

Leave a Reply

Your email address will not be published.