Issue with Digital button and logic state

So I have this code bit…

int relayOne = 9;

void setup()
{
  Blynk.begin(auth);

  pinMode(relayOne, OUTPUT);
  digitalWrite(relayOne, HIGH);

the problem is when I start my program on the App, the button is not setting its state to the equal state (button shows off) I have set in code to be high which would make the current app code show the button ON. So I end up having to push the button twice on the app to get it to “synch” with the real logic state of the GPIO

I dont see a way currently to make sure the button reflects the pin logic state like a “force push of logic” to the App
is there one? or is this a bug that needs to be ironed out?

1 Like

Good point, we have it on our Roadmap
Updating UI accordingly to the hardware state is still a feature to implement.

2 Likes

And, we have actually developed an experimental way of handling it, but unfortunately can’t release it yet.
We want to be sure that the API we introduce is meaningful and persistent, so there’s some delay.

Keep tuned! :wink:

1 Like

I was in the process of writing a similar feedback, i.e. the lack of persistance.
What I tried is this:

  • create an App with a button configured as switch and tied to an output in my Arduino
  • run the app, turn the switch ON (le the LED lights up)
  • brutally close the Blynk application from iOS
  • restart the Blynk app

I would expect to find the switch in the ON position, but this is not the case i.e. the switch status is not persistent.

Glad to know this is a feature to be introduced soon

Thanks
Luciano

1 Like

Similar issue here on Android.

No need to brutally close the app. Same "mis"behaviour by just disconnecting(stop) and connecting(start) the project again while an LED was set. After reconnecting the LED state is not up to date.

Same issue if I start to connect from a second app to the same device, LED state is not up to date.
While both are synchronised everything works fine. GREAT JOB BLYNK TEAM!

Was thinking of an update function/callback which could be called in void setup() and by a freshly connected project?

Thanks, looking forward to hear some news,
CaptBlaubaer

1 Like

A post was split to a new topic: How should I change the digital pin state and this change be reflected in the app