A question about Blynk with Particle

Hello,
According to Particle code sample

#define BLYNK_PRINT Serial  // Set serial output for debug prints
//#define BLYNK_DEBUG       // Uncomment this to see detailed prints

#include <blynk.h>

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

// Attach a Button widget (mode: Switch) to the Digital pin 7 - and control the built-in blue led.
// Attach a Graph widget to Analog pin 1
// Attach a Gauge widget to Analog pin 2

void setup()
{
    Serial.begin(9600);
    delay(5000); // Allow board to settle

    Blynk.begin(auth);
}

// Attach a Button widget (mode: Push) to the Virtual pin 1 - and send sweet tweets!
BLYNK_WRITE(V1) {
    if (param.asInt() == 1) { // On button down...
        // Tweeting!
        // Note:
        //   We allow 1 tweet per minute for now.
        //   Twitter doesn't allow identical subsequent messages.
        Blynk.tweet("My Particle project is tweeting using @blynk_app and it’s awesome!\n @Particle #IoT #blynk");

        // Pushing notification to the app!
        // Note:
        //   We allow 1 notification per minute for now.
        Blynk.notify("You pressed the button and I know it ;)");
    }
}

// Attach a ZeRGBa widget (mode: Merge) to the Virtual pin 2 - and control the built-in RGB led!
BLYNK_WRITE(V2) {
    int r = param[0].asInt();
    int g = param[1].asInt();
    int b = param[2].asInt();
    if (r > 0 || g > 0 || b > 0) {
        RGB.control(true);
        RGB.color(r, g, b);
    } else {
        RGB.control(false);
    }
}

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

Are these three lines necessary?

#define BLYNK_PRINT Serial  // Set serial output for debug prints
//#define BLYNK_DEBUG       // Uncomment this to see detailed prints
Serial.begin(9600);

I know they are for debugging. But if I don’t need them, are they necessary to make Particle work with Blynk? Thanks

They are not technically required for ESP’s so I’m guessing they are not required for Particle either.

Thanks @Costas but I’m working on remote device so I would appreciate if someone could confirm this before I submit the code. I suspect that this is a bottleneck in data transmission so I need to know if I can safely remove serial connection.

I have seen the #define BLYNK_PRINT Serial commented as /* Comment this out to disable prints and save space */ and once I am done testing, I always remove them. They have no effect on device operation and, without a serial connection, they do nothing but “take memory space”

In reference to Serial.begin(9600); This will be easy enough to determine… do you have ANY other references to Serial anywhere in your code? if not then it does nothing else.

PS, these are in ALL examples, not just Particle ones… probably because they are beneficial for new users to see the results without having to be edumacated into installing these commands.

1 Like