Page 1 of 1

esp01 gpio2 low at boot?

Posted: 14 Jan 2017, 18:49
by uxhamby
Hi,

I understood that the esp8266 gpio boot modes truth table was as follows:

Image

.............which seems to imply that holding gpio2 low during boot is not an issue. This however is not my experience and I read herein that posters to this site share my experience and warn against the practice.

I only have a few esp01 modules to play with just now so don't have access to other gpio ports (unless I get into some microscopic soldering fun which frankly my eyes are just no longer up to). I am trying to monitor a door switch which could be in either position at esp startup so I can't assume or rely on a particular startup state.

I read an instructables article that advises one to use the two gpio's 0 and 2 in tag team with one an input and the other an active low output to get around the problem.
The trick is to not connect the external switch directly from the GPIO0 or GPIO2 to GND but to connect it instead to another GPIO pin which is driven to ground (as an output) only after the ESP8266 starts up.
Does EPS Easy support this trick and if so, how do I implement it?

Thanks,

Brian H.
Uxnrige Ont.

Re: esp01 gpio2 low at boot?

Posted: 14 Jan 2017, 20:39
by uxhamby
Ok, I think I found the solution involving 'RULES'.

I have set a rule to make gpio0 go low after System#Boot and am connecting my door switch to gpio0 at one end and gpio2 at the other, with both pulled high through 10k. Seems to work and boots up fine regardless of switch condition.

Thanks for listening.

Brian H.

Re: esp01 gpio2 low at boot?

Posted: 28 Feb 2017, 18:48
by Kruu
I have the same problem. But I need to use both GPIOs, so I connect Gpio0 to gnd, and gpio2 to gnd to get info about two switches.

How can I solve booting problems?

ty

Re: esp01 gpio2 low at boot?

Posted: 28 Feb 2017, 19:31
by Shardan
Kruu wrote:I have the same problem. But I need to use both GPIOs, so I connect Gpio0 to gnd, and gpio2 to gnd to get info about two switches.

How can I solve booting problems?

ty
Hello Kruu,

short and simple - you can't.

GPIO0 is hardcoded to a specific behaviour:
If GPIO0 is connected to ground at startup or reset, the ESP8266 starts the firmware loader code and waits for a new firmware.

So if you have connected GPIO0 to gnd, it will start the firmware loader as soon as you power up.

As long as you use a push button that closes contacts only as long as it is pressed you can inverse it:
Pull up GPIO0 internally or by a resistor to 3,3V (Resistor 3,3K ... 10K) and connect the push button between GPIO0 and ground.
In the ESPEasy setup check the "Inversed" box.

If you use a switch that stays "on" you will run into problems anyways as this creates situations the ESP-01 will start into the loader
if the switch is closed and the ESP is rebooted.

Regads
Shardan

Re: esp01 gpio2 low at boot?

Posted: 28 Feb 2017, 19:35
by Kruu
Oh, great :(

So I must buy different ESP with more GPIOs? Or have only one switch connected to GPIO2 and gnd?

Is it safe for ESP to be in bootloader mode for long time, until I reset it when open switch?

Re: esp01 gpio2 low at boot?

Posted: 28 Feb 2017, 20:13
by Shardan
Honestly i don't have any experience what happens if you leave it in boot/firmware mode for long time.

There might be a way around:

Within the setup of ESPEasy you might switch off the serial port (under Tools --> Advanced, uncheck the "Enable serial port" box)
and use these pins as GPIO1 and GPIO3.

But remember you won't be able to do serail monitoring or reflashing the chip as long as the serial port is disabled.

Alternatively you can use a PCF8574 port expander and control up to eight IO's.
http://letscontrolit.com/wiki/index.php/PCF8574
This expander uses I2C and you may connect even more sensors and such so the ESP-01 can do a lot of things.


Regards
Shardan

Re: esp01 gpio2 low at boot?

Posted: 28 Feb 2017, 21:24
by Kruu
Which of the pins are those GPIOs then?

Re: esp01 gpio2 low at boot?

Posted: 28 Feb 2017, 21:55
by Shardan
On the pic you see the pins.

Pin 1 = Rx = GPIO3

Pin 8 = Tx = GPIO1
ESP-01.jpg
ESP-01.jpg (109.03 KiB) Viewed 20782 times

Re: esp01 gpio2 low at boot?

Posted: 03 Mar 2017, 08:50
by Kruu
I unchecked "Enable serial port" and after reboot I have blue light all the time, what can I do to get it to normal boot. Nothing is connected to pins except power.

I got it working.

But still if my switches are connected the WSP wont boot normaly, switches must be off to boot normaly.

Re: esp01 gpio2 low at boot?

Posted: 29 Apr 2017, 11:21
by fbrs
Hey i just found Brians solution but it doesn't work for me. Maybe i got it wrong?
In easyesp i declared under "Hardware" the "Pin mode 0 (D3): Output Low". Under "Devices" i set up GPIO0 and GPIO2 as Switch and checked Pull-Up. "Switch Button Type" is "Normal Switch". So then i connected one cable of the magnet sensor to GPIO0 and the other to GPIO2. That's it? No GND?

Edit: I forgot to tell, i have the Wemos Mini pro https://www.wemos.cc/product/d1-mini-pro.html. So maybe there are any differences?

Edit 2: Seems it works with GPIO16 and GPIO14. The startup is now withtout any problems. Just in case the magnet is away by starting up, easyesp says the switch is closed. But it gets "normalized" and works good after the switch was really closed. In practice it's a workaround, i could live with it.