skip to Main Content
Blynk + Omega =

Blynk + Omega = <3

The second part of this week’s 2-Bullet Tuesday! See the first part here. You can subscribe to the newsletter on the 2-Bullet Tuesday page!

Omega Tip

Using the Blynk App to Control the Omega 

This week we’ll show you how to use the Blynk app on your smartphone to create a dashboard to control the Omega! We’ll show you how to get everything setup so that a button press on your phone creates text output on the Omega. You can take it from there and build awesome, mobile-controlled Omega projects!

First start by going to your phone’s app store and downloading the Blynk app, then create a new account. Then create a new project and select the Onion Omega as the device.

Now that the project is setup, let’s add a Button widget. You can choose to name it whatever you like but set the pin to V1 (Virtual Pin 1).

Let’s switch over to the Omega; we’ll first need install NodeJS and the Blynk library. Take care as the commands that need to be run depend on your firmware version!

If you’re running firmware v0.3.0 and higher, run the following commands to install NodeJS v8.10 and the Blynk library:

opkg update
opkg install node-npm
npm install -g blynk-library

Be patient as npm takes a bit of time to get going

 

If your running firmware older than v0.3.0, we encourage you to update your Omega so you can benefit from all of the improvements that have been made.

If you want to stick with the old firmware, you can run the following command to install NodeJS v4.3.1 and the Blynk library:

opkg update
opkg install blynk-library

 


Then, create a text file called test.js to hold the code that will interact with Blynk:

var BlynkLib = require('/usr/bin/blynk-library');
 
var blynk = new BlynkLib.Blynk('YOUR AUTH TOKEN HERE'); // !!!
var v1 = new blynk.VirtualPin(1);
 
v1.on('write', function(param) {
  console.log('Hi! Pin V1 is: ', param);
});

This code first authenticates with Blynk and then sets up a Virtual Pin, complete with a routine to run when the virtual pin is toggled on the dashboard. In our case, a change on the virtual pin will result in a small message indicating the value of the button being printed.

You should have received an email from Blynk containing the Auth Token for your new project. In case you didn’t, we’ll go back to the Blynk app to find it. Click the small gear icon to access the project settings and you’ll find the Auth Token.

Then exit the project settings and then tap the play button (next to the gear icon) to activate your dashboard.

In the code on your Omega, replace YOUR AUTH TOKEN HERE! with your actual auth token. Then run node test.js. Your Omega should output something like the following:

root@Omega-F04F:~# node test.js
Connecting to: blynk-cloud.com 8441
SSL authorization...
Connected
Authorized

Now try pressing and holding the button on the Blynk app, you should see:

Hi! Pin V1 is:  [ '0' ]

When you let go, you’ll see:

Hi! Pin V1 is:  [ '0' ]

Wasn’t it easy to control your Omega with your smartphone? Take a peek at Blynk’s documentation, our Blynk library article and get cracking making awesome dashboards and projects! We can’t wait to see them!

Thanks for reading! Have a great week!

Let us know what kind of stuff you would like to see featured on 2-Bullet Tuesday! Send a tweet to @OnionIoT with your suggestions!

P.S. Get free shipping on all Onion Store orders over $75 that include a Dock, Expansion, or a Kit!

P.P.S. Don’t forget! If your project is featured on 2-Bullet Tuesday, you will receive an Omega2+, a Dock of your choice, AND free shipping!

Back To Top