Problem with the button

Hello everyone
My system has a esp8266 esp 01 use a Blynk button and the GP02 command output the coil of a relay which turns on a lamp to me.
The problem is that sometimes the button remains on, I have to press one more time to put it off.
Where am I wrong?
Thank you

Hello Spaceace,
Firstly…awesome name!

Secondly, it’s a friendly forum so feel free to ask any questions but we might need more information in this case. Can you show your code? Is your button set as a ‘switch’ or ‘push’?

I have a similar issue on android with button in push mode. Tap it and it stays highlighted… tap again and back to normal

Do you guys use the Sync feature? It could be related to that, but without some code it’s hard to explain, as @NickMurray indicated :slight_smile:

Hello NickMurray
Today I wanted to try something else
I made an app to open two automatic gates.
I opened the remote control and two buttons I soldered two wires, they have connected to 2 relays them, I fed and sent the GPIO0 GPIO2 output and the inputs of the relay.
With Blynk use 2 button push.
It’s okay gates open, but occasionally (1 time out of 50) the button is in the ON, and unfortunately if I did not realize I will discharge the battery.

1 Like

Instead of using a Switch Button… try a momentary button as there is no set state.
Then use an LED widget to output the current state of the relay.

You would also benefit from using Virtual Pin writes instead of direct pin writes as you can perform other functions at the same time.

void setup(){
  int varButtonStatePrevious  = 0;

  varButtonState = param.asInt();
  if (varButtonState == 1 && varButtonStatePrevious == 0) {
       int Relay1state = digitalRead(GPIO0); // get current state of relay
       digitalWrite(GPIO0,!Relay1state);     // switch relay to opposite state
       Blynk.virtualWrite(V2, !Relay1state); // send back same state (LOW/HIGH) to LED widget on V2
       delay(10); // crude de-bounce
  varButtonStatePrevious = varButtonState;
1 Like