Normally when driving loads from uC-Pins I use MOSFETs and do ground Gate and Source with a high value resistor to get a clear LOW signal on startup, whatever happens at this time with the microcontroller output pin.
It looks like this doesn't work with at least ESP-01 (did not try the other module types). A transistor connected with a base resistor pulls GPIO2 low, even if I use a high value resistor or go for a Darlington. The MOSFET has the same problem - although I didn't try one with a very high impedance at the gate. I will try the proposal with the capacitor (although a C is an immediate short to the circuit while getting loaded) or maybe even a RC circuit.
Easiest way will be using a different module I think.
markbee
peteben wrote:That really depends on your application. What are you trying to switch?
GPIO2 will be set as an input while the chip boots, and needs to remain pulled up to run user code. After user code starts, you can do whatever you want, though.
Since you're talking 5V and the chip runs at 3.3V, it's clear you're going to need atransistor or a FET to switch your load.
If you are just driving a LED, a short (20ms) flash at bootup is probably not critical. You can write your own firmware in 'C' or modify the 'AT' firmware to ensure GPIO2 goes low as soon as execution starts.
If it is but timing on your output is not critical, you could add a capacitor that would 'eat' that 20ms pulse.
If you can't do anything else, a pair of transistors will probably be necessary to invert the output and drive the load.
Pete