BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Particle Photon showing offline using new Blynk

I’ve been using the older Blynk for sometime, wanted to try the new version but am stumbling at the first stage of actually getting the device to show “Online”

To debug, I created a new Project in build.particle.io with the following code and added the blynk 1.0.0 library;

#define BLYNK_PRINT Serial // Defines the object that is used for printing
#define BLYNK_DEBUG        // Optional, this enables more detailed prints
#include <blynk.h>
#define BLYNK_TEMPLATE_ID "myID"
#define BLYNK_DEVICE_NAME "myDEVICE"

//char auth[] = "myAUTH1"; // BLNK 0.6.4
char auth[] = "myAUTH2";  // BKNK 2.0

//WidgetLED GarageLED(V15);

void setup()
{
    Serial.begin();   
    WiFi.clearCredentials();
    WiFi.setCredentials("mySSID", "myPASS");
    delay(2000); // Allow board to settle
    Blynk.begin(auth);
}

void loop()
{
  Blynk.run();
  
//  GarageLED.on();
  Serial.printlnf("led_ON");
  delay(2000);
//  GarageLED.off();
  Serial.printlnf("led_OFF");
  delay(2000);
}

I created a Template in the iOS Blynk app, and a device using the Blynk.Console webpage. Flashed the Photon with all the correct “myXXX” credentials, but it always shows as ‘Offline’ both in the iOS app and on the above webpage.

If I switch to my old auth code (for Blnk 0.6.4) the Photon connects okay. What am I missing? Is blynk 1.0.0 the correct library?

@Tinker please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

To futher debug, I’ve changed the code to the above, when looking at serial output for AUTH1 it shows:

   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.0 on Particle Photon

[12526] Connecting to blynk-cloud.com:80
[12580] <[1D|00|01|00] [myAUTH1]
[12611] >[00|00|01|00|C8]
[12611] Ready (ping: 30ms).

If I then switch out to AUTH2 i.e. the AUTH code copied from Blynk Console / AUTH TOKEN, I get this message

[12521]
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v1.0.0 on Particle Photon

[12522] Connecting to blynk-cloud.com:80
[12575] <[1D|00|01|00] [myAUTH2 here]
[12856] >[00|00|01|00|09]
[12856] Invalid auth token

I read somewhere that v2.0 should be connecting to blynk.cloud not as above, how do I proceed from here? - I’ve tried deleting the device (twice) and copying the new AUTH codes but get the same problem. If the library should be connecting to blynk.cloud for v2.0 does it need to be specified somewhere?

This is the Blynk 1.0.0 library used in the Particle IDE

Okay, after scanning through the library code, figured out that it looks at blynk.cloud if it finds #define BLYNK_TEMPLATE_ID in the code. I therefore rearranged the order so that is higher up [as below] and it now connects to blynk.cloud and shows online! :slight_smile:

#define BLYNK_PRINT Serial // Defines the object that is used for printing
#define BLYNK_DEBUG        // Optional, this enables more detailed prints
#define BLYNK_TEMPLATE_ID "myID"
#define BLYNK_DEVICE_NAME "myNAME"

// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>

Hopefully this may help others having the same issue!? - Now my Pro trial has expired before I even managed to get online! :frowning: Any chance of another @Pavel for finding a bug? :slight_smile: :grinning:

1 Like

This helped me big time, thank you for posting the solution!

1 Like

@Tinker Thanks this really helped me! I have Particle Argon and Boron devices and was really struggling with the new Blynk 2.0. It really helped clear up some mass confusion I had as well. Once I realized that the Legacy and the New Blynk both use the same exact library. Only a line of code determines which system it is using. I was having a hard time wrapping my head around how to get Blynk.Edgent to work with Particle Cloud and the way the Particle devices are provisioned via their own app. The simple fix - you don’t use Blynk.Edgent with these devices being they have their own cloud system for provisioning and OTA updates.

Now I also understand how the new Blynk 2.0 can still easily work with just about every board the old Blynk did. Fantastic! Kudos to you! :wink:

@PeteKnight @vshymanskyy Thanks to @Tinker post with the similar problem I have it all figured out now. Switching to the new Blynk from the old is going to be easy now… and I paid for the year of the plus plan. :slight_smile: :+1:

2 Likes

not working for me unfortunately. Even having made the change to the code as suggested, I still get:

[744688] Connecting to blynk-cloud.com:80
[745180] <[02|00|01|00] ************************Jz_YHVzJ9B6
[745672] >[00|00|01|00|09]
[745673] Invalid auth token

@tpstech please post your full sketch, correctly formatted with triple backticks at the beginning and end.
Triple backticks look like this:
```

Pete.

#define BLYNK_PRINT Serial  // Set serial output for debug prints
// set Template ID and Device Name for Blynk 2.0
#define BLYNK_TEMPLATE_ID "***********"
#define BLYNK_DEVICE_NAME "BoronLumina"
#define BLYNK_DEBUG       // Uncomment this to see detailed prints
#define BLYNK_HEARTBEAT 300
#define PARTICLE_KEEPALIVE 120
#include <blynk.h>

char auth[] = "**********************";

BLYNK_WRITE(V1)
{
    if (param.asInt() == 1){
        digitalWrite(A0,HIGH);
        delay(50);
        digitalWrite(A0, LOW);
        digitalWrite(7, HIGH);
        digitalWrite(A2, HIGH);
    }
    else{
        digitalWrite(A0,LOW);
        digitalWrite(A2, HIGH);
        digitalWrite(7, LOW);
        delay(50);
        digitalWrite(A2, LOW);
        digitalWrite(7,HIGH);
        delay(100);
        digitalWrite(7,LOW);
        delay(100);
        digitalWrite(7,HIGH);
        delay(100);
        digitalWrite(7,LOW);
    } 
    
}

BLYNK_WRITE(V2)
{
    bool pinState = digitalRead(7);
    if (!pinState){
        if (param.asInt() == 1){
            digitalWrite(A0,HIGH);
            delay (50);
            digitalWrite(A0, LOW);
            delay (500);
            digitalWrite(A2, HIGH);
            delay(50);
            digitalWrite(A2, LOW);
        }
        digitalWrite(A0,LOW);
        digitalWrite(A2, LOW);
    }
}


void setup()
{
  // Debug console
  Serial.begin(9600);

  delay(5000); // Allow board to settle
  pinMode (7,OUTPUT);
  pinMode (A0, OUTPUT);
  pinMode (A2, OUTPUT);
  digitalWrite (7, LOW);
  digitalWrite (A0, LOW);
  digitalWrite (A2, LOW);
  Blynk.begin(auth);
}

void loop()
{
  Blynk.run();
}

What Blynk library version are you using?

Pete.

0.5.4. I didn’t consider that. I’ve just updated it to 1.0.0 but it still gives me the same result.

The latest version is 1.0.1

I have no experience (and therefore no interest) in the Particle boards, and this means I don’t pay much attention to Particle related issues.
But, I think you need to define your WiFi credentials in the sketch…

Pete.

If using build.particle IDE, check it hasn’t added the #include <blynk.h> line again at the top of your code after updating the library! (That has to be AFTER the TEMPLATE_ID and DEVICE lines for it to pick up the correct cloud)

Directly from the docs and release notes:

@vshymanskyy Its good to see the docs have been updated to make it clearer, however, as Particle automatically adds the #include <blynk.h> to the very top of the code, it’s VERY easy to get this problem, even if you read the docs originally.

To prevent it happening, I would highly recommend the library be modified to allow for the template ID lines to be located after the blynk.h line!

This is impossible, unfortunately. We will modify Particle examples so it’s even more clear.

Okay I decided to give it another crack this morning and found that although I don’t have a #include <blynk.h> at the top of my sketch, by moving the #define BLYNK_TEMPLATE_ID line to the very top (above the #define BLYNK_PRINT Serial I got it to work. Thanks chaps. Now to understand how to set it up and use in Blynk 2.0 :laughing: