ESP8266 it is constantly restarting

Hey. I’m just starting to play with ESP8266. At the beginning I want to make one physical button. In the application it has to change the state after each press. I found such a program here:
Unfortunately, when I download this code, my ESP keeps restarting. I suspect that this is too often a question for the server. Even if the pauses are longer, the problem remains. Why is this happening ??

Can you post a diagram or photo of exactly how you’ve wired the physical button to your ESP?


I know that other pins are selected in the drawing than in the example code. It’s about a constant restart. I do not have to hook anything and it keeps restarting.

So if you’re saying that the NodeMCU keeps restarting even when its removed from the breadboard and simply connected to the PC via the USB connector then it’s likely to be one of the following:

  1. Poor power supply - either the USB port on the PC is faulty or the cable is faulty
  2. A bad flash - re-flash the code and ensure that you’ve chosen the correct settings
  3. Faulty hardware - Your NodeMCU is broken
  4. Dodgy installation the Arduino IDE, ESP core, or Arduino libraries

What does the serial output show?

Edited to add - it might be worth re-flashing with the “Erase Flash - All Flash Contents” option selected


I did everything you wrote. Unfortunately, nothing worked.
Serial show

[7126] Connecting to
[12127] Connecting to
[17128] Connecting to
[17611] Ready (ping: 256ms).

⸮[46] Connecting to RossiQ
[15551] Connected to WiFi
[15551] IP:
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.4 on Arduino

[15630] Connecting to
[20631] Connecting to
[20908] Ready (ping: 52ms).
⸮[46] Connecting to RossiQ
[11551] Connected to WiFi
[11551] IP:
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
/___/ v0.5.4 on Arduino

[11630] Connecting to
[16630] Connecting to
[16681] Ready (ping: 24ms).

But if I download another program, everything works correctly.

Does this “other” program also connect to WiFi? It is usually a poor power-supply/WiFi usage combo that can cause a brownout and reset.

Yes. Other programs connect to wifi. for example, I am using an RGB zebra. There must be a separate RGB LED power supply and separate to ESP. In this case, it’s OK. Or maybe the program itself is wrong ??

More likely you have made some changes, pin choices, etc that disagree with the ESP… Not all GPIO pins are equal, and some do not like to be held high or low when booting (via pinMode() or physically).

@Piotr_Rosol says that these restarts are happening with with no external connections to his NodeMCU.

Out of curiosity, I tried the same sketch builder code myself and uploaded it to a Wemos D1 Mini.
Surprisingly, I suffered exactly the same results - restarts every few seconds and the same sort of output to the serial monitor, even with nothing connected to the Wemos apart from the USB power/serial lead.

I think the culprit is these 2 lines in the sketch builder code:

const int ledPin = 7;
const int btnPin = 8;

These pins are in the “These pins are reserved for MCU - flash communication, do not use!” range.

The code tries to do a digitalRead on GPIO8 and this causes the device to immediately reset.

Changing the code to:

const int ledPin = 4;
const int btnPin = 5;

solves the problem (I’ve not taken it a stage further and attached a physical switch or LED, but the constant reset problem is solved).

Maybe time for someone at Blynk Towers to update the sketch builder examples for the ESP/NodeMCU/Wemos D1 Mini devices?


1 Like

Using the “report a problem” button in the Sketch Builder, I submitted a report…



Thanks @Gunner,
I have to admit that I’d never noticed that button before (or the Copy Example button either!).


It is in a non-scaling font and thus not easily visible :stuck_out_tongue_winking_eye: :innocent:

1 Like

Hello. After changing the pins on the one you can use. Everything started to work correctly. The only problem is the inability to use all pins from ESP8266-12E. For my project, I have to use 2 ESPs in this situation. Well, unless you have a solution to my problem :slight_smile:
3 physical buttons control 3 relays (6 pins have already been used) and connecting 2 RGB tapes (next 6 pins) Is it possible on one ESP ??
Yes. RGB colors are to be independent of each other :slight_smile:

It depends how creative you want to get to avoid using two devices.
You could use the analog pin as an input for your three switches. Have resistors of different values attached to each switch, so that a different voltage is read when each of the switches is pressed. You’s have to work-out what you wanted to happen if multiple buttons were pressed at the same time and choose your resistor values accordingly.

Or, if you beef-up your coding skills you could explore using an ESP32, which has built-in pins dedicated to being used as touch switches.



In that case, think about it using 2 ESPs. Thank you so much for your help.

Or you could use one of THESE. They are quite simple to use and there are some YouTube videos that can give some guidance.

1 Like