So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By aledrus
#73965 Hello, I have a quick question, I think I know what the problem is but I don't know what is the normal standard in dealing with this issue.

My ESP-01 boots up fine when GPIO0, GPIO1, GPIO2, & GPIO3 are not connected to anything (floating) - they are all pulled up high internally.

However, I wish to control a relay with the ESP-01. The way I have done that is by connecting the GPIO pin to the base (via a 1k resistor) of a BJT NPN transistor, and the transistor drives the negative relay coil to ground.

But I think where the problem is is the fact that I connected the GPIO pin to the base of an NPN resistor, and this base is +0.7V from the collector (GND). Therefore, when booting up, the ESP-01 sees a "low" at the GPIO pin (transistor base) thus goes into one of the other modes instead of the operation mode.

How do other people handle this?
User avatar
By btidey
#73969 Your analysis is correct. The GPIO only has a high value pull up to make it into the required '1' state at boot time, so a load like a 1K + bipolar junction will make it '0'.

I almost always use MOSFETs now which do not require any drive current so you can connect to the GPIO without pulling it down. You have to use MOSFETS with low gate threshold so they turn on with 3.3V logic.

With bjt you could consider using pnp instead, or even a pnp stage followed by an npn if the relay input wants that.

You should also consider how you want the relay to behave during this boot period as otherwise it can temporarily turn on until you set up the GPIO. You may want to make the logic such that you need an active low on the GPIO to turn the relay on.