Blynk and Omega2 Love


And finally the Omega Onion2 is here, in the lab!
Do you know Onion Omega2? See the Omega official site!
Now I begin the experimentation of board. After the installation, and registration on onion cloud I try to connect the Onion2 for IoT use. The board have moore possibilities! One important step, for IoT, and for my projects, is the platform of control. For this project I use Blynk app.
Do you know Blynk App? See the official site!
Now you can register to blynk service, mount a led on Omega Onion2 and install the blynk library on Omega2.
A part of Omega Onion2 you must have a led and a resistor and a Blynk account.
Install Software and Library
For use Blynk app on Omega 2 we must install the Blynk library!
First of all, you must connect the Omega2 to your LAN and internet. Open a terminal on your mac OS or Linux system and type:
ssh root@omega-xxxx.local
You can use the default "onioneer" after type the password
If you have Windows system you must install putty, and use this like a terminal.
Now you can install Blynk library on Omega Onion:
Update the opkg package
opkg update
Install blynk library
opkg install blynk-library
Install onoff package for switch ON/OFF the led
opkg install onoff-node
Install nano for edit a text file
opkg install nano
Connect the Led


Now you can use a led. You can connect the led to the PIN number 11.
Use this pin because the pin number 11 is a free GPIO pin without I2C or SPI port.
Connect directly the anode led to the PIN number 11, and after putting a resistor on the led cathode, and the resistor to the Omega2 GND. In this mode, you allow passage of all the current through to the led, and use a resistor to avoid a short-circuit.
The Program

You can write the program by typing on terminal:
mkdir blynk
cd blynk
nano test.js
In the file called test.js you can write this.
var BlynkLib = require('/usr/bin/blynk-library'); var blank = new BlynkLib.Blynk('TOKEN'); var Gpio = require('/usr/bin/onoff-node/onoff.js').Gpio; var led = new Gpio(11,'out'); var num = 1; var v1 = new blynk.Virtual.Pin(1); var v5 = new blynk.VirtualPin(5); v1.on('write', function(param) { console.log('V1:', param); }); v5.on('write', function(param) { this.num ^=1; led.writeSync(this.num); });
Where you see TOKEN, you must type the Blynk Token. For obtain a blynk token id, you can use your Blynk app, and obtain a new token id.
node test.js
Open Blynk app and make a Dashboard with two button. The buttons are the virtual pin.
If you push virtual PIN number 1 you can see your terminal V1: on or off.
If you push PIN number 2 you can see your led on or off.