sorry for a beginner question, but I can't find the issue. I bought two of these https://www.aliexpress.com/item/1005001281266972.html?spm=a2g0o.order_list.order_list_main.17.698e1802eEHtjq - a board with 2 relays and optocouplers. It has separate power supply 5V and 2 inputs (according to aliexpress page 0-2VDC means ON, 3-5VDC means off). I'm trying to control and power it with ESP32 dev board (ESP32 WROOM). However it doesn't work as I hoped:

Relay 1: works ok

Relay 2: I can hear a silent click when switching from ON to OFF, however the relay remains open.

Relay 3&4: I can close the relay, but when I apply the voltage to switch it off, the relay stays closed.

Power supply of the board is connected to 5V output of the ESP32, the inputs are connected directly to ESP32 GPIO pins. I know that ESP uses 3V3 logic, however according to datasheet, 3V3 should be enough to turn the relay off.

It seems I'm doing something wrong, but I dont know what. When I bypass the optocouplers (shorting with a screwdriver), the relay closes and opens as expected. Can you give me some advice please?

  • 1
    \$\begingroup\$ The current input is not specified ... \$\endgroup\$
    – Antonio51
    Jun 21, 2023 at 9:13
  • \$\begingroup\$ These 5V relays use quite a lot of current for the coil. Can you check your 5V supply has enough output? Or measure 5V on the relay board with a multimeter to check it doesn't go down when turning on a relay? \$\endgroup\$
    – bobflux
    Jun 21, 2023 at 9:55
  • \$\begingroup\$ Your relay module has not enough details how to use it or how much current it works. Each relay itself takes 185mA to turn on. I bet for the opto and transitor (if it has one), you need maybe 200mA per relay. ESP32 5V output comes from where? How do you power it with 5V? USB? PC? Charger? Also technically, that's an electronic product, bought without manual, so it is a black box, and you are asking how to use it. You should be asking the product seller. \$\endgroup\$
    – Justme
    Jun 21, 2023 at 11:11
  • \$\begingroup\$ Power comes from USB, 2A charger, originally used for raspi2. However when I trigger it manually (shorting the optocoupler by a screwdriver), then it's working OK, so it doesn't look like a power supply issue \$\endgroup\$ Jun 22, 2023 at 10:14

2 Answers 2


I am not sure if ESP32 I/O can drive the relay input, but I may be wrong. One thing you could do is disconnect your ESP from the relay input controls and then use a variable power supply to feed in the DC voltages to the input of the optocouplers that AliExpress claims it should work with, just to confirm operation according to your AliExpress.

Then perhaps you can use the power supply to try feeding in the voltages that your ESP32 would output to the optocouplers and see if they would work. Ensure the polarity headers are set correctly.

You have to be a little careful with what Aliexpress sellers claim.


A voltage between 0-2VDC should turn the relay on, and 3-5VDC should turn it off. However,you you are connecting the relay inputs directly to the ESP32 GPIO pins. The GPIO pins operate at 3.3V logic. The relay board may not detect the 3.3V signal as "off."

You can try using a voltage level shifter or a transistor circuit to provide the necessary voltage levels for the relay board. You can also test your relay board with another microcontroller.

And if you want to design a ESP32 relay board of your own, you can try this:



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.