ESP8266 Memory Erasing

I am having a problem keeping code on my ESP. I have a very simple task that I want this board to accomplish, I have a push button (connected to ground with a pull-up resistor) that is connected to pin 0 so I can read whether it is high or low. Then I send that to the server and I can read it from my web browser. Everything works perfectly right after I upload, however, after the board has been disconnected from power for a while, when I power it up, it no longer works. I have to re-upload the sketch in order to get it back in a working state. It’s acting as if it’s brand new every time it has been off for a little while(5-10 minutes or more).

Some more info:
I am using an adafruit feather ESP8266 board so I can power it from 5v micro usb, and upload easily.
I am using arduino IDE to program it, and the sketch I wrote is a modified version of the ESP blink sketch, with other code examples from A Beginner's Guide to the ESP8266

The only additional classes I am using are these ones:
<ESP8266WiFi.h>, <WiFiClient.h>, <ESP8266WiFiMulti.h>, <ESP8266mDNS.h>, <ESP8266WebServer.h>

I am trying to avoid adding an arduino as a middle layer between the button and the ESP, but if that is the only way to make it work, I will give that a shot. Any suggestions are greatly appreciated!

Try using a different pin, a pin that doesn’t have an LED and transistor hanging off of it like pin zero has.

What WattsThat said probably.

In case you don't know, ESP pins are not as simple, one-purpose pins as Arduino pins are. You can't connect anything to anything and expect it to work 100% of the time, so to speak.

What does what depends on the board you have, which determines what IO pin number corresponds to what GPIO on the ESP. So you might want to start looking for that.

ClydeFrog04: I am trying to avoid adding an arduino as a middle layer between the button and the ESP, but if that is the only way to make it work, I will give that a shot. Any suggestions are greatly appreciated!

I think adding a middle arduino is the best approach to follow in case of cloud computing projects where you need to send or receive data from some web server.

I have worked on many web embedded projects, and I use Arduino mini or Arduino Pro Mini for interfacing of all my sensors etc. and I communicate this data via serial pins between arduino & esp8266 ( normally Nodemcu v3) and then upload this data over to server. It makes the programming quite easy and flexible.

Cosme_Fulanito: What WattsThat said probably.

In case you don't know, ESP pins are not as simple, one-purpose pins as Arduino pins are. You can't connect anything to anything and expect it to work 100% of the time, so to speak.

What does what depends on the board you have, which determines what IO pin number corresponds to what GPIO on the ESP. So you might want to start looking for that.

That’s good advice, why haven’t you followed it? Have a look at the Feather schematic for pin 0, there is an LED and a transistor connected to it, both considered outputs. You then add a pushbutton and a pull-up, an input function. Do you see the conflict?

It certainly is easy enough to move your input function to an unused pin and try it.

Hey thanks for all of the replies! I switched to pin 15 and things seem to be working as expected without any memory erasing like symptoms! I will keep in mind for future projects to use an arduino in the middle. I just didn't want to for this one because I really only need one switch and an arduino seems excessive. Thanks for the advice on finding the right pin to use!