I would like to drive 3 relays with single ESP01 pin (RX in this case). However, the ESP keeps clicking along with relays sometimes. in other times nothing happens. it doesn't work. I used the same code and wiring for single relay which works fine. So how can I drive all three relays at the same time with ESP01. enter image description here


#define PIN3 3 // Using RX as GPIO

void setup() {
  pinMode(PIN3, FUNCTION_3);   //GPIO 3 (RX) swap the pin to a GPIO.
  pinMode(PIN3, OUTPUT);
  digitalWrite(PIN3, LOW);

void loop() {
  digitalWrite(PIN3, HIGH);
  • \$\begingroup\$ Can you add your code? Hard to debug when we don't know what you're doing. Also I do not know too much about the ESP01 in particular - is there a reason you use RXD instead of GPIO0? Seems to me a GPIO would be more fitting for this purpose. \$\endgroup\$
    – InBedded16
    Commented Dec 6, 2021 at 17:43
  • \$\begingroup\$ rx is an input-only GPIO; use tx instead, and then make sure you don't use Serial. \$\endgroup\$
    – dandavis
    Commented Dec 6, 2021 at 19:11
  • \$\begingroup\$ @InBedded16 code uploaded. GPIO are needed for boot purposes which I don't want to mess with. I used this RX in multiple projects successfully. \$\endgroup\$ Commented Dec 6, 2021 at 21:46
  • \$\begingroup\$ @dandavis This is not correct. Both RX and TX can be used for either (tested). \$\endgroup\$ Commented Dec 6, 2021 at 21:47
  • \$\begingroup\$ Pins of MCU may have different purposes. You are using Pin3 as GPIO. \$\endgroup\$
    – user263983
    Commented Dec 6, 2021 at 22:34

2 Answers 2


You might want to wire the relays in parallel. Two relays are now directly connected to supply so they are always activated, the transistor has no control over them.

  • \$\begingroup\$ Sorry I messed the drawings. they are connected in parallel were I'm having the issue. \$\endgroup\$ Commented Dec 6, 2021 at 21:47

The best solution to use transistor with higher Hfe, or darlington transistor. In your case summary current of 3 relay coils should be bigger. It is restricted by base current multiplied by The transistor. Transistor is not saturated, it is in active mode. Not enough current to activate relay coils. Or reduce base transistor value, but not exceed max output current of MCU.


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.