Software Overview  |  Sitemap  |  Downloads  |  Developers  |  Forums
Small_clear_logo_llc

Blynk

Are you looking for a smartphone application for monitoring and controlling your Virtual Wiring system? Want to control a whole bunch of new hardware devices directly from your phone? Blynk Devices may be just what you need.

Blynk is a company which makes a smartphone application for controlling devices. The application is unique, because it provides a drag and drop interface for creating your own control interface for controlling and monitoring just about anything. Using just your cell phone, you can create an interface with buttons, sliders, lights, graphs, displays, and gauges. Then you can view your interface on your phone and use it to control and monitor devices.

A Custom Blynk Interface for Controlling and Monitoring a Home
Blynk Interface for Controlling a Home

As an added bonus, Blynk provides native code for a large number of popular devices, so you have lots of choices of what you want to control and monitor - Arduinos, Raspberry Pis, and the Sparkfun Blynk Board are some examples.

Integrated into the Virtual Wiring system are Blynk Hardware and Bridge Devices. These allow you to control and monitor your Virtual Wiring system using Blynk, and they allow the Virtual Wiring system control other Blynk devices.

Getting Started

The Blynk Application

The Blynk application is a cell phone application which lets you control and monitor hardware devices. Go to the Blynk site and read about Blynk. There, they will tell you how to download and install Blynk on your cell phone. They will also give you a "token". The token is a magic cookie which will let your phone and Virtutal Wiring work within the Blynk system.

Once you have your token, design yourself an interface using the Blynk application (for tips, see the instructions on the Blynk website). To get started, try adding one or two of their "widgets" (try a button and an LED). For each widget you add, you will need to define their "pins" (D0, A0, V0, ...). Remember the pins you have chosen, because later, you'll see that these pins will become the names you give to your Virtual Wiring Blynk Device Terminals. When defining your pins, follow the Blynk conventions (D0 is a digital pin, A0 is an analog pin, ...). For now, don't worry about connecting the widgets to any "real" devices - we'll do that in the next section.

Virtual Wiring Blynk Devices

Once you've set up your Blynk application with a widget or two, you define a Virtual Wiring Blynk Hardware Device. Here's how you do it.

From the Scripts Page, use the View Filter to select "Blynk". You will see a small number of Scripts. Click on the Run action of the Hardware Script - we are going to create a Blynk Hardware Device. You will see a dialog box with a bunch of parameters.

You can change any of these parameters, but for now, we will modify just three of them. First, call your Device by an appropriate name - we do that by defining its "id" parameter. We'll call our Device "blynk_interface" (quoted). Next, define your Terminals using the PIN names you used when defining your Blynk widgets. For example, if your widgets used pins A0, D0, V0, and V1, the "terminal_names" parameter would be "A0, D0, V0, V1" (quoted). Lastly enter your Blynk token as the "token" parameter, enclosing it in double quotes as you did for the id and terminal_names parameters. Press the Submit button to create your Blynk Hardware Device.

Blynk Hardware Device Script with Parameters
Blynk Hardware Dialog

Testing Things Out

Once you have the Blynk application running on your smartphone and Virtual Wiring running the Blynk Hardware Device, there are some easy tests you can do.

First, go to the Virtual Wiring Device Explorer page. You'll see a Device with the ID you created (ours was "blynk_interface") and the Terminals you gave it ("A0, D0, V0, V1" or whatever pins your widgets used). If you've got a button widget, try pressing it on your smartphone. Refresh your Device Explorer page - see the value change? Every time you press a button, it will update the corresponding Terminal in your Virtual Wiring system!

Now try the other direction. If you have a LED or display widget in your Blynk application, we'll try assigning it a value. Start by clicking on the Terminal within the Device Explorer page that corresponds to a Blynk display or light widget. While watching the Blynk application on your smartphone, assign an "on" value (unquoted) to your Terminal. If nothing seems to happen, try a number value. See how that works? Values assigned to Blynk Hardware Device Terminals show up on the corresponding widget within the Blynk application!

Wiring Things Up

Now that we have a Blynk Hardware Device working with the Blynk application, we can connect whatever we wish to Blynk by Wiring Virtual Wiring Devices to the Blynk Hardware Device. Want to monitor a value in the Virtual Wiring System with Blynk? Draw a wire from the appropriate Terminal in your Virtual Wiring system to a Blynk display widget's Terminal on your Blynk Hardware Device. Want to control something in the Virtual Wiring System? Draw a wire from a Blynk actuator widget's Terminal (a switch, a button, ...) to whatever Virtual Wiring Device Terminal you want to control!

An Example

If you want to see a working example of a Virtual Wiring system using Blynk, checkout our Blynk Home Automation project.

Blynk Device Descriptions

We've already talked a bit about the Blynk Hardware Device. Here is a complete description of all the Blynk Devices supported by the Virtual Wiring system.

Hardware Device

The Blynk Hardware Device creates a Virtual Wiring Device which notifies the Blynk server (and smartphone application) of changes in a Virtual Wiring system. It also notifies the Virtual Wiring application of changes made by the Blynk application. By default, the Hardware Device has no terminals - all its terminals are defined by the user.

Blynk Hardware Devices are created by running the Hardware Script. The parameters for the Hardware Script are:

  • terminal_names : a quoted, comma separated string of terminal names. These are the same names that Blynk uses as pin names (A0, D0, V0, etc.). These will become terminals on the Hardware Device.
  • token : the token string (quoted) for this Device (as supplied by Blynk)

The following parameters are optional - leaving them alone generally works and is advisable.

  • push_events : set this to true (the default) if you want Virtual Wiring to push Terminal events to the server and false if you want the server to poll Virtual Wiring. "true" generally works well.
  • host_name : the name of the Blynk server
  • port : the IP port of the Blynk server
  • ssl : set to true (the default) if you want to use SSL with the server, false otherwise

Running the Hardware Script with the parameters listed below creates a Blynk Hardware Device.

id: "blynk"
terminal_names : "A0, D0, V0"
token : "secret token supplied by Blynk"

The Blynk Hardware Device will have the ID "blynk" and "A0", "D0", and "V0" terminals. Whenever an event occurs at one the the Hardware Device's terminals, it will push the event to the Blynk server.

Bridge Device

The Blynk Bridge Device allows Virtual Wiring to control Blynk devices using a Blynk bridge. The Blynk devices are native Blynk devices running code supplied by Blynk or written to conform with the Blynk application interface. A Blynk Bridge Device can be used to control another Virtual Wiring system's Blynk Hardware Device. If you have two Virtual Wiring systems running on two isolated networks, you may be able to connect them using Blynk Bridge Devices. By default the Bridge Device has no terminals - all its terminals are defined by the user.

Blynk Bridge Devices are created by running the Bridge Script. The parameters for the Bridge Script are:

  • channel : the channel / virtual pin (V0, V1, ...) to use to talk to the other Blynk Device (quoted).
  • poll_interval : how often, in seconds, to poll the bridged Blynk device for changes. Leaving this value at nil will tell Virtual Wiring to never poll the bridged device.
  • terminal_names : a quoted, comma separated string of terminal names. These are the same names that bridged Blynk devices use as pin names (A0, D0, V0, etc.). These will become terminals on the Bridge Device.
  • token : the token string (quoted) for the Blynk bridge device (as supplied by Blynk)

The following parameters are optional - leaving them alone generally works and is advisable.

  • hardware_token : the token string (quoted) of the Blynk hardware device we are bridging from. If there is only one Blynk hardware device in the Virtual Wiring system, leaving this value at nil is fine.

Running the Bridge Script with the parameters listed below creates a Blynk Bridge Device.

id: "blynk_bridge"
channel : "V31"
terminal_names : "A0, D0, V0"
token : "secret token supplied by Blynk"

The Blynk Bridge Device will have the ID "blynk_bridge" and "A0", "D0", and "V0" terminals. Whenever an event occurs at one the Bridge Device's terminals, it will use the V31 channel of Virtual Wiring's Blynk Hardware Device to push the event to the Blynk server, notifying the bridged Blynk device of the changes. Other values on the bridged device's terminals will not be shown on the Bridge Device terminals, since poll_interval is set to its default (nil) value.

Catalina Computing, LLC.

Copyright © Catalina Computing, LLC. (2013-2017)




Page last updated: Fri Dec 23 03:01:39 2016 (UTC)