I'm using an ESP-01 to control a load (SSR), which is connected to IO pin 2. This pin needs to be HIGH at boot time, otherwise the module won't boot. I've tried driving the load with an optocoupler to avoid driving the pin LOW while booting, but it's not working. Do you know of any solution to make it boot correctly without changing the IO pin? (there's only two GPIO pins, both ocuppied, plus serial port pins).

  • On the 01, you don't have to have GPIO2 pulled high to boot, you just can't have it grounded. I've had to use a diode (instead of a wire) to connect relay modules to pin2. btw: you can use TX as an output and RX as an input; I've driven an RGB LED with one and it works out since the LEDs blinking for a few ms at boot was ok. All pins on the ESP-01 boot/reset high, so take that into account. – dandavis Apr 20 '17 at 5:53
  • I'm already using the TX to drive the built-in LED as a state indicator, but I'll try with RX instead. But still, I'd like to know how to use GPIO 2 without screwing the booting. :S – Christian Rodriguez Apr 20 '17 at 14:03
  • just don't let the pin fall under 2.4v and it will boot. it's weakly pulled up internally, so keep it high or disconnected by default. depending on the internals of your SSR, you might be able to simply invert the signal wiring and make gpio2 a ground to activate it; i've done that with a few ssr/relay modules, and i didn't even need the resistor in @Majenko's 2nd sketch for some reason, but results may vary... – dandavis Apr 21 '17 at 8:31
  • @dandavis Yeah, that's what I did to make it work. :D – Christian Rodriguez Apr 21 '17 at 14:37

Simply invert the logic - so that LOW turns the SSR on and HIGH turns it off.

Try something like this:


simulate this circuit – Schematic created using CircuitLab

The P-channel FET will invert the logic. Pull GPIO2 LOW and it will turn on the FET which will enable the SSR. The 10KΩ resistor keeps the GPIO pin (and the gate of the FET) HIGH at other times.

If the GPIO pin can sink enough current to directly drive the SSR you can leave out the FET:


simulate this circuit

Again the logic is inverted. Pull GPIO2 LOW to sink current through the SSR to turn it on. The resistor keeps the GPIO pin held HIGH when booting.


I did something similar to what @Majenko proposed in his answer (as in I inverted the output), but instead of using R1 as a pullup resistor in paralell with the SSR's LED, I'm using it as a normal current limiting resistor. In other words, I just swapped GPIO2 from sourcing the SSR to sinking it. The schematic is like this:

Circuit Schematic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.