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)

Connecting Raspberry Pi with Blynk Cloud

After completing the building process, you can run the sample C++ code to connect your Raspberry Pi with the Blynk Cloud through Wi-Fi:

  1. Run the default source code file, which is main.cpp, with the following command:
pi@raspberrypi:~/blynk-library/linux $sudo ./blynk --token=da999e8ef4ac42148f9f e8427d482451
  1. When you run the command sudo ./blynk --token=da999e8ef4ac42148f9fe8427d482451, the main.cpp file residing in the blynk-library/linux directory gets executed. The sample code only connects to the Blynk server at The output should look something like this:
Output for default file main.cpp
  1. You can find the sample code for main.cpp in the blynk-library/linux directory. You can read the content of the file with the following command:
pi@raspberrypi:~/blynk-library/linux $ cat main.cpp
  1. The output should look something similar to what is on this link:
  2. Go through the code and see whether you can understand the key functions. Don't worry, you will learn how to write C++ code for the Blynk application in Chapter 3, Using Controller Widgets.
  3. Now exit from the nano editor by pressing Ctrl + X with your keyboard. The editor will prompt you asking if you want to save the file; type Y in response.