Electronic – arduino – Driving 5V powered relay module from 3V3 powered microcontroller

arduinomicrocontrollerraspberry pirelaysolid-state-relay

What I'm trying to do

This question is about the use of any 3V3 supply microcontroller to drive 5V powered relay modules which are available from many suppliers. I have provided details below of the microcontrollers and modules that I am specifically using, but the question is a generic one.

In my application I have a Raspberry Pi Zero and an Arduino that I'd like to use for an automation project. I have two of the SSR modules (HCMODU0115), like the one in the picture below.

SSR

I connected them to my GPIO pins, kind of like the picture below, and activated them, but I noticed that both the LEDs were shining regardless of output provided by my controllers. Only that when it was active the LED were like 100% bright, and when inactive they were at half brightness, but still turned on.

Wiring

Out of curiosity I decided to connect a pair of diodes in the channel inputs, like the picture below, but then the relays wouldn't activate at all.

Test 1

Then I decided to invert the diodes and suddenly the relay module started working again, but this time the LED1 and LED2 were working as they should, being lid up only when active.

Test 2

This brings up two questions for me.

First, is it safe to directly connect this relay module to my controllers? Why are the LEDs always turned on?

Second, Why did it only work when I reversed the diodes? It has something to do with the direction of the electron flow?

Best Answer

Here is the easiest way to make this work- add just one part (per output):

schematic

simulate this circuit – Schematic created using CircuitLab

enter image description here

The internal schematic of the module is something like this (from here):

enter image description here

The Omron SSR gets about 0.7 or 0.8V less than the supply voltage, and it needs 4V minimum to work reliably so it really needs a 5V supply. It starts to turn on a couple diode drops below the supply so more than the maximum output voltage of the 3.3V MCU.