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:
https://examples.blynk.cc/?board=ESP8266&shield=ESP8266%20WiFi&example=More%2FSync%2FSyncPhysicalButton
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?
Pete.
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:
- Poor power supply - either the USB port on the PC is faulty or the cable is faulty
- A bad flash - re-flash the code and ensure that you’ve chosen the correct settings
- Faulty hardware - Your NodeMCU is broken
- 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
Pete.
Hello.
I did everything you wrote. Unfortunately, nothing worked.
Serial show
[7126] Connecting to blynk-cloud.com:80
[12127] Connecting to blynk-cloud.com:80
[17128] Connecting to blynk-cloud.com:80
[17611] Ready (ping: 256ms).
?0⸮⸮)
⸮
⸮[46] Connecting to RossiQ
[15551] Connected to WiFi
[15551] IP: 192.168.1.14
[15551]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.5.4 on Arduino
[15630] Connecting to blynk-cloud.com:80
[20631] Connecting to blynk-cloud.com:80
[20908] Ready (ping: 52ms).
H⸮⸮⸮!⸮D⸮
⸮[46] Connecting to RossiQ
[11551] Connected to WiFi
[11551] IP: 192.168.1.14
[11551]
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ v0.5.4 on Arduino
[11630] Connecting to blynk-cloud.com:80
[16630] Connecting to blynk-cloud.com:80
[16681] Ready (ping: 24ms).
⸮⸮⸮⸮!⸮⸮D⸮
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?
Pete.
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!).
Pete.
It is in a non-scaling font and thus not easily visible
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
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
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.
Pete.
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.