After pushing physical button, blynk not responding

Hi, I have a project on Wemos R1. It is garage opener. I have app with button to trigger relay and physical button to check if the grage door is closed or open, but when it is open and button not pressed, so 3.3 volts are going in Wemos D6, the program freezes and i cant close the garage with my blynk app. But when i press the button again and leave it pressed blynk reconnects and it is working well. But then when i open the garage it freezes again. Do you have any solution?

And I have another question. How to send the message “GARAGE IS OPEN” only one time? You can see that in my code. It is spamming me every second when the garage is open longer :smiley:

Thank you for your help, I am a noobie in programming. :slight_smile:

    #define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "AUTH CODE";

SimpleTimer timer;
WidgetLCD lcd(V1);

char ssid[] = "ID";
char pass[] = "PASSWORD";

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

  Blynk.begin(auth, ssid, pass);
  // Setup a function to be called every second
  timer.setInterval(1000L, notifyOnButtonPress);
  digitalWrite(4, HIGH);
digitalWrite(12, HIGH);
}

void notifyOnButtonPress()
{
//   Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(D6);
  if (isButtonPressed) {
    BLYNK_LOG("Vrata!!");

    Blynk.notify("GARAGE IS OPENING!");
  lcd.clear(); //Use it to clear the LCD Widget
  lcd.print(0, 0, "     GARAGE"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
  lcd.print(0, 1, "    IS OPEN!");
  delay(5000); 
  lcd.clear();
  lcd.print(0, 0, "     GARAGE"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
  lcd.print(0, 1, "   IS CLOSED!");
  }
}

void loop()
{
  Blynk.run();
 timer.run();
}

Tell us more about the physical button. Is it a microswitch that is actuated when the garage door reaches the open position, or is it a switch in the garage to manually open/close the door?
How is the switch wired to the Wemos? Which pins are used?
What pins are you using for the widget buttons? Is one for up and the other for down.

Pete.

Hi, sorry for the delay, I had lot on my plate. I have a relay connected to my pin D2. This relay is connected to the physical switch for opening the garage, therefore I can open my garage through App or physical switch on the wall. Then I have Micro switch on pin D6, that is mounted on the garage and it is pressed down all the time, but when the garage opens the micro switch gets “unpressed” (sorry, don’t know the right word) and sends signal to Wemos and code above sends me a notification that garage is openned. But when I “unpress” the micro switch whole Wemos freezes and i have to restart it. That is the main problem. There is only one button for opening and closing because the motor for garage only needs split of a second pulse and it starts closing/opening. My app button for opening/closing is on GP4(digital2 on the board) Thanks for your help. :slight_smile:

can anyone please help me?

You didn’t really answer the questions I asked you in enough detail for me to be able to help.

You’ve said that one side of the microswitch is connected to pin D6. Where is the other side connected to - is it Ground or +3.3v ?
When the microswitch is activated by the garage door, is the circuit between D6 and the unknown pin open, or closed?

The more information you provide, the more likely it is that someone will be able to help, but if we have to ask 20 questions to get the whole picture then it probably won’t happen.

Pete.

The other side of microswitch is connected to the GND and when you press it, it will send gnd to pin D6. And there is not any unknown pin. Just D6—>microswitch—>GND.

If you don’t have a pull-up resistor on D6 then it might be floating and causing some false triggering.

I have kind of massed with the code and I’m pulling-up by code. D6 has pull-up resistor

So D6 is connected to Ground all the time that the garage door is closed, and as soon as the door begins to open D6 is disconnected from Ground - at which point your Wemos freezes. Is this correct?

Pete.

Yes! Exactly what’s happening.

If you’ve messed around with the code then you should post your updated code.

In the code you posted above, the bit that relates to a change in state of the switch connected to D6 is really designed for a momentary push to make switch where pushing the switch will invert the IsButtonPreessed integer.
In your situation, you should be reading the state of D6 to know whether your garage door op open.
If D6 is low then GarageDoorOpen = false, else GarageDoorOpen = true

Pete.

@Andy007 first of all, you should set:

pinMode(D6, INPUT_PULLUP); 

To set the pull up resistor on this pin and also set the pin as an input, don´t see this on your code.