Book Image

Hands-On Internet of Things with Blynk

By : Pradeeka Seneviratne
Book Image

Hands-On Internet of Things with Blynk

By: Pradeeka Seneviratne

Overview of this book

Blynk, known as the most user-friendly IoT platform, provides a way to build mobile applications in minutes. With the Blynk drag-n-drop mobile app builder, anyone can build amazing IoT applications with minimal resources and effort, on hardware ranging from prototyping platforms such as Arduino and Raspberry Pi 3 to industrial-grade ESP8266, Intel, Sierra Wireless, Particle, Texas Instruments, and a few others. This book uses Raspberry Pi as the main hardware platform and C/C++ to write sketches to build projects. The first part of this book shows how to set up a development environment with various hardware combinations and required software. Then you will build your first IoT application with Blynk using various hardware combinations and connectivity types such as Ethernet and Wi-Fi. Then you'll use and configure various widgets (control, display, notification, interface, time input, and some advanced widgets) with Blynk App Builder to build applications. Towards the end, you will learn how to connect with and use built-in sensors on Android and iOS mobile devices. Finally you will learn how to build a robot that can be controlled with a Blynk app through the Blynk cloud and personal server. By the end of this book, you will have hands-on experience building IoT applications using Blynk.
Table of Contents (10 chapters)

The Blynk app builder

The Blynk app builder provides an easy way to build IoT apps that can be run on smartphones and tablets. It provides a predefined set of draggable and droppable modules known as widgets, and allows the users to make further configuration on widgets with an easy-to-use user interface. Using the app builder, you can build apps for your personal use or business purposes, as shown in the following screenshot.

If you want to build an app with Blynk for business purposes, visit http://www.blynk.io/business/ for more information:

Blynk widget Box

Installing the Blynk app builder

The Blynk app builder is currently available for Android and iOS platforms. The following steps explain how to install the Blynk app builder on your Android smartphone or tablet:

  1. Tap the apps icon in the lower-right corner of the home screen (consider that this is the default location).
  2. Swipe left and right until you find the Play Store icon.
  3. Tap the Play Store icon.
  4. The first time you open the Play Store, you may be prompted to sign in with your Google credentials. If you still don't have a Google account, you can create a free account with Google.
  5. Once you sign in with Google Play Store, you can search for a specific app.
  6. Tap the magnifying glass in the upper-right corner, type in the name blynk, and tap the magnifying glass on the keyboard to execute the search. You will get a result on the screen as follows:
Search results for Blynk
  1. Tap INSTALL to start the installation process. Also, you can find more information about the app by tapping the MORE INFO button:
Installing Blynk app
  1. Tap ACCEPT to allow the Blynk app to access some resources on your mobile device:
Permitting access to resources in your mobile device
  1. The installation process will take some time depending on the bandwidth of your internet connection.
  2. After completing the installation, you can open the Blynk app by tapping on the OPEN button with Google Play. This will help you to open the Blynk app builder for the first time without moving to the home screen of your smartphone or tablet:
Once installed, opening Blynk app builder from Google Play
  1. After installation, an application icon associated with the Blynk app builder can be found on the home screen of your smartphone or tablet:
Opening Blynk app builder from Android home screen

Creating a Blynk account

Before you start to create applications with the Blynk app builder, you should create a user account with Blynk Cloud. The following steps will guide you through how to do that:

  1. Open the Blynk app builder on your mobile device by tapping on the application icon labeled Blynk.
  2. Tap Create New Account.
  3. Alternatively, you can log into the Blynk app builder with your Facebook account by tapping on the Log In with Facebook button:
Creating new account—step 1
  1. On the Create New Account page, type your email address for the username, and a password.
  2. Then, tap the Sign Up button:
Creating new account—step 2
  1. A user account will be created, and you will automatically be logged in to the Blynk app builder (Blynk Cloud).
  2. First, you will be notified on how energy works. Tap on the Cool! Got it. button:
Notification about how energy works
Each widget needs energy to operate. When you delete a widget, energy is returned.
  1. At any time, you can log out from the app builder by tapping the log out icon in the toolbar. When prompted, tap LOG OUT, or tap CANCEL if you want to stay logged in.
At the time of writing, Blynk doesn't send any email message to your email account confirming the creation of the new user account.
  1. When you log into the Blynk app builder again, type in your email address associated with the Blynk account and the password, then tap Log In.
  2. You can reset your password by tapping Reset Password at any time.

Creating a new project

Now that you have created a new account with Blynk Cloud and logged in to your Blynk app builder running on your smartphone or tablet, you can follow the following steps to create a new project with the Blynk app builder:

  1. To start building a project, tap New Project. This will bring you to the create New Project wizard:
Creating a new project
  1. Type in demo in the Project Name textbox:
Creating new project—project name
  1. Tap the CHOOSE DEVICE dropdown box to see the available hardware models (the default is ESP8266). Then, tap Raspberry Pi3 B from the Select your hardware list. You may find other versions of the Raspberry Pi as well. Following are the available options for Raspberry Pi versions:
    • Raspberry Pi 2/A+/B+
    • Raspberry Pi 3 B
    • Raspberry Pi A/B (Rev2)
    • Raspberry Pi B (Rev 1)
  2. After choosing the hardware model, tap OK:
Creating new project—Selecting hardware
  1. Tap on the CONNECTION TYPE dropdown list to see the available connection types. Then select WiFi from the CONNECTION TYPE list, followed by OK.
  2. Tap the Create button to create the project workspace:
Creating new project
  1. After successfully creating the project, the app builder will send an auth
    token to confirm your project
    . Every new project you create will have its
    own auth token. The auth token is a unique identifier that consists of alphanumeric characters, and authorizes you to access the Blynk Cloud,
    located at https://www.blynk.cc/:
Notification about the auth token
  1. At the same time, you'll have an auth token automatically sent to the email address you provided.
If you have lost your auth token, you can still find it with your project in Project Settings (the nut icon).
  1. Tap the nut icon in the toolbar to get to the Project Settings page. Then, scroll down to find the DEVICES section. Tap demo Raspberry Pi 3 B (WiFi).
  2. Alternatively, you can tap Email all under AUTH TOKENS to get all the Auth tokens on your email provided for each project in your Blynk account. You can also tap Copy all to copy all the Auth tokens to your mobile device's clipboard:
Finding Auth token—step 10
  1. On the My Devices page, tap demo Raspberry Pi 3 B(WiFi) under My Devices:
My Devices page
  1. You can find the Auth token under the AUTH TOKEN section, but it only shows the last four alphanumeric characters. You can tap the E-mail button to send it to the email account again:
Finding Auth token—step 12

You will learn how to use the Auth token with your C++ code later in this chapter.