And finally the Onion Omega2 is here in the lab! Now I begin experimentation of the board. After the installation and registration on the Onion Cloud, I tried to connect the Omega2 for IoT use. The board has more possibilities! One important step for IoT, and for my projects, is the platform of control. For this project I use the Blynk app.
Now you can register to Blynk service, mount an LED on the Onion Omega2 and install the Blynk library on Omega2.
A part from an Onion Omega2, you must have an LED, a resistor and a Blynk account.
Install the library on Omega2To use the Blynk app with Omega2, 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 a Windows system, you must install PuTTY and use this like a terminal. Now you can install the Blynk library onto the Onion Omega.
Update the opkg
package:
opkg update
opkg install blynk-library
opkg install onoff-node
opkg install nano
Connect the LEDNow you can use an LED. You can connect the LED to the PIN number 11.
Use this pin because pin number 11 is a free GPIO pin without I2C or SPI port.
Directly connect the anode LED to PIN number 11. After put a resistor on the LED cathode and a resistor for the Omega2 GND. With this arrangement, you allow passage of all the current through to the LED and use the resistor to avoid a short-circuit.
Write the programYou can write the program by typing into the terminal:
mkdir blynk
cd blynk
nano test.js
In the file test, you can write this. Write the token code in the file.
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 replace it with the Blynk Token. To obtain a Blynk token ID, use your Blynk app and obtain a new token ID.
After this, you can start the program. Type:
node test.js
TestOpen the Blynk app and make a Dashboard with two buttons. The buttons are the virtual pins.
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.
Comments