Sainsmart 4CH relay board and ESP32

Hello, I am trying to interface an ESP32 WROOM 32D with a Sainsmart relay board (LOW level type I think).

I've searched all over the internet, but I can't find a schematic for noobs that explains how to wire them together. I did find some articles that suggest connecting the relay card directly to the 5v, GND and GPIO inputs of the ESP, but I've read elsewhere that it is not recommended to drive the GPIOs directly without using a driver.

I found several transistor based schematics but none of them work. Could you please explain me how to basically connect these components together ?

Thank you !

Bad news, it is probably doing what it should. From the schematic I found, shown below, it shows a LED in series with the opto coupler which serves as an on signal indicator. Here is a chart showing the threshold voltages of various Logic families: Logic Voltage Thresholds for TTL, CMOS, LVCMOS, and GTLP IC families. I use a PCF8574 as the interface as it will run on 5V and using 3.3K pull up to the 3V3 works fine. You could use a inverter or a and gate as an interface. You can try jumping out the leds (if you know what you are doing) or get a different relay board.
image or
image
from sainsmart.

Hi,
your relay module has this schematic below.

If you power your ESP from its USB port, it may not provide enough current to operate the relays.

Feed the module through the Vin pin, with a source that can support the summed current of the 4 relays.
Remember to connect this power supply's GND with the ESP32's GND.

Plug each IN into a GPIO that you want on your ESP32.

If fed with 5V, (which is the value of the relay coil), and
as each IN has a 1K resistor, a photo module and a diode.

Adding the voltage drops of each element we will have: +- 2.0V drop in the LED, (red LED) +- 1.2V drop in the photo, so 5V - 2.0 - 1.2 = 1.8V.

This 1.8V is within the ESP32 GPIOS limit. (max 3.3V)
The maximum current will be 1.8V/1K = 1.8 mA.
I find too little current for the opto PC817.

According to his datasheet the ideal current would be +- 20 mA.
"https://www.farnell.com/datasheets/73758.pdf"
Therefore, I would not recommend this module for your project.

PS : 4 Channel 5V Relay Module - Wiki

Thank you for your replies :slight_smile: