Button Timeout Limit

No. Only 1 command is send on press and 1 command on release.

2 Likes

But he is using it as push type n not as switch. So it will be flooding right ?

1 Like

No. The only difference is that the switch button changes the state right away. While with the push button state is preserved until you release the button.

1 Like

I had misunderstood this the whole time. Sorry for the wrong information.

1 Like

The button widget in PUSH mode sends a 1 when pressed, and a zero when released
In SWITCH mode it sends a 1 when it goes from off to on, and a 0 when it goes from on to off.

There is no constant stream of 1ā€™s when it is pressed in PUSH mode, so no server flooding.

@timgtech Iā€™ve just flashed this code onto a NodeMCUā€¦

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "REDACTED"
#define BLYNK_DEVICE_NAME "REDACTED"

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

char auth[] = "REDACTED";
char ssid[] = "REDACTED";
char pass[] = "REDACTED";

void setup()
{
  Serial.begin(74880);
  pinMode(2,OUTPUT); // NodeMCU built-in LED, Active LOW
  digitalWrite(2,HIGH); // Turn the LED off
  Blynk.begin(auth, ssid, pass);
}

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

BLYNK_WRITE(V0)
{
  Serial.println(param.asInt());
  if(param.asInt() == 1)
  {
    // execute this code if the switch widget is now ON
    digitalWrite(2,LOW);  // Set digital pin  LOW
  }
  else
  {
    // execute this code if the switch widget is now OFF
    digitalWrite(2,HIGH);  // Set digital pin HIGH
  }
}

The onboard LED stays On for as long as the button widget attached to V0 is pressed. This is what the serial output looks like:

09:39:35.898 -> 1
09:40:06.307 -> 0
09:40:12.881 -> 1
09:41:10.980 -> 0
09:44:53.952 -> 1
09:46:12.927 -> 0

As you can see, you can keep the button widget pressed for as long as you wish, and the Off (0) command is received when the button widget is released.

Iā€™d guess that thereā€™s an issue with the board or the relay (possible power issues?) or the WiFi connection, but there is no change in behaviour of the button widget between Blynk Legacy and Blynk 2.0.

Pete.

3 Likes

Just tested it also, i can confirm that the pushbutton works as it should be. So itā€™s not a Blynk problem.

2 Likes

This is really bizarre! I really do appreciate everyoneā€™s help and input. Using the same board, with the same relay, and the same power supply, and the same code that I have always used with the old Blynk it behaves this way with the new Blynk. I went back to the old Blink and it works just fine. This really is not a big problem or a deal breaker in the grand scheme of things. Just very very strange.

For now when, I move it back to the new Blynk I will just use the Switch instead of momentary button. This is probably the one and only project that I will need to do this with.

Thanks again everyone. :slight_smile:

Just out of curiosity, how long are you able to hold the button down and it stay on? (whatever you are turning on).

The longest I tested was 1 minute 15 secondsā€¦

I couldnā€™t be bothered to do any longer, especially as you said they 10 seconds was the longest you could achieve.

Pete.

I tested it for about 40 seconds

maybe its his phoneā€¦

I had this problem on both Android and iOS and different MCU boards. For whatever strange reason now the problem mysteriously just went away it seems. Thanks everyone for the help and suggestions. We can call this one closed.