How difficult/easy is this? And if it's possible could I have a hand?

I’d like to use Blynk to basically give me a push button on my iPhone that I can use to fire off a “Particle Publish” from my Particle Photon. I gather this can’t be done directly but would have to be done via a virtual pin? After that…I’m a bit lost.

Thanks!!

@boomdom I’ve not used a particle board and presume “Particle Publish” is a firmware routine available on the Particle board.

In Blynk app, you define a button attached to virtual pin V1. In your sketch, create a function BLYNK_WRITE(V1) to invoke publish. Am giving an example code snippet below:

BLYNK_WRITE(V1)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  digitalWrite(sw1, pinValue);
  stat_sw1 = pinValue;
  Serial.print("\nApp button change. V1 is set to ");
  Serial.println(pinValue);
}

When you press the button in the app, this routine will get executed. Trust this helps.

2 Likes

Sounds very doable! Thank you! :slight_smile:

Final (hopefully) question @mohan_sundaram, it says in the guidance to keep the loop to just two lines - does this mean I have to completely refactor any existing Particle Photon code before I can integrate with Blynk? And remove stuff out of loop and into functions?

Yes. Loop should be as clear as possible. Also, use Timer library available in Particle IDE