esp01 gpio2 low at boot?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
uxhamby
Normal user
Posts: 132
Joined: 29 Dec 2016, 18:13
Location: Toronto Canada

esp01 gpio2 low at boot?

#1 Post by uxhamby » 14 Jan 2017, 18:49

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.

User avatar
uxhamby
Normal user
Posts: 132
Joined: 29 Dec 2016, 18:13
Location: Toronto Canada

Re: esp01 gpio2 low at boot?

#2 Post by uxhamby » 14 Jan 2017, 20:39

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.

Kruu
New user
Posts: 4
Joined: 28 Feb 2017, 18:46

Re: esp01 gpio2 low at boot?

#3 Post by Kruu » 28 Feb 2017, 18:48

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

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: esp01 gpio2 low at boot?

#4 Post by Shardan » 28 Feb 2017, 19:31

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
Regards
Shardan

Kruu
New user
Posts: 4
Joined: 28 Feb 2017, 18:46

Re: esp01 gpio2 low at boot?

#5 Post by Kruu » 28 Feb 2017, 19:35

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?

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: esp01 gpio2 low at boot?

#6 Post by Shardan » 28 Feb 2017, 20:13

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
Regards
Shardan

Kruu
New user
Posts: 4
Joined: 28 Feb 2017, 18:46

Re: esp01 gpio2 low at boot?

#7 Post by Kruu » 28 Feb 2017, 21:24

Which of the pins are those GPIOs then?

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: esp01 gpio2 low at boot?

#8 Post by Shardan » 28 Feb 2017, 21:55

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 20678 times
Regards
Shardan

Kruu
New user
Posts: 4
Joined: 28 Feb 2017, 18:46

Re: esp01 gpio2 low at boot?

#9 Post by Kruu » 03 Mar 2017, 08:50

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.

fbrs
New user
Posts: 1
Joined: 29 Apr 2017, 11:02

Re: esp01 gpio2 low at boot?

#10 Post by fbrs » 29 Apr 2017, 11:21

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.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 24 guests