0
\$\begingroup\$

I have this relay module : https://www.amazon.co.uk/gp/product/B06XKQQXKW/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1

I want to drive the 8 control pins (driving low at 3.3v) from the ESP32. I believe that each pin needs 70mA according to this datasheet:http://datasheetcafe.databank.netdna-cdn.com/wp-content/uploads/2015/10/SRD-05VDC-SL-C-Datasheet.pdf.

The relay is a SRD-05VDC-SL-C which I believe correlates to a 5v high sensitivity coil. That means each pin will draw 70mA to drive the coil, obviously this is way beyond the spec for the ESP32. Except this relay board is being driven by an optocoupler, so I am not sure if this is the current i am supposed to be looking at.

How can I drive this safely using normal cheap components, as doing so directly from the device would be pushing its current limitations. I understand a NPN transistor will likely be involved, however I am not entirely sure of the safest, best way to proceed. Please help by example of a circuit.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ That would appear to already have driving circuits built into it. If you are worried about the 8x10 milliamp total, consider using some CMOS buffers. \$\endgroup\$ Commented Mar 7, 2018 at 21:12
  • \$\begingroup\$ Never used those before, can you help draw a circuit. I believe these relays draw in excess of 10mA, so it is beyond the spec of the esp32 \$\endgroup\$ Commented Mar 7, 2018 at 21:20
  • \$\begingroup\$ @ChrisStratton additionally if it already has driving circuits, how much current is each pin going to draw? \$\endgroup\$ Commented Mar 7, 2018 at 22:44

2 Answers 2

1
\$\begingroup\$

The ESP32 has configurable output ports that support up to 40 mA when driving high:

enter image description here See the datasheet.

All ports will sink 40 mA driving low (the absolute maximum is 80 mA). The default as shown is 20 mA for a high.

Connect the signal VCC to the Relay 5 V VCC, and the Opto diode in series with DSx ensures that the ESP32 pin cannot be pulled above about 2.5 V.
If you want to absolutely ensure the voltage can't rise then you could add say a 10k Ohm resistor from each output you use to ground.

There are many derivatives of the relay board you have chosen and many of the datasheets specify they work on 3.3 V signal levels. This then gives you an input circuit like this:

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
10
  • \$\begingroup\$ Hey Jack. OK - this helps, but in practical terms, I have a GPIO pin, and I have my relay which has 8 signal pins, a VCC and a GND. I am powering the relay externally. So what would I connect between my GPIO pin and the signal pin in order to make this work. As far as I can see, this is basically hooking the GPIO pin directly up to the signal pin on the relay board. \$\endgroup\$ Commented Mar 8, 2018 at 1:53
  • \$\begingroup\$ Additionally, the relay is signalled by driving LOW. \$\endgroup\$ Commented Mar 8, 2018 at 1:53
  • \$\begingroup\$ As I showed, you can simply connect the DIO pin to the signal pin ...your VCC for the board is 5 V, which I assume you already have. The circuit I showed has an extra resistor to ground which does ensure you have a good Vf for both the LED and series diode. What other risks do you think you need to protect against? \$\endgroup\$ Commented Mar 8, 2018 at 3:43
  • \$\begingroup\$ Jack-thanks very much. Well, This may appear somewhat tangental to our discussion, however this ESP32 library github issue caused the library maintainer to believe I am driving the relay incorrectly...and as far as I can see, I am driving it as you specify : github.com/earlephilhower/ESP8266Audio/issues/65 \$\endgroup\$ Commented Mar 8, 2018 at 8:52
  • 1
    \$\begingroup\$ Completely wrong ....look at the board and you will see that the relay is driven by a transistor, so the relay current does not flow from the DIO pin. You will need to supply the relays current (for 8 relays) separately of course. \$\endgroup\$ Commented Mar 8, 2018 at 16:07
0
\$\begingroup\$

In simple words, either use

  1. an opto-coupler where the phototransistor side passes current from power source itself. PC817 is a good option, or
  2. a mosfet like BS170 for such an operation. Circuits for arduino and BS170 are easily available online.
\$\endgroup\$

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.