Blynk API for buttons

Could you please explain how to work with buttons using Blynk API?

I’ve read FAQ and API docs on apilari.
I use GET to receive and update data.
Now I’d like to receive commands.

My current flow:

  • sensor sleeps
  • wake up, connect to WiFi, measure, send data using Blynk API
  • get new parameters (LED display brightness, sleep time, etc)
  • go to sleep

What about button which I push and release?
Will I receive its status via GET that it WAS pushed during my sleep period despite of it is released now?

I guess I can use the button in a switch mode and change back to Off via API after receiving its state/command (when wakes up).
But what about simple “push” button? Theoretically short click can be missed even when using the native Blink library. Or not?

No, when the API call is made, the Blynk server will return the current status of the button, not a list of statuses that may or may not have existed during an arbitrary sleep period (which the server isn’t really tracking).

Yes, it will be missed

Maybe the answer is to update a hardware device that doesn’t sleep, and use that to store a flag indicating if a button was pressed during the sleep period.


Thank you Pete.
I guess the use of button in the Switch mode is fine.

  • Normally it is Off
  • I push it
  • it is ON now
  • device wakes up and reads the state
  • device sets its state to Off
  • I can see that now the button is Off (and realize that it was processed by the device)

Is it technically correct?

Yes, that should work.