Blynk for Raspberry Pi

Lead Image © Dietmar Hoepfl, 123RF.com

In a Blynk of a Pi

Use your Android device to build graphical interfaces for interacting with Raspberry Pi.

Using an Android device or an iPad to control and interact with a Raspberry Pi sounds like a great idea, until you realize that turning it into reality is no trivial matter. One way to do this is to build a web app that runs on the Raspberry Pi and acts as an intermediary between the mobile device and the machine's hardware (e.g., GPIO pins). Although frameworks like Bottle for Python simplify the process of building web apps, they do require a working knowledge of Python. Besides being fluent in Python, you also need to spend time writing the actual app as well as testing and debugging it.

In short, if your Python skills are not (yet) up to scratch or you are not keen on spending hours writing and debugging code, building web apps from the ground up might not sound all that appealing. Meet Blynk [1], an easy-to-use platform that lets you whip up simple mobile interfaces for interacting with Raspberry Pi – no coding required.

How Blynk Works

Blynk consists of three components: the app, the server, and the library. The library runs on the Raspberry Pi (or on any supported board) and does all the behind-the-scene jobs of interfacing with the hardware. The app is the core component of the Blynk platform, and it provides an environment for building visual interfaces for controlling Raspberry Pi. The app offers a collection of widgets, such as button, sliders, LEDs, value displays, and the like. To create a graphical interface using the app, you simply add the desired widgets to a project and configure their settings.

The server component provides a link between the app and the Raspberry Pi running the library. By default, the platform uses the cloud service provided by the Blynk project. The server is released under an open source license, however, and you can easily deploy it on your own machine. In fact, you can even run both the server and the library on the same Raspberry Pi, although it might be prudent to use a dedicated machine or a virtual private server for that.

Preparatory Work

To make Blynk work, you need to install the required components. Start by installing the mobile app on your Android or iOS device from Google Play Store or Apple App Store. Next, you need to deploy the Blynk library on the Raspberry Pi. Use the commands below to update the software repositories and install Git:

sudo apt-get update
sudo apt-get install git-core

The Blynk library requires the wiringPi library, so you need to compile and install that first. To do this, clone the wiringPi Git repository:

git clone git://git.drogon.net/wiringPi

Switch to the resulting wiringPi directory and run the build script:

cd wiringPi
./build

To make sure the library has been installed, run the gpio -v command, which should return the version information. To compile the Blynk library, use the following commands:

git clone https://github.com/blynkkk/blynk-library.git
cd blynk-library/linux
make clean all target=raspberry

Although you can use the service provided by the Blynk project to link the Blynk app and the Raspberry Pi, you may also choose to run the server on your own machine. The only requirement is that this machine has Java installed on it. The Blynk Server GitHub repository contains .jar binaries, so deploying the server is a matter of downloading the latest version of the server-x.x.jar binary and running it on your machine using the java -jar server-x.x.jar command. This will run the server on the default port 8443, but you can use the -hardPort parameter to specify another port: java -jar server-x.x.jar -hardPort 8555.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content