On boot up pins go high!

Hello there !

I use blynk on the Esp8266 Nodemcu V3 . I use 2 digital pins but on every boot these are go to hight state without push the button on the app!!!

I use GP12 - GP13

Any solution or tip - help ?

Thanks!

Not related to Blynk.

In setup() just write the pin low

digitalWrite(pin,LOW);

I allready tried :frowning: Its weird but Nothing !!

Thanks for your reply!

I don’t have NodeMCU v3 to test with - Just use virtual pins if you want to override any unexpeted behaviour.

Paste your code and format it correctly like so

```cpp
CODE
```

I use this virtual pin to call it!

BLYNK_WRITE(V5)  
    {
       int widgetValue = param.asInt();
       
       if (widgetValue == 1) {          //if Button Widget value is 1 (HIGH)...
           digitalWrite(12, HIGH);   
            delay(1000);                
            digitalWrite(12, LOW);    
            delay(1000); 
          led_deactivated.off();
          led_activated.on();         
          Serial.println("Alarm Activated");
       } else {                         //otherwise..
            digitalWrite(13, HIGH);   
            delay(1000);                
            digitalWrite(13, LOW);   
            delay(1000);   
            led_deactivated.on();
            led_activated.off();               
            Serial.println("Alarm Deactivated");
       }
}


void setup()
{  
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);  
  
  digitalWrite(12, LOW); 
  digitalWrite(13, LOW); 
 
  Serial.begin(9600);
  Blynk.config(auth,"***********",8442);
  Blynk.connectWiFi(ssid, pass); 
}

Works Perfect but on reboot it goes hight and auto-deactivate the alarm!!

You code looks fine.
Try adding this to the bottom of setup()

Blynk.syncVirtual(5);

Upon boot it should look at the virtual pin state

Thanks for your time but again nothing … When i reboot it the pin activated!!! I will broke it!!! :slight_smile:

Hmm and when you boot up your button widget is definately LOW?

I just ran the code and it works fine on my ESP8266 WeMos clone and my NodeMCU clone.

When you boot up, you want the hardware to know the last state? or do you want it to boot “alarm off”?

Yes my button widjet is LOW…

When i bootup i want my arduino don’t push the alarm unlock button :slight_smile: because when i activate it and for some reason the nodemcu reboots i don’t want the auto-deactivate of my home alarm!

The pin gets hight state instanlty after push the reset button for restart or unplug the power and reboot… I use transistor to simulate the click on the key fob (if this helps)

You’ve lost me…

Lets picture a senario…

You are leaving and want to set the alarm… set it ACTIVE
Then the power goes out and your hardware resets. You would want the alarm to boot up ACTIVE.

Right now in the code below, your hardware should sync its state with the widget upon boot.
Its working fine for me.

BLYNK_WRITE(V5)  
    {
       int widgetValue = param.asInt();
       
       if (widgetValue == 1) {          //if Button Widget value is 1 (HIGH)...
           digitalWrite(12, HIGH);   
            delay(1000);                
            digitalWrite(12, LOW);    
            delay(1000); 
          led_deactivated.off();
          led_activated.on();         
          Serial.println("Alarm Activated");
       } else {                         //otherwise..
            digitalWrite(13, HIGH);   
            delay(1000);                
            digitalWrite(13, LOW);   
            delay(1000);   
            led_deactivated.on();
            led_activated.off();               
            Serial.println("Alarm Deactivated");
       }
}


void setup()
{  
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);  
  
  digitalWrite(12, LOW); 
  digitalWrite(13, LOW); 
 
  Serial.begin(9600);
  Blynk.config(auth,"***********",8442);
  Blynk.connectWiFi(ssid, pass); 

  Blynk.syncVirtual(5); // set to current widget button state.
}
1 Like

Yes this is a solution but the perfect for me is just to don’t click anything!!

But WHY ? When i click reset instant without booting up he gives power to the pins ??? Maybe its hardware failure ?

Try using a different GPIO pin?

OK i will thanks you @Jamin for your messages!

I will post results! :slight_smile:

@Jamin i change it again the same!!!

I don’t know if this is normal… On every pin on boot the pin gives me voltage… WTF??? And the button activated!!! How is that possible ?

Do you have any other hardware to test?

Paste your entire sketch

Yeeeeeaaaaaaa!!!

Finally!!! Worked at pin D1 D2 (GPIO4 GPIO5) :slight_smile: :slight_smile: (Lock - Unlock)

I thing the board is broken or bad quality… IDK :frowning:
I want to know the answer but i can’t find the error …

And now on reboot works normal (It doesn’t give voltage to the pins D1 D2)…

1 Like

Great you got it working!

Hopefuly this issue was to do with the board and thats it! :slight_smile:

Yeaa my friend! Thanks for your help! :slight_smile:

1 Like

@Dimitris I have same issue in my nodemcu.
To solve it, in setup, I first connect to the server and after I set the pinmode to output and to low, it worked for me on every pin. Lets try it.

2 Likes