Can we use only when App is opened?

Hi there
I am working in a project using NodeMCU and I have programmed it. I am using Blynk as well. I wanna know if we can stop the programme uploaded on NodeMCU when Blynk Application is running? Please help, it’s urgent…

You can’t stop a program flashed to an MCU without flashing a blank sketch to the processor.

But with Blynk you can stop the initial sketch from doing anything meaningful.

Blynk button is 0 or 1.

Pseudo code:

if button is 1 do your code
else loop doing nothing.


Can you give me the code please. I am a noob…

@mehulvarshney build this project and study the code.


  App project setup:
    Button on V0 in Switch mode
    Value Display widget attached to Virtual Pin V5

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
char ssid[] = "xxxxx";
char pass[] = "xxxxx";

bool isRunning = true;

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
    // You can send any value at any time.
    // Please don't send more that 10 values per second.
    Blynk.virtualWrite(V5, millis() / 1000);

    isRunning = true;  
    isRunning = false;  

void setup()
  // Debug console

  Blynk.begin(auth, ssid, pass);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);

void loop()
{;; // Initiates BlynkTimer
1 Like

I am not aware of any way of knowing (in the sketch) if the app on the phone is running or not.
You can tell if the sketch is connected to a Blynk server.
So there is no way to decide if the app should halt unless you add a button the app that stops the sketch.

The aim you have stated makes no sense at all though. If you only want the sketch to run when there is no app running, begs the question of why you have the app, and hence Blynk. So I think you have to make another attempt at describing what you are trying to achieve.


if I am to answer the question posed as the title and ignore the description, the answer is NO.

You can use when no app is running.

Try it.

1 Like

Thanks @DaleSchultz For looking In the Matter but in this project, I just wanna turn ON my LEDs in a customized way through Blynk and stop the Programme that I have uploaded (to function for My Particular Purpose). It is just like you are having a chocolate bar gradually and when you see a cake you dine upon it and leave the chocolate bar for the time being and once the cake is finished, you finish your Chocolate Bar. :sweat_smile::sweat_smile: I know it’s a lame example, but still

@Costas thanks, I’ll look into it :pray::pray::pray:

in that case, you have to prevent your code that change the LEDs to prevent them from executing. You have to have code running for Blynk to work, in the loop() keeps it running.

To stop your old code, either remove them, or add an additional layer, by adding a button in the app that sets a flag in your code that makes your old lines get skipped. So once the button is pressed, the app is in control. But you have to decide how to give control back, either one has to unclick the button in the app, or let it time out, after no commands are received for a certain length of time, you reset the flag, so your code can control the LEDs again.

@DaleSchultz Thanks, that was what I was looking for. But, I don’t get how the button is to be added. Is it to be added through Blynk Application or Arduino IDE? and if from Arduino IDE, what’s the code… Sir, please help me out… I have to participate in a competition and deadline is approaching!

You just lost my interest in helping you right there!
If you’re taking part in a competition then what you submit should be your own work.

You’ve been given a pointer - add a switch widget and the corresponding code - for the rest you’ll need to do some searching and some trial and error experimentation of your own.


1 Like

Thanks Pete for coming here and giving me a Pointer. I asked that because I am very new to this and what I came through searching Was Blynk Community. In a competition, one can’t do anything himself, right? because even in an World Class Competition you need some help to give you the path @Pete But Sir @DaleSchultz conveyed the pointer which I could not understand. Sorry but take it in a positive sense. No offense @Pete sir

@Costas Thanks, I got what you wanted to say…

@Pete I got your point. Thanks, I will perform my task and have it done with help from Blynk Community