Environment - WeMos D1 with ESP8266 WiFi
Sketch - Blynk Examples - Widgets/LED/LED_StatusOfButton
Problem - A particular line of the code in the 'Setup" section ( pinMode(btnPin, INPUT_PULLUP); which seems perfectly valid causes the wireless connection to continuously drop and reconnect every second.
The sketch compiles and loads perfectly then the device connects to the WiFi but immediately drops and reconnects after about 1 second. Disabling that particular line of code resolves the continuous disconnect/reconnect problem.
Here is the link to the code taken from the Blynk Example sketch generator
I don’t have that board, so this is just an educated guess… but those boards are apparently particular on which pin is used for which purpose… reportedly even differing between R1 & R2 of the board… and then there’s the mini…
The sketch you are trying stays mostly the same regardless of the type of board you state that you are using… so not really a bug so much as the usual… tweek… to your hardware configuration… that is so common in the Arduino world
I would suggest that you simply change the const int btnPin = 7; to a different pin and test again, and again…
Thanks very much for your response. The board is a D1 mini (not sure if it is a R1 or R2) but I did try specifying different input pins with the same result. I normally use an UNO R3 which I find to be rock solid.
This little problem is bugging me and I won’t get any sleep until it is resolved. Thanks again and cheers !
One other issue… do you have a physical button hooked up properly? (and confirm that it is not stuck).
Any ESP8266 based board seems very susceptible to interruptions (button bounce, too long of a delay, looking at them sideways…) and then they disconnect.
Try without the button… if all is stable, then experiment with button debouncing (Google that… there are both hardware and software solutions).
Success !!! I changed the input port to 13 and it now works great. On my WeMos, the pins are still labelled D1 - D8. I never would have expected such symptoms by simply addressing a non-existent port.
Thanks very much for your help. I can now get a good night’s sleep. Hope someone will note this and correct the example sketch.