Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Tinamore
#21381 Hi everyone
I build circuit relay with the diagram:
I use the code esphttpd in the examples Espressif SDK to control GPIO 2.
Everything works great except for one problem:
When ESP8266 reboot then GPIO 2 keep in high voltage for 1 second, This will auto turn on the replay then turn off, The device connect to the replay would be damaged
This seems to be the default of ESP8266 at startup.
Is there a way to kill the high voltage of the GPIO 2 when restarting ?
User avatar
By tytower
#21454 Always have trouble with transistors . Should be as easy as .
Your emitter then is connected to Ground . The base is connected to GPIO2 and Collector to middle pin on relay . A small flow on base to ground at 3.3V will allow a larger flow from Collector to Ground at 5V. In this case through the coil I assume pulling in the contacts . OK

can you point me to the example please as I do not use SDK and would like to see it . GPIO2 is an alternative pin for serial and I'm wondering if it is sending something out there after reboot . Perhaps setting GPIO as input for a couple of seconds delay in your program then set it as output.? Don't know but I'd like to see example.
You might also be able to set the pin to a different function -see Wiki

Perhaps pinMode(2, FUNCTION_1) or equivalent in Language you use and set it low immediately.
Last edited by tytower on Tue Jun 23, 2015 9:26 pm, edited 1 time in total.
User avatar
By martinayotte
#21456 This question is been asked several time!
GPIO2 (or GPIO0) need to be HIGH at Reset because of the Boot process : ... ot-Process

So, you need to have pullups on both !
if you attached ANY devices, relay or whatever, expect a HIGH at powerup to be the default OFF state.
So, in the schematic above, you need to add another NPN transistor to inverse it's active state to LOW, so in the your firmware, writting a LOW state to that pin will activated the relay.

(BTW, personally, I prefer using MOSFET since the gate current is very low, and saturation very high)
User avatar
By tytower
martinayotte wrote:GPIO2 (or GPIO0) need to be HIGH at Reset because of the Boot process : ... ot-Process

I don''t believe this is right see wiki/doku.php?id=getting-started-with-the-esp8266 where GPIO2 is left floating.

I'll start a separate thread on this conflict so please report back what works for you
and hopefully this will help others starting out .