Enter the IoT world now! - Getting started with Blynk

Enter the IoT world now! - Getting started with Blynk © GPL3+

Control and monitor your Arduino porject using your only a smartphone and an internet connection!

  • 10,708 views
  • 4 comments
  • 45 respects

Components and supplies

Apps and online services

About this project

Why do you Need Blynk?

This article requires no experience with web programming and very basic knowledge about Arduino.

Have you ever thought of making a device send notifications to your phone and didn't know how to start implementing it?

Have you ever thought that you wanted to control anything over the internet and break the boundaries of RF and WiFi ranges?

You came to the right place!

In this article we'll explore how to use Blynk and use it to blink an LED on Arduino.

 What is Blynk?

Blynk which was awarded the IoT Software People's Choice 2015/2016 is a Platform with iOS and Android apps to control Arduino, Raspberry Pi, Particle and other devices using the internet. It's based on an Application that lets you drag and drop widgets to make your project grow larger and control more things.

Components

  • Arduino Uno
  • Smart phone with Android or iOs
  • Breadboard
  • Wires
  • IDE - Visual Studio ( I prefer to use it as it saves lots of time, if you're interested to know how to use Visual Studio to make Arduino sketches check this link, It's completely OK to use Arduino IDE)

Installing the Application

To download the application you can either go here if you're running Android or here if you're running iOS.

Setting Up Blynk Project

Then you register and create a new project.

When you're about to create the project you get the access token keep it in some place because you'll need this to connect to the internet later on. You can also click on Email and get the token send to your mail to easily use it.

Now you'll have your project and its empty work space, swipe to the right to see the available components to use.

We'll use the button so, add one and on the settings window you choose the button's name ,the pin it controls on the Arduino and its type and also its display color. Set the pin to D13 so we don't need to connect a circuit. I picked switch but you're free to choose whatever you want.

So our final project shall be like this :)

Setting Up Arduino

Adding the library

After downloading the library from this link, add it to Arduino by copying it to the libraries directory in the Arduino directory it's typically in.

C:\Program Files (x86)\Arduino\libraries

Extract the ZIP file in that directory.


The Code

We're almost done, we just need to tell Arduino that it'll connect to our application using Blynk, they made it really so simple to do. (Full sample will be below).

First, We'll setup a software serial so the PC communicates with the Arduino.

Then you modify the sketch with the Token that was generated for your project, you must edit this.

Then, in Setup() you begin the authorization with the Blynk platform.


Connecting Arduino to the internet

After  uploading the code to Arduino, you need to connect it to the internet. to do so you should run the script blynk-ser.bat that's provided with the Blynk library in.

\Blynk\scripts


Make sure that your firewall allows the script to connect to the internet.

A running script will look like this.

To terminate the script hit Ctrl + C then Y then press Enter.

Let's Roll

To run everything, do the following steps in order.

  • Make sure you have an internet connection.
  • Make sure that your application is ready with the correct pin numbers.
  • Make sure that the Arduino code is uploaded.
  • Make sure that the script is running correctly ( and not reconnecting ).
  • Run the application from your phone using this button.


Congratulations !! now you can switch the LED on and off from anywhere in the world!

Common Problems

Serial port doesn't show up should show up when you run the script if you see something like this, try to re-connect your Arduino. and make sure that nothing is making the port busy ( e.g: code is uploading ).



Your Arduino is not on network

if you see something like this, make sure that the Authorization Token is correct in your code and matches the one in the application, and make sure the firewall isn't blocking the Arduino from connecting to the internet.

To know more check the documentation of Blynk here, they have a very neat one.

Linux, RPi, Particle and Ethernet shields users should follow the instructions as the documentation here.

If you didn't find a solution you can head to the Blynk community and ask for help.

Thank You

I hope this article was useful, thank you for taking time to read this article, if you find it useful please Share it :)



Code

Getting Started With BlynkArduino
This is the full Arduino code to get you started, from Blynk makers
/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social groups:              http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * This example shows how to use ordinary Arduino Serial
 * to connect your project to Blynk.
 * Feel free to apply it to any other example. It's simple!
 *
 * 1. Optional, but recommended.
 *    Connect additional USB-serial adapter to see the prints.
 *
 * 2. Edit auth token and upload this sketch.
 *
 * 3. Run the script (script located in "scripts" folder of library root,
 *    e.g. 'blynk-library/scripts') for redirecting traffic to server:
 *
 *      for Windows:         scripts/blynk-ser.bat
 *      for Linux and OSX:   ./scripts/blynk-ser.sh (may need to run with sudo)
 *
 *    You can specify port, baud rate, and server endpoint like this:
 *      ./blynk-ser.sh -c <serial port> -b <baud rate> -s <server address> -p <server port>
 *
 *    For instance :
 *      ./blynk-ser.sh -c /dev/ttyACM0 -b 9600 -s cloud.blynk.cc -p 8442
 *
 *    Run blynk-ser.sh -h for more information
 *
 *    Be sure to select the right serial port (there may be multiple).
 *
 *    Attention!
 *        Arduino IDE may complain with "programmer is not responding".
 *        You need to terminate script before uploading new sketch.
 *
 * 4. Start blynking! :)
 *
 **************************************************************/

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11);
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

void setup()
{
  SwSerial.begin(9600);
  Blynk.begin(auth);
  // Default baud rate is 9600. You could specify it like this:
  //Blynk.begin(auth, 57600);
}

void loop()
{
  Blynk.run();
}

Comments

Similar projects you might like

Room temperature sensor with display on Mobile

Project showcase by Kaustubh Agarwal

  • 23,926 views
  • 8 comments
  • 54 respects

Introduction to the Blynk IoT service

by Rafa Juárez

  • 2,355 views
  • 1 comment
  • 9 respects

IoT Blink - Getting started with IoT

Project showcase by AppShed Support

  • 2,027 views
  • 0 comments
  • 11 respects

Connect to Blynk using ESP8266 as Arduino Uno wifi shield

Project tutorial by Nolan Mathews

  • 71,137 views
  • 11 comments
  • 50 respects

Arduino and AC Devices - Automatic Lights

Project tutorial by Ahmed Hamdy

  • 21,948 views
  • 7 comments
  • 51 respects

OH HAI! on Windows 10 IoT Core

Project in progress by BuddyC

  • 12,530 views
  • 3 comments
  • 48 respects
Add projectSign up / Login