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)

Getting parts

Blynk supports over 400 hardware platforms and major connectivity types such as Ethernet, Wi-Fi, Bluetooth, Bluetooth Low Energy, and USB; however, it is very difficult to explain how to build devices for Blynk using all the supporting hardware platforms in a single book. Therefore, this book will be using Raspberry Pi as the hardware platform to demonstrate the ability and power of Blynk.

Raspberry Pi

Raspberry Pi is a small, programmable device. It is a mixture between a very small computer and a programmable embedded board. You can connect the Raspberry Pi to the internet through Wi-Fi or Ethernet. You will be using Raspberry Pi 3, the latest model of the Raspberry Pi family, as the hardware platform; however, you can use other versions of Raspberry Pi, such as Raspberry Pi 2/A+/B+ and Raspberry Pi A/B (revision 2) to work with projects that we will be discussing throughout the book.

The sample code provided with this book is not tested with Raspberry Pi Zero W or Raspberry Pi Zero.

Here is a list of the Raspberry Pi boards available in reverse chronological order:

  • Raspberry Pi 3 Model B (third-generation single-board computer)
  • Raspberry Pi 2 Model B (the Raspberry Pi 2 Model B is the second-generation Raspberry Pi)
  • Raspberry Pi 1 Model B+ (the model B+ is the final revision of the original Raspberry Pi)
  • Raspberry Pi 1 Model A+ (the model A+ is the low-cost variant of Raspberry Pi)
  • Raspberry Pi Zero W (single-board computer with wireless and Bluetooth connectivity)
  • Raspberry Pi Zero (lowest-cost single-board computer)
Raspberry Pi 3 Model B, which is one of the latest models of the Raspberry Pi family, can be found here along with the other models:

Refer to the following screenshot:

Raspberry Pi 3 Model B, a single-board computer with wireless LAN and Bluetooth connectivity

Following is the list of important specifications of Raspberry Pi Model 3:

  • Quad Core 1.2 GHz Broadcom BCM2837 64-bit CPU
  • 1 GB RAM
  • BCM43438 wireless LAN and Bluetooth Low Energy (BLE) on board
  • 40 extended GPIO pins
  • 4 USB 2 ports
  • 4 Pole stereo output and composite video port
  • Full-size HDMI
  • CSI camera port for connecting a Raspberry Pi camera
  • DSI display port for connecting a Raspberry Pi touchscreen display
  • Micro SD port for loading your operating system and storing data
  • Upgraded switched Micro USB power source up to 2.5 A

You will learn more technical details about Raspberry Pi in Chapter 2, Building Your First Blynk Application.

Raspberry Pi can be plugged in to a computer monitor or TV, and uses a standard keyboard and mouse. If you want, you can use the Raspberry Pi without attaching a monitor/TV, keyboard, or mouse.

You will need the following things to prepare your Raspberry Pi before installing Raspbian:

  • SD card: 8 GB class 4 SD card is recommended; however, you can use one with higher capacity like 16 GB, 32 GB, or 64 GB. But having a class 10 micro SD card in your Raspberry Pi is very much recommended. Don't use SD cards lower than class 4, because they provide very low writing speed. The following screenshot shows an 8 GB Kingston class 4 micro SD card. The SD card works as the hard drive of your Raspberry Pi:
Kingston 8 GB class 4 micro SD card
  • Power supply: Raspberry Pi is powered by a micro USB power supply. You'll need a good-quality power supply that can supply at least 2 A at 5V for the Raspberry Pi 3 Model B, or 700 mA at 5V for the earlier, lower-powered models. The following screenshot shows a micro USB power supply for Raspberry Pi:
A micro USB power supply for Raspberry Pi
  • A Wi-Fi dongle (required for earlier, lower-powered models): Allows you to connect your Raspberry Pi to a wireless network. The following screenshot shows the official and recommended universal USB Wi-Fi dongle for Raspberry Pi.
  • Ethernet (network) cable [Model B/B+/2/3 only]: An Ethernet cable is used to connect your Pi to a local network and the internet. The following screenshot shows an Ethernet cable:
SparkFunCAT 6 Cable—3ft (image is CC BY 2.0—

Setting up Raspberry Pi

Let's see how to set up Raspberry Pi:

  1. Place your SD card into the SD card slot on the Raspberry Pi. It will only fit one way
  2. Plug your keyboard and mouse in to the USB ports on the Raspberry Pi
  3. Connect your HDMI cable from your Raspberry Pi to your monitor or TV
  4. Connect a Wi-Fi dongle to one of the USB ports (unless you have a Raspberry Pi 3)
  5. The Raspberry Pi is powered by the micro USB power supply