Blynk App Connected Event in NodeJS

Hello everyone,

I am working on a project using Raspberry Pi and the [blynk-library-js]. I noticed in the [documentation] there is a function BLYNK_APP_CONNECTED() in the Blynk C++ library, and I want to have that function in my program, too. I have been searching in the JS library, but seems like that function is not there. I also tried to replicate the function in C++ library, but I couldn’t due to missing definition of “InternalPinACON” and “InternalPinADIS”. Specifically:
In C++ library:

I tried to search through the whole library but I couldn’t find the definition of these 2 variables.
So I would like to ask you guys:

  1. Where are these variables defined ?
  2. How can I implement such a function in JS library ?


1 Like

I have also tried using the BLYNK_APP_CONNECTED() and BLYNK_APP_DISCONNECTED() functions in a setup where:
Hardware: Arduino + ESP8266 using AT commands


#define BLYNK_PRINT Serial
  Download latest Blynk library here:

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials:
    Sketch generator: 
    Blynk community:  
    Follow us:        

  Blynk library is licensed under MIT license
  This example code is in public domain.


  This example shows how to use ESP8266 Shield (with AT commands)
  to connect your project to Blynk.

    It's very tricky to get it working. Please read this article:

  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1

// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(10, 11); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

// LED
#define LED 13
  Serial.println("App connected");

  Serial.println("App disconnected");

void setup()
  // Debug console

  // Set ESP8266 baud rate

  Blynk.begin(auth, wifi, ssid, pass);

void loop()

I am sure that I have turned on the settings " Notify devices when app connected" in my Blynk project. But these functions don’t work at all when I open/close the app.
Could anyone please help me on this issue ?

I suspect the NodeJS library just simply doesn’t have support for those commands. It seems more like a semi-official library by one of the developers that gets worked on in spare time.

Hello Gunner,

It’s ok if it doesn’t work on NodeJS. However, have you ever tried it on Arduino ? I tried it on the Arduino + ESP8266 setup I stated earlier, but it didn’t work.

These DO work with C++ code.

But you must have the switch turned on in the App.

And remember, they are activated when the APP is on (as in running on the phone or not) not the individual project.

It certainly works on a Wemos D1 Mini programmed in C++, provided you enable the “Notify devices when app connected” switch for your project (if you have multiple projects then it needs to be enabled for the project that contains a device with the Auth code that you’re using in your sketch).

Tested using:
iOS 2.25.0 (3) and 2.26.0 (7) - Beta
Blynk Cloud server
Blynk library 0.6.1

If you have multiple devices signed-in to your account then you get a notification when the app is closed on any device.
So if you have two devices and close the app on device 1 then device 2, you’ll get two “App Disconnected” notifications one after another. Re-launching the app on one device will give you an “App Connected” message, but you aren’t able to distinguish which device has connected.


I am also looking for such a function in the blynk node.js library to return the status of the blynk connection to the cloud. How can we have the functionality of the Arduino’s “Blynk.connected()” function in the node.js library?

Will we ever get an “official” version of the library for node.js, especially the inclusion of the “Blynk.connected()” function?

Although it’s not exactly the same, you could use blynk.on(‘connect’…) and ‘disconnect’ to set a Boolean variable that works in the same way as Blynk.connected

blynk.on('connect', function() {
  // set your variable to true in here


Pete, you are right and I’ve done that as well. However, from my tests, it seems that the system (blynk?) takes some time, ~10 minutes before the disconnect function was called i.e. it was not triggered immediately when there was a break in the connection to the blynk cloud server.