-->
Page 1 of 3

Prevent GPIO 2 keep in High voltage when reboot ESP8266

PostPosted: Tue Jun 23, 2015 9:22 am
by Tinamore
Hi everyone
I build circuit relay with the diagram:
Image
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 ?
Thanks.

Re: Prevent GPIO 2 keep in High voltage when reboot ESP8266

PostPosted: Tue Jun 23, 2015 9:12 pm
by tytower
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.

Re: Prevent GPIO 2 keep in High voltage when reboot ESP8266

PostPosted: Tue Jun 23, 2015 9:25 pm
by martinayotte
This question is been asked several time!
GPIO2 (or GPIO0) need to be HIGH at Reset because of the Boot process :

https://github.com/esp8266/esp8266-wiki ... 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)

Re: Prevent GPIO 2 keep in High voltage when reboot ESP8266

PostPosted: Tue Jun 23, 2015 11:33 pm
by tytower
martinayotte wrote:GPIO2 (or GPIO0) need to be HIGH at Reset because of the Boot process :
https://github.com/esp8266/esp8266-wiki ... 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 .