0% found this document useful (0 votes)
63 views20 pages

Blink App

This document describes how to control an Arduino board from a smartphone using the Blynk application over the internet. Key steps include installing the Blynk app, downloading the Blynk library onto a PC, connecting the Arduino board to the PC, uploading code to the Arduino that integrates with Blynk, and running the Blynk app to control pins on the Arduino board remotely. An example is provided where a button on the Blynk app is used to control an LED connected to pin D13 on the Arduino.

Uploaded by

Sugaina K.R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views20 pages

Blink App

This document describes how to control an Arduino board from a smartphone using the Blynk application over the internet. Key steps include installing the Blynk app, downloading the Blynk library onto a PC, connecting the Arduino board to the PC, uploading code to the Arduino that integrates with Blynk, and running the Blynk app to control pins on the Arduino board remotely. An example is provided where a button on the Blynk app is used to control an LED connected to pin D13 on the Arduino.

Uploaded by

Sugaina K.R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/310096021

Controlling Arduino board with smartphone and Blynk via internet

Research · November 2016


DOI: 10.13140/RG.2.2.23956.30080

CITATIONS READS
5 9,452

1 author:

M. Todica
Babeş-Bolyai University
104 PUBLICATIONS   488 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

IR and Raman Investigation of Some Poly(acrylic) Acid Gels in Aqueous and Neutralized State View project

Simple WI-FI remote car with smartphone and Blynk View project

All content following this page was uploaded by M. Todica on 13 November 2016.

The user has requested enhancement of the downloaded file.


Controlling Arduino board with smartphone and Blynk via internet
M. Todica

This is my first work concerning the use of Blynk application to control the Arduino
board. Blynk allow us to create applications and then use it to control Arduino board
connected to a PC with internet access, from any where in the world, (for instance,
control led, servos, receive data, etc), with a smartphone. It is one of the most interesting
actions! The connection can also be established by Bluetooth between smartphone and
Arduino board, but this will be not presented in this work.
Blynk can be download from Google play store (for Android).& app store (for apple),
providing us the dashboard as well as the connectivity to Arduino, (it is a virtual
connectivity). Programming Blynk is very simple, push and drag widgets form the tools
bar and allocating them pins on Arduino board. For such project can be used an ordinary
Arduino board, without internet shield, connected to a PC with internet access and a
smartphone. The role of PC is to ensure the connectivity of the Arduino board to the
internet and to upload the Arduino code. For this purpose it is necessarily to install Blynk
library on the PC and made some settings. The Arduino codes used for Blynk have the
same structure as ordinary codes, but contain specific parts to communicate with Android
devices. I will present a simples example, taken from internet, and partially modified by
me. You can see that creating new codes is almost similar with the coding of the ordinary
Arduino.

To create our first project we need to follows many steps.


1. Install Blynk app on your smartphone and create your simplest application, for
instance control one led.
2. Download blynk v0.3.1 library and install on your PC. Set the right port of the PC to
communicate with the Arduino board, (very important), from the script of the Blynk
library.
3. Upload the Arduino code, (from the examples presented in this work, or other).
4. Run the Blynk on the smartphone.

1. Download Blynk and install on the smartphone.


Create an account with your email and password. This e-mail will be used by Blynk
server to send your "YourAuthToken", which allows only you to command the Arduino
board.
Open a new project, give it a name, select your board, (for instance Arduino Uno), and E-
mail the "YourAuthToken", (push the E-mail button), and then create. The
"YourAuthToken" is a series of letters and numbers appearing above the E-mail button.
This "YourAuthToken" must be introduced into your Arduino code, (see next steps).
Go to the Widget Box and select the desired widget, in our case Button.
Drag it into the dashboard, give it a name, (button led), and select the Arduino pin to
which will be connected, in our case D13. Select the color, (optional), and the mode of
activation, switches for our project. After uploading the Arduino code on the board and
after setting the right ports of the computer, play the application on your smartphone. Of
course, the computer and the smartphone must be connected to the internet. That's all.
2. Coding the Arduino board and setting the ports of computer.
The crucial point of this project is represented by the correct installation of the Blynk
library on the computer. I followed the very good tutorial of Saurabh Gangamwar47 ,
(http://www.instructables.com/id/Control-arduino-using-Blynk-over-usb/?ALLSTEPS),
to perform this action, but I added some personal modifications. We must follow the next
steps:
Connect the Arduino board to the computer, open the Arduino ide, open Tools, select the
right Board, (Arduino UNO in my case), open the Serial Port and select the port to
which the board is connected, (COM 3 in my case). Mind this port. Keep open the
Arduino ide.

Download the Blynk library, Blynk_v0.3.1, using the link provided by Saurabh
Gangamwar, ( Blynk library.), and save the zip file in your Arduino work folder.

Unzip the file; you will find the following folders, (see the print screen above):
Copy all these folders into the Arduino\library folder. Usually this folder is situated on
the :
(C:\Program Files (x86)\Arduino\ libraries)
For my path is:
C:\Users\your own folder\Documents\Arduino\libraries. It appears like this:

Now you must set the correct port which allows Arduino board to be connected to
internet trough the computer. Go to
C:\Users\your own folder\Documents\Arduino\libraries
and open \libraries\Blynk\. You will see something like this:
Open scripts, select blynk-ser

Right click on blynk-ser and select edit. You will obtain these windows:
Click run.
Now, very important, in line 6, (blue highlighted on the print screen), set COM
PORT=COM(your Arduino port)
Edit the port to which the Arduino board is connected, (COM PORT=COM3 in my case).
Then save this modification, (click file, save). Close these windows.

Go again to, to scipts\blynk-ser, and double left click, an then run


If the library is correct installed you must obtain this screen

If all is correct you will find this message


Connecting device at COM3 to blynk-cloud.com:8442...
OpenC0C("\\.\COM3", baud=9600, data=8, parity=no, stop=1) - OK
Connect("blynk-cloud.com", "8442") - OK
InOut() START
DSR is OFF

Now the Arduino board is connected to the internet and it is ready to receive commands
from the smartphone.
Warning, if you don't obtain this message, that means that the connection is not
established. You must modify the script folder following the instruction presented at the
end of this tutorial. This was my situation on windows 10 education.

3. Now is time to upload the Arduino code, (from libraries or the examples presented in
this work, or other). In the
libraries\Blynk\examples\BoardsAndShields\Arduino_Serial_USB, copy the
Arduino_Serial_USB code and drop it into Arduino ide. Introduce your authentification
code (YourAuthToken) mailed from the Blynk application
char auth[] = "YourAuthToken";
Upload the code on the Arduino board. Connect a led between D13 and GND via 220
Ohms resistor.
Alternatively you can use my code,

Example 1. Switch led on-off


Acknowledgment
**************************************************************
* 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 networks: http://www.fb.com/blynkapp
* http://twitter.com/blynk_app
*
* Blynk library is licensed under MIT license
*********************************************

#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>

char auth[] = "e5beac0d31f4433da82dc64b99a03b47";


//delete the above code and put here your YourAuthToken

void setup()
{
SwSerial.begin(9600);
Blynk.begin(auth);
}

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

If you have close already the scripts, then go again to


C:\Users\your own folder\Documents\Arduino\libraries\Blynk\scripts,
left double click blynk-ser, a then run. The message will appear:

Connecting device at COM3 to blynk-cloud.com:8442...


OpenC0C("\\.\COM3", baud=9600, data=8, parity=no, stop=1) - OK
Connect("blynk-cloud.com", "8442") - OK
InOut() START
DSR is OFF

And the windows:

Keep open the windows \script\ blynk-ser\ run\ otherwise the connection will be lost.
Now the Arduino board is ready to receive commands from the smartphone.

4. Open the Blynk project on your Smartphone, run the application, switch the button
led icon, and the led on the Arduino board will shine.

Important. If the original library blynk v0.3.1 don't work, (that was my problem), then
download the version blynk v0.4.0 from the link below.
https://github.com/blynkkk/blynk-library/releases/tag/v0.4.0
Save into separately folder, not in Arduino \libraries\, unzip the Blynk_Release_v0.4.0.
You will find many folders, as well Blynk folder. The screen looks like this:
Open Blynk folder and select scripts. Copy this folder and then go to
C:\Users\your own folder\Documents\Arduino\libraries\Blynk\scripts
and replace the existent scripts folder, (which got from the v0.3.1), with this one (scripts
from v0.4.0). Below, on the left side of the screen is the old library, blynk v0.3.1, and on
the right side is the library blynk v0.4.0

Repeat the procedure of setting the ports presented above. In my case it woks.
That's all!
Example 2. Control one servo

Acknowledgment
**************************************************************
* 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 networks: http://www.fb.com/blynkapp
* http://twitter.com/blynk_app
*
* Blynk library is licensed under MIT license
*********************************************

#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>
#include <SPI.h>
#include <Servo.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "e5beac0d31f4433da82dc64b99a03b47";
//delete the above code and put here your YourAuthToken
Servo servo;
void setup()
{
SwSerial.begin(9600);
Blynk.begin(auth);
servo.attach(9);
// on Arduino board attach servo to D9, GND and +5V.
}
BLYNK_WRITE(V4)
{
servo.write(param.asInt());
}
void loop()
{
Blynk.run();
}
In the previous Blynk application keep the button-led and add a slider. Give name servo,
attach to the virtual V4 this slider and set the range of angles from 0 to180. It`s all.
On the Arduino board attach led between D13 and GND, servo to GND, +5V and D9 (the
command of the servo). Upload the code, then run blynk-ser as described previously,
open the Blynk app on the Smartphone, slide the slider. The display shows the angle of
rotation. The servo will follow the slider. Switch the button-led on and off. On the
Arduino board the led will shine or will be off.
Example 3. Get analog data from potentiometer

This example shows what getting analog data from a potentiometer connected to GND,
+5V and A2 and display the result on the Smartphone. To do this, on the Blynk app we
keep the button-led and we add a display on virtual pin V5. We set the domain between 0
and 1023 and the refresh rate 1sec. The display will show the tension on A2 pin of
Arduino, between 0 and 5V.
The code:

//read analog tension on A2 and display on Smartphone


#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>
//#include <SPI.h>

char auth[] = "e5beac0d31f4433da82dc64b99a03b39";


//delete the above code and put here your YourAuthToken

#define tensiune V5
//on Blynk attach display on virtual V5
float tens;
int tensPin = 2; //attach potentiometer on A2

void setup()
{
SwSerial.begin(9600);
Blynk.begin(auth);

BLYNK_READ(tensiune)
{
Blynk.virtualWrite(tensiune, tens);
}

void loop()
{
Blynk.run();
tens = analogRead(tensPin);
tens = tens*5/1024; //normalize the data to max 5volts
}

***************************************************************
We can replace the potentiometer by the temperature sensor LM 35 and we will have the
temperature.

// LM35 to gnd, +5v and A2


//on Blynk App display on virtual V5

#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>

#include <SPI.h>

char auth[] = "e5beac0d31f4433da82dc64b99a03b39";


//delete the above code and put here your YourAuthToken

#define temperature V5

float temp;
int tempPin = 2; //analog pin 2

void setup()
{
SwSerial.begin(9600);
Blynk.begin(auth);
}

BLYNK_READ(temperature)
{
View publication stats

Blynk.virtualWrite(temperature, temp);
}

void loop()
{
Blynk.run();
temp = analogRead(tempPin);
temp = temp * 0.488;
}

Thanks
I took many examples from internet, especially from Instrutables site, and I modified
some of them. I thank all the contributors from worldwide which posted theirs work on
the public domain.

You might also like