I use the Arduino IDE with the core https://github.com/esp8266/Arduino
I have connected a push button between the GND and the RST pin, so when I push it (connecting RST to ground), the sketch should always start from scratch and run.
If the sketch was already running, it should restart from scratch after the hard reset.
If it was in deep sleep (my sketch always ends entering deep sleep), the reset wakes up the ESP8266 and it should run the sketch from scratch. So no matter what, at every reset it should run the whole sketch from scratch.
One of the two ESPs I have works as expected.
The other, however, randomly, about 50% of the times I do the hardware reset, doesn't run my sketch, or apparently anything for that matter.
If connected to the Serial Monitor:
When working as expected, after a hardware reset I observe this output:
//...and then the output from my code
When not working, after a hardware reset, only a few characters of garbage show up, and then nothing. I have no way of knowing whether the device goes to deepsleep, or does nothing, or gets stuck doing something or waiting for something, but there's no output whatsoever on the serial port no matter what debug level I upload the sketch with. It certainly doesn't run my code, and it doesn't even print the SDK version line.
Also, if I do not connect the USB and run it on external power (batteries), when I disconnect and connect the power, the same (apparently) happens: sometimes it runs my code, sometimes it just does nothing - I can tell because the first thing my code does is flash the LED. Of course in this case I have no serial output and I can't tell for sure if the same happens as when connected to the computer, but I can tell for sure it doesn't (always) run my sketch.
The garbage that shows up on the serial monitor when the issue happens is this: (see attached screenshot, can't copy and paste).
Is there any way I can decipher that?
Any idea what the issue could be??