Running my own script

I dont understand how I can run my own script. I am using an Raspberry Pi. I installed the Blynk library and I am able to run the app when I use the command ‘sudo ./blynk --token=MyAuthToken’, but where do I need to place my scripts.

For example this script:

You can view minimum sketch with command :

less /usr/local/bin/blynk-client

#!/usr/bin/env node

var Blynk = require("../");

if (!process.argv[2]) {
  console.log("Please specify auth token.");
  process.exit(1);
}

var blynk = new Blynk.Blynk(process.argv[2]);

blynk.on('connect', function() {
  console.log("Blynk ready.");
});

Now you have to write your own program and run it with

node full_path_to_your_script.js <Auth Token>

as stated here http://docs.blynk.cc/#hardware-set-ups-raspberry-pi

1 Like

Here is better example https://github.com/vshymanskyy/blynk-library-js

Thankyou for your reply.

But this is the way with node.js right? What if I want to use it with C++? I have installed the blynk library and WiringPi.

1 Like

I understand this and I am able to run my own scripts now in Javascript.

What I dont understand is that in the documentation, its explained how to install Blynk with Node.js, but the sketch examples are with C++. Can someone clarify this?

What is the difference? Do I have to make a choice to use javascript or C++ script or can I use both? How can I run my C++ scripts?

Blynk supports everything. And everything is python, c/c++, javascript, java, etc. It is up to you what to use.
We provide all basic examples with Arduino style (c++).

Have a look http://examples.blynk.cc/ for tool for creating default sketches.

1 Like

I still dont understand how I can use these C++ examples.
With javascript I run:
node sketch.js <auth-token>

How is this done with a c++ script and java?

You could just build an interface to the Web API’s Blynk is offering. That works really great from C++. You just have to do some web requests :slight_smile: