Reset the board/ power failure/ internet off/ wifi router reboot, the device is pushing the selected gpio

any news about this problem? I have the same problem with a push button. Whenever i reset the board/ power failure/ internet off/ wifi router reboot, the device is pushing the selected gpio. There is any way to solve this problem?

Why dig up an older & solved topic to ask a new question? I moved your post to your own topic.

As for your issue, with a little searching you would see that it is a known situation with ESP8266 (assuming that it what you are using, since you didn’t say :wink: ) that upon boot, some pins go to different states, some HIGH, some LOW, most toggle between both before settling.

If this doesn’t match your issue, then please provide actual details of your situation, board type, code (properly formatted), etc…

Also, please read the Welcome Topic for this forum, prior to posting. Thank you.

Thanks for the picture. New info for me :). Tried some other pins, but the problem persist.
I’m using a simple relay connected to board.
I was looking closer in Serial Monitor, and i saw that when the board is connected to blynk server (Ready (ping: 31ms) the relay is changing state for ~0.5 sec.

Board used NodeMCU
I’m using the simplest code blynk blink …

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxx";
char pass[] = "xxxx";

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  Blynk.syncAll();
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()

{
  Blynk.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

Thanks for reply!

Rather than choosing digital pins within the app, I’d use virtual pins instead.
Try the code below.

Attach the relay to pin D1 and your switch widget to Virtual Pin 1 in the app.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxx";
char pass[] = "xxxx";

int Relay_Pin = 5;  // Connect the relay to GPIO5 (Pin D1 on the NodeMCU)

BLYNK_WRITE(V1)                             // This code is triggered when the App button widget on V1 changes state
{
  int pinValue = param.asInt();             // Assign incoming value from pin V1 to a variable

  if (pinValue==1)                          // Do this if it was an On command from the Button widget in the App
  {
    digitalWrite(Relay_Pin, HIGH);          // Turn the relay On
  }
  else                                      // Else do this if it was an Off command from the Button widget in the App
  {
    digitalWrite(Relay_Pin, LOW);           // Turn the relay Off
  }
}



void setup()
{
  pinMode(Relay_Pin, OUTPUT);                  // Define the relay pin as an output
  digitalWrite(Relay_Pin, LOW);                // Turn the Relay off  
  
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);

}

void loop()

{
  Blynk.run();
}

This assumes that you’re using a relay that is active HIGH (it turns on when pin D1 is made HIGH). If the relay works the wrong way around then change all of the LOW commands (including the one in void setup) to HIGH and vice versa.

Pete.

Hi Pete, thanks for reply! I was thinking to try with virtual pins, but didin’t know exactly how to do it …i’m noob :smiley:… so thanks for code! I had to change the HIGH/ LOW states, and to add Blynk.SyncAll, and it’s running perfectly! :slight_smile:

Many thanks for your help!

1 Like

It’s not a good idea to use Blynk.syncAll, which is why I removed it from your code.
Much better to use Blynk.syncVirtual(V1) in your case.

Pete.

you are right! Thanks again!

1 Like