Hello everybody.
I hope you have chosen the correct category for the discussion.
There are many threads of people using this type of module and having problems.
I couldn't find if there is a discussion about this case here on the forum.
Today, while helping someone here on the forum, I came across a situation that I had not noticed before.
"Sainsmart 4CH relay board and ESP32 "
Below schematic of the relay module that I would like to discuss.
(It's the same used in 2x and 4x modules).
When feeding the module with 5V, (which is the value of the relay coil),
The module has a 1K resistor, a photo module and a diode in series at the IN.
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.
In this case we would have 1.8V on the microcontroller port when it is HIGH.
The maximum current will be 1.8/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"
In order to have the recommended 20 mA passing through the PC817 LED, it would be necessary to remove jumper J2, feed the relay with 5V and feed the 1K resistor with 24V, so we will have:
24V - 2.0 - 1.2 = 20.8V. 1K/20.8V = +- 20mA.
But in this case we would have 20.8V at IN (or microcontroller port when it is HIGH).
If you use 12V on the resistor, you will still have problems, as the current would be +- 10mA and the voltage would be 8.8V on the IN pin.
The other solution would be to feed with 5V and change the 1K resistor for a 90 Ohms one, (100 Ohms commercial).
Then we would have: 5V - 2.0 - 1.2 = 1.8V. 100R/1.8V = 18mA.(+-20mA).
And we would have 1.8V at IN (or microcontroller port when it is HIGH).
Am I missing something or am I correct in my analysis?