Blink App
Blink App
net/publication/310096021
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.
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.
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.
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,
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>
void setup()
{
SwSerial.begin(9600);
Blynk.begin(auth);
}
void loop()
{
Blynk.run();
}
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:
#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.
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(2, 3); // RX, TX
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>
#include <SPI.h>
#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.