0% found this document useful (0 votes)
859 views

Docs Blynk CC Blynk Server

Blynk is a platform for building hardware projects that can be controlled remotely via a mobile app. It consists of the Blynk app, Blynk server, and Blynk libraries. The Blynk app allows users to create interfaces for controlling hardware using widgets. The Blynk server handles communication between the app and hardware. Blynk libraries enable communication with the server from various hardware platforms. Users need an Arduino, Raspberry Pi, or similar device and the Blynk app to get started. The guide provides instructions for connecting an LED to an Arduino and controlling it remotely with the Blynk app.

Uploaded by

Herry Sulfian
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)
859 views

Docs Blynk CC Blynk Server

Blynk is a platform for building hardware projects that can be controlled remotely via a mobile app. It consists of the Blynk app, Blynk server, and Blynk libraries. The Blynk app allows users to create interfaces for controlling hardware using widgets. The Blynk server handles communication between the app and hardware. Blynk libraries enable communication with the server from various hardware platforms. Users need an Arduino, Raspberry Pi, or similar device and the Blynk app to get started. The guide provides instructions for connecting an LED to an Arduino and controlling it remotely with the Blynk app.

Uploaded by

Herry Sulfian
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/ 154

Blynk

Intro
This guide will help you understand how to get started using Blynk and give a comprehensive overview of
all the features.

If you want to jump straight into playing with Blynk, check out Getting Started.

GETTING STARTED

How Blynk Works

Blynk was designed for the Internet of Things. It can control hardware remotely, it can display sensor data,
it can store data, vizualize it and do many other cool things.

There are three major components in the platform:

Blynk App - allows to you create amazing interfaces for your projects using various widgets we provide.

Blynk Server - responsible for all the communications between the smartphone and hardware. You can
use our Blynk Cloud or run your private Blynk server locally. It’s open-source, could easily handle

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
thousands of devices and can even be launched on a Raspberry Pi.

Blynk Blynk Libraries - for all the popular hardware platforms - enable communication with the server and
process all the incoming and outcoming commands.

Now imagine: every time you press a Button in the Blynk app, the message travels to space the Blynk
Cloud, where it magically nds its way to your hardware. It works the same in the opposite direction and
everything happens in a blynk of an eye.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Features

Similar API & UI for all supported hardware & devices


Connection to the cloud using:
WiFi
Bluetooth and BLE
Ethernet
USB (Serial)
GSM

Set of easy-to-use Widgets


Direct pin manipulation with no code writing
Easy to integrate and add new functionality using virtual pins
History data monitoring via History Graph widget
Device-to-Device communication using Bridge Widget
Sending emails, tweets, push noti cations, etc.
… new features are constantly added!

You can nd example sketches covering basic Blynk Features. They are included in the library. All the
sketches are designed to be easily combined with each other.

What do I need to Blynk?

At this point you might be thinking: “Ok, I want it. What do I need to get started?” – Just a couple of things,
really:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
1. Hardware.
Blynk
An Arduino, Raspberry Pi, or a similar development kit.

Blynk works over the Internet. This means that the hardware you choose should be able to connect to the
internet. Some of the boards, like Arduino Uno will need an Ethernet or Wi-Fi Shield to communicate,
others are already Internet-enabled: like the ESP8266, Raspberri Pi with WiFi dongle, Particle Photon or
SparkFun Blynk Board. But even if you don’t have a shield, you can connect it over USB to your laptop or
desktop (it’s a bit more complicated for newbies, but we got you covered). What’s cool, is that the list of
hardware that works with Blynk is huge and will keep on growing.

2. A Smartphone.

The Blynk App is a well designed interface builder. It works on both iOS and Android, so no holywars here,
ok?

Downloads

Blynk Apps for iOS or Android

    

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Blynk Library

DOWNLOAD THE BLYNK LIBRARY

In case you forgot, or don’t know how to install Arduino libraries click here.

Getting Started
Let’s get you started in 5 minutes (reading doesn’t count!). We will switch on an LED connected to your
Arduino using the Blynk App on your smartphone.

Connect an LED as shown here:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Getting Started With The Blynk App

1. Create a Blynk Account


After you download the Blynk App, you’ll need to create a New Blynk account. This account is separate from
the accounts used for the Blynk Forums, in case you already have one.

We recommend using a real email address because it will simplify things later.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Why do I need to create an account?

An account is needed to save your projects and have access to them from multiple devices from anywhere.
It’s also a security measure.

You can always set up your own Private Blynk Server and have full control.

2. Create a New Project


After you’ve successfully logged into your account, start by creating a new project.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Give it a name.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

3. Choose Your Hardware


Select the hardware model you will use. Check out the list of supported hardware!

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

4. Auth Token
Auth Token is a unique identi er which is needed to connect your hardware to your smartphone. Every new
project you create will have its own Auth Token. You’ll get Auth Token automatically on your email after
project creation. You can also copy it manually. Click on devices section :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Click on device :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

And you’ll see token :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

NOTE: Don’t share your Auth Token with anyone, unless you want someone to have access to your
hardware.

It’s very convenient to send it over e-mail. Press the e-mail button and the token will be sent to the e-mail
address you used for registration. You can also tap on the Token line and it will be copied to the clipboard.

Now press the “Create” button.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

5. Add a Widget
Your project canvas is empty, let’s add a button to control our LED.

Tap anywhere on the canvas to open the widget box. All the available widgets are located here. Now pick a
button.

Widget Box

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Drag-n-Drop - Tap and hold the Widget to drag it to the new position.

Widget Settings - Each Widget has it’s own settings. Tap on the widget to get to them.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

The most important parameter to set is PIN . The list of pins re ects physical pins de ned by your hardware.
If your LED is connected to Digital Pin 8 - then select D8 (D - stands for Digital).

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

6. Run The Project


When you are done with the Settings - press the PLAY button. This will switch you from EDIT mode to PLAY
mode where you can interact with the hardware. While in PLAY mode, you won’t be able to drag or set up
new widgets, press STOP and get back to EDIT mode.

You will get a message saying “Arduino UNO is o line”. We’ll deal with that in the next section.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Getting Started With Hardware

How To Use an Example Sketch


You should by now have the Blynk Library installed on your computer. If not - click here.

Example sketches will help you get your hardware online quickly and major Blynk features.

Open the example sketch according to the hardware model or shield you are using.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Let’s take a look at the example sketch for an Arduino UNO + Ethernet shield

#define BLYNK_PRINT Serial


#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

char auth[] = "YourAuthToken";

void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth); // Here your Arduino connects to the Blynk Cloud.
}

void loop()
{
Blynk.run(); // All the Blynk Magic happens here...
}

Auth Token

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
In this example sketch, nd this line:
Blynk
char auth[] = "YourAuthToken";

This is the Auth Token that you emailed yourself. Please check your email and copy it, then paste it inside
the quotation marks.

It should look similar to this:

char auth[] = "f45626c103a94983b469637978b0c78a";

Upload the sketch to the board and open Serial Terminal. Wait until you see something like this:

Blynk v.X.X.X
Your IP is 192.168.0.11
Connecting...
Blynk connected!

Congrats! You are all set! Now your hardware is connected to the Blynk Cloud!

Blynking

Go back to the Blynk App, push the button and turn the LED on and o ! It should be Blynking.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Check out other example sketches.

Feel free to experiment and combine di erent examples together to create your own amazing projects.

For example, to attach an LED to a PWM-enabled Pin on your Arduino, set the slider widget to control the
brightness of an LED. Just use the same steps described above.

Hardware set-ups

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Arduino over USB (no shield)

If you don’t have any shield and your hardware doesn’t have any connectivity, you can still use Blynk –
directly over USB :

1. Open Arduino Serial USB example and change Auth Token

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#define BLYNK_PRINT DebugSerial


#include <BlynkSimpleStream.h>

// You should get Auth Token in the Blynk App.


// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

void setup()
{
// Debug console
DebugSerial.begin(9600);

// Blynk will work through Serial


Serial.begin(9600);
Blynk.begin(auth, Serial);
}

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

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk 2. Run the script which is usually located in /scripts folder:

Windows: My Documents\Arduino\libraries\Blynk\scripts
Mac User$/Documents/Arduino/libraries/Blynk/scripts

On Windows:

Open cmd.exe

Write your path to blynk-ser.bat folder. For example:

cd C:\blynk-library-0.3.1\blynk-library-0.3.1\scripts

Run blynk-ser.bat le. For example : blynk-ser.bat -c COM4 (where COM4 is port with your
Arduino)

And press “Enter”, press “Enter” and press “Enter”

On Linux and Mac:

Navigate to /scripts folder. For example:

cd User$/Documents/Arduino/libraries/Blynk/scripts

When inside this folder, run:

user:scripts User$ ./blynk-ser.sh

Warning: Do no close terminal window with running script.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
In some cases you may also need to perform :
Blynk
user:scripts User$ chmod +x blynk-ser.sh

You may need also to run it with sudo

user:scripts User$ sudo ./blynk-ser.sh

This is what you’ll see in Terminal app on Mac (usbmodem address can be di erent):

[ Press Ctrl+C to exit ]


/dev/tty.usbmodem not found.
Select serial port [ /dev/tty.usbmodem1451 ]:

Copy the serial port address: /dev/tty.usbmodem1451 and paste it back:

Select serial port [ /dev/tty.usbmodem1451 ]: /dev/tty.usbmodem1451

After you press Enter, you should see an output similar to this:

Resetting device /dev/tty.usbmodem1451...


Connecting: GOPEN:/dev/tty.usbmodem1451,raw,echo=0,clocal=1,cs8,nonblock=1,ix
2015/10/03 00:29:45 socat[30438.2046857984] N opening character device "/dev/
2015/10/03 00:29:45 socat[30438.2046857984] N opening connection to LEN=16 AF
2015/10/03 00:29:45 socat[30438.2046857984] N successfully connected from loc
2015/10/03 00:29:45 socat[30438.2046857984] N SSL connection using AES128-SHA
2015/10/03 00:29:45 socat[30438.2046857984] N starting data transfer loop wit

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
NOTE: Arduino IDE may complain with “programmer is not responding”. You need to terminate script
Blynk before uploading new sketch.

Additional materials:

Tutorial: Control Arduino over USB with Blynk app. No shield required. Mac OS)
How to control arduino (Wirelessly) with blynk via USB. Windows
Instructables: Control Arduino with Blynk over USB

Raspberry Pi

1. Connect your Raspberry Pi to the Internet and open it’s console.


2. Run this command (it updates your OS package repository to include the required packages):

curl -sL "https://deb.nodesource.com/setup_6.x" | sudo -E bash -

3. Download and build Blynk JS library using npm:

sudo apt-get update && sudo apt-get upgrade


sudo apt-get install build-essential
sudo npm install -g npm
sudo npm install -g onoff
sudo npm install -g blynk-library

4. Run Blynk test script (put your auth token):

blynk-client 715f8cafe95f4a91bae319d0376caa8c

5. You can write our own script based on examples

6. To enable Blynk auto restart for Pi, nd /etc/rc.local le and add there:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk node full_path_to_your_script.js <Auth Token>

Additional materials:

Instructables: Blynk on Javascript for Raspberry Pi, Intel Edison and others
Instructables: Use DHT11/DHT12 sensors with Raspberry Pi and Blynk

Note: Instead of using Node.js, you can also build a C++ libarry version (same as Arduino, WiringPi-based)
installation: - Library README for Linux - Blynk Community Topic: How-To Raspberry Pi - Video tutorial -
Setting up Blynk and Raspberry Pi:

ESP8266 Standalone

You can run Blynk directly on the ESP8266!

Install the latest ESP8266 library for Arduino using this guide.

Example Sketch: ESP8266_Standalone

Additional materials:

Instructables: ESP8266 ESP-12(Standalone)+ Blynk


Instructables: ESP8266-12 standalone Blynk lm35 temperature sensor

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Step-by-Step Tutorial in Russian language
Blynk

NodeMCU

Please follow this detailed instruction. Or watch this Video tutorial.

Arduino + ESP8266 WiFi with AT commands

This connection type is not recommended for beginners.


If you would like to try it, please carefully read this help topic Note: Some boards like Arduino UNO WiFi
from Arduino.org, do not use AT commands (and do not provide relevant libraries), so this renders them
unusable with Blynk.

Particle

Blynk works with the whole family of Particle products: Core, Photon and Electron

1. Open Particle Web IDE.


2. Go to the libraries.
3. Search for Blynk in the Community Libraries and click on it
4. Open 01_PARTICLE.INO example
5. Click “use this example”
6. Put your Auth Token here: char auth[] = "YourAuthToken"; and ash the Particle!

You can scan this QR code from the Blynk App and you’ll get a ready-to-test project for Particle Photon. Just
put your Auth Token into the 01_PARTICLE.INO example.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Additional materials:

Particle core + DHT22

Blynk main operations

Virtual Pins

Blynk can control Digital and Analog I/O Pins on you hardware directly. You don’t even need to write code
for it. It’s great for blinking LEDs, but often it’s just not enough…

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
We designed Virtual Pins to send any data from your microcontroller to the Blynk App and back.
Blynk
Anything you connect to your hardware will be able to talk to Blynk. With Virtual Pins you can send
something from the App, process it on microcontroller and then send it back to the smartphone. You can
trigger functions, read I2C devices, convert values, control servo and DC motors etc.

Virtual Pins can be used to interface with external libraries (Servo, LCD and others) and implement custom
functionality.

Hardware may send data to the Widgets over the Virtual Pin like this:

Blynk.virtualWrite(pin, "abc");
Blynk.virtualWrite(pin, 123);
Blynk.virtualWrite(pin, 12.34);
Blynk.virtualWrite(pin, "hello", 123, 12.34);

For more information about virtual pins, read this

Send data from app to hardware

You can send any data from Widgets in the app to your hardware.

All Controller Widgets can send data to Virtual Pins on your hardware. For example, code below shows
how to get values from the Button Widget in the App

BLYNK_WRITE(V1) //Button Widget is writing to pin V1


{
int pinData = param.asInt();
}

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
When you press a Button, Blynk App sends 1 On the second click - it sends 0
Blynk
This is how Button Widget is set up:

Full example sketch: Get Data

Sending array from Widget


Some Widgets (e.g Joystick, zeRGBa) have more than one output.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

This output can be written to Virtual Pin as an array of values. On the hardware side - you can get any
element of the array [0,1,2…] by using:

BLYNK_WRITE(V1) // Widget WRITEs to Virtual Pin V1


{
int x = param[0].asInt(); // getting first value
int y = param[1].asInt(); // getting second value
int z = param[N].asInt(); // getting N value
}

Sketch: JoystickTwoAxis

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Get data from hardware

There are two ways of pushing data from your hardware to the Widgets in the app over Virtual Pins.

Perform requests by Widget


Using Blynk built-in reading frequency while App is active by setting ‘Reading Frequency’ parameter
to some interval:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
BLYNK_READ(V5) // Widget in the app READs Virtal Pin V5 with the certain freq
{
// This command writes Arduino's uptime in seconds to Virtual Pin V5
Blynk.virtualWrite(5, millis() / 1000);
}

Sketch: PushDataOnRequest

Pushing data from hardware


If you need to PUSH sensor or other data from your hardware to Widget, you can write any logic you want.
Just set the frequency to PUSH mode. Any command that hardware sends to Blynk Cloud is automatically
stored on server and you get this info either with History Graph widget or with HTTP API.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

We recommend sending data in intervals and avoiding Flood Error.


You can use timers like BlynkTimer.
Please read instructions inside this example sketch for more details.

Here is how it can work:

#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

char auth[] = "YourAuthToken"; // Put your token here

BlynkTimer timer; // Create a Timer object called "timer"!

void setup()

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
{
Serial.begin(9600);
Blynk Blynk.begin(auth);

timer.setInterval(1000L, sendUptime); // Here you set interval (1sec) and


}

void sendUptime()
{
// This function sends Arduino up time every 1 second to Virtual Pin (V5)
// In the app, Widget's reading frequency should be set to PUSH
// You can send anything with any interval using this construction
// Don't send more that 10 values per second

Blynk.virtualWrite(V5, millis() / 1000);


}

void loop()
{
Blynk.run(); // all the Blynk magic happens here
timer.run(); // BlynkTimer is working...
}

Sketch: PushData

State syncing

For hardware
If your hardware looses Internet connection or resets, you can restore all the values from Widgets in the
Blynk app.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
BLYNK_CONNECTED() {
Blynk.syncAll();
}

//here handlers for sync command


BLYNK_WRITE(V0) {
....
}

The Blynk.syncAll() command restores all the Widget’s values based on the last saved values on the
server. All analog and digital pin states will be restored. Every Virtual Pin will perform BLYNK_WRITE
event.

Sync Hardware with App state

You can also update a single Virtual Pin value by calling Blynk.syncVirtual(V0) or you can update
several pins with Blynk.syncVirtual(V0, V1, V2, ...) .

You can also use server to store any value without widget. Just call Blynk.virtualWrite(V0, value) .

Storing single value on server

Storing multiple values on server

For app
If you need to keep your hardware in sync with Widgets’ state even if app is o line use
Blynk.virtualWrite .

Imagine you have a LED Widget connected to the Virtual Pin V1 in the app, and a physical button attached
to your hardware. When you press a physical button, you would expect to see updated state of the LED

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Widget in the app. To achieve that you need to send Blynk.virtualWrite(V1, 255) when a physical
button gets pressed.
Blynk
Represent physical button state via LED widget with interrupts

Represent physical button state via LED widget with polling

Represent physical button state via Button widget with polling

Control of multiple devices

Blynk app has support of multiple devices. That means you can assign any widget to speci c device with
own auth token. For example - you may have button on V1 that controls wi- bulb A and another button on
V1 that controls wi- bulb B. In order to do this you need more than 1 device within your project. To achieve
this please go to project settings and click on “Devices” section :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

You’ll see list of devices :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

So you can add new device :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

After above steps, every widget will have one more eld “Target” :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Now you need to assign widget to device and after that widget will control only this speci c device.

That’s it! Now you need to upload sketches with correct Auth Tokens to your hardware.

Tags
Tags feature allows you to group multiple devices. Tags are very useful in case you want to control few
devices with 1 widget. For example, imagine a case when you have 3 smart bulbs and you want to turn on
all those bulbs with one single click. You need to assign 3 devices to 1 tag and assign tag to button. That’s it.

Tag widgets also support state syncing. So you can get state of widget from your hardware. However you
can’t update state of such widgets from hardware.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Devices online status

Blynk app has support for online statuses for multiple devices.

In ideal world when device closes tcp connection with some connection.close() - connected server
will get noti cation regarding closed connection. So you can get instant status update on UI. However in
real world this mostly exceptional situation. In majority of cases there is no easy and instant way to nd out
that connection is not active anymore.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
That’s why Blynk uses HEARTBEAT mechanism. With this approach hardware periodically sends ping
Blynk command with prede ned interval (10 seconds by default, BLYNK_HEARTBEAT property). In case
hardware don’t send anything within 10 seconds server waits additional 5 seconds and after that
connection assumed to be broken and closed by server. So on UI you’ll see connection status update only
after 15 seconds when it is actually happened.

You can also change HEARTBEAT interval from hardware side via Blynk.config . In that case
newHeartbeatInterval * 2.3 formula will be applied. So in case you you decided to set
HEARTBEAT interval to 5 seconds. You’ll get noti cation regarding connection with 11 sec delay in worst
case.

Project Settings

Every project has it’s own settings:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Theme - switch between the Light and Black Blynk Theme (Business accounts have wider choice);
Keep screen always on - allows you to use the Blynk app without going to the sleep mode (usually all
mobile devices do that);
Send app connected command - with this option enabled the server will send “App Connected” and
“App Disconnected” commands to your hardware when your Blynk app goes online/o ine. Usage
example;
Do not show o line noti cations - right now, for debugging purposes, every time your hardware goes
o ine - the Blynk Server will notify you with popup in the app about that. However, when
debugging is not needed or the Blynk app is used only via HTTP/S this noti cations are meaningless.
So this switch allows you to turn o this popups. Also this switch turns o the Push noti cation
“Notify when o ine” option.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Change Widget properties

Changing some of the widget properties from hardware side is also supported.
For example, you can change the color of LED widget based on a condition:

//change LED color


Blynk.setProperty(V0, "color", "#D3435C");

//change LED label


Blynk.setProperty(V0, "label", "My New Widget Label");

//change MENU labels


Blynk.setProperty(V0, "labels", "Menu Item 1", "Menu Item 2", "Menu Item 3");

Set Property for single value eld

Set Property for multi value eld

NOTE : Changing these parameters work only for widgets attached to Virtual pins (analog/digital pins
won’t work).

Four widget properties are supported - color , label , min , max for all widgets :

label is string for label of all widgets.

color is string in HEX format (in the form: #RRGGBB, where RR (red), GG (green) and BB (blue) are
hexadecimal values between 00 and FF). For example :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
#define BLYNK_GREEN "#23C48E"
#define BLYNK_BLUE "#04C0F8"
#define BLYNK_YELLOW "#ED9D00"
#define BLYNK_RED "#D3435C"
#define BLYNK_DARK_BLUE "#5F7CD8"

min , max - minimum and maximum values for the widget (for example range for the Slider). This
numbers may be oat.

On rmware side, widget objects also support setLabel() and setColor() functions.

Widget speci c properties:

Button

onLabel is string for ON label of button;

offLabel is string for OFF label of button;

Music Player

isOnPlay is boolean accepts true/false.

Blynk.setProperty(V0, "isOnPlay", "true");

Menu

labels is list of strings for Menu widget selections;

Blynk.setProperty(V0, "labels", "label 1", "label 2", "label 3");

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Video Streaming
Blynk
Blynk.setProperty(V1, "url", "http://my_new_video_url");

You can also change widget properties via HTTP API.

Limitations and Recommendations

Don’t put Blynk.virtualWrite and any other Blynk.* command inside void loop() - it will
cause lot’s of outgoing messages to our server and your connection will be terminated;

We recommend calling functions with intervals. For example, use BlynkTimer

Avoid using long delays with delay() – it may cause connection breaks;

If you send more than 100 values per second - you may cause Flood Error and your hardware will be
automatically disconnected from the server;

Be careful sending a lot of Blynk.virtualWrite commands as most hardware is not very powerful
(like ESP8266) so it may not handle many requests.

Widgets
Widgets are interface modules. Each of them performs a speci c input/ output function when
communicating with the hardware.

There are 4 types of Widgets:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Controllers - they send commands to hardware. Use them to control your stu ;

Blynk Displays - used for various visualizations of data that comes from hardware to the smartphone;
Noti cations - are various widgets to send messages and noti cations;
Interface - are various widgets to make your UI look better;
Others - widgets that don’t belong to any category;

Each Widget has it’s own settings.

Some of the Widgets (e.g. Bridge Widget) are used to enable some functionality and they don’t have any
settings.

Common Widget Settings

Pin Selector
This is one of the main parameters you need to set. It de nes which pin to control or to read from.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Digital Pins - represent physical Digital IO pins on your hardware. PWM-enabled pins are marked with the
~ symbol

Analog Pins - represent physical Analog IO pins on your hardware

Virtual Pins - have no physical representation. They are used for any data transfer between Blynk App and
your hardware. Read more about Virtual Pins here.

Data Mapping
In case you want to map incoming values to speci c range you may use mapping button :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Let’s say your sensor sends values from 0 to 1023. But you want to display values in a range 0 to 100 in the
application. With data mapping enabled, incoming value 1023 will be mapped to 100.

SPLIT/MERGE
Some of the Widgets can send more than one value. And with this switch you can control how to send
them.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

SPLIT: Each of the parameters is sent directly to the Pin on your hardware (e.g D7). You don’t need to
write any code.

NOTE: In this mode you send multiple commands from one widget, which can reduce performance of
your hardware.

Example: If you have a Joystick Widget and it’s set to D3 and D4, it will send 2 commands over the
Internet:

digitalWrite(3, value);
digitalWrite(4, value);

MERGE: When MERGE mode is selected, you are sending just 1 message, consisting of array of values.
But you’ll need to parse it on the hardware.

This mode can be used with Virtual Pins only.

Example: Add a zeRGBa Widget and set it to MERGE mode. Choose Virtual Pin V1

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk BLYNK_WRITE(V1) // There is a Widget that WRITEs data to V1
{
int r = param[0].asInt(); // get a RED channel value
int g = param[1].asInt(); // get a GREEN channel value
int b = param[2].asInt(); // get a BLUE channel value
}

Send On Release
This option is available for most controller widgets and allows you to decrease data tra ic on your
hardware. For example, when you move joystick widget, commands are continuously streamed to the
hardware, during a single joystick move you can send dozens of commands. There are use-cases where it’s
needed, however creating such a load may cause hardware reset. We recommend enabling Send On
Release feature for most of the cases, unless you really need instant feedback. This option is enabled by
default.

Write interval
Similar to above option. However, allows you to stream values to your hardware within certain interval. For
example, setting write interval to 100 ms - means, that while you move slider only 1 value will be send to
hardware within 100 ms. This option also used to decrease data tra ic on your hardware.

Color gradient
Some display widgets have ability to select gradient. Gradient allows you to colorize your widgets without
any coding. At the moment we provide 2 types of gradients :

Warm: Green - Orange - Red;

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Cold : Green - Blue - Violet;

Blynk Gradient changes color of your widget based on min/max properties. For example, you select warm
gradient for your Level Display widget with min 0 and max 100 value. When value 10 comes to widget it will
have green color, when value 50 comes you’ll see orange color, when value 80 comes you’ll see red color.

Controllers

Button
Works in push or switch modes. Allows to send 0/1 (LOW/HIGH) values. Button sends 1 (HIGH) on press and
sends 0 (LOW) on release.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Sketch: BlynkBlink

Slider
Similar to potentiometer. Allows to send values between MIN and MAX.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Sketch: BlynkBlink

Timer
Timer triggers actions at a speci c time. Even if smartphone is o line. Start time sends 1 (HIGH). Stop time
sends 0 (LOW).

Recent Android version also has improved Timer within Eventor widget. With Eventor Time Event you can
assign multiple timers on same pin, send any string/value, select days and timezone. It is recommended to
use Eventor over Timer widget. However Timer widget is still suitable for simple timer events.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

NOTE: The timer widget rely on the server time and not your phone time. Sometimes the phone time may
not match the server time.

Sketch: Timer

Joystick
Control servo movements in 4 directions

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Settings:
Blynk
SPLIT/MERGE modes - read here

Rotate on Tilt

When it’s ON, Joystck will automatically rotate if you use your smartphone in landscape orientation
- Auto-Return - When it’s OFF, Joystick handle will not return back to center position. It will stay where you
left it.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Sketch: JoystickTwoAxis

zeRGBa
zeRGBa is usual RGB controller (color picker).

Settings:

SPLIT: Each of the parameters is sent directly to the Pin on your hardware (e.g D7). You don’t need
to write any code.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
NOTE: In this mode you send multiple commands from one widget, which can reduce performance of your
Blynk hardware.

Example: If you have a zeRGBa Widget and it’s set to D1, D2, D3 it will send 3 commands over the Internet:

digitalWrite(1, r);
digitalWrite(2, g);
digitalWrite(3, b);

MERGE: When MERGE mode is selected, you are sending just 1 message, consisting of array of
values. But you’ll need to parse it on the hardware.

This mode can be used with Virtual Pins only.

Example: Add a zeRGBa Widget and set it to MERGE mode. Choose Virtual Pin V1.

BLYNK_WRITE(V1) // zeRGBa assigned to V1


{
// get a RED channel value
int r = param[0].asInt();
// get a GREEN channel value
int g = param[1].asInt();
// get a BLUE channel value
int b = param[2].asInt();
}

Step Control
Step control is like 2 buttons assigned to 1 pin. One button increments your value by desired step and
another one decrements it. It is very useful for use cases where you need to change your values very
precisely and you can’t achieve this precision with slider widget.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Send Step option allows you to send step to hardware instead of actual value of step widget. Loop value
Blynk option allows you to reset step widget to start value when maximum value is reached.

Sketch: Basic Sketch

Displays

Value Display
Displays incoming data from your sensors or Virtual Pins.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Sketch: BlynkBlink

Labeled Value
Displays incoming data from your sensors or Virtual Pins. It is a better version of ‘Value Display’ as it has a
formatting string, so you could format incoming value to any string you want.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Sketch: BlynkBlink

Formatting options

For example: your sensor sends vaule of 12.6789 to Blynk application. Next formatting options are
supported:

/pin/ - displays the value without formatting (12.6789)

/pin./ - displays the rounded value without decimal part (13)

/pin.#/ - displays the value with 1 decimal digit (12.7)

/pin.##/ - displays the value with two decimal places (12.68)

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

LED
A simple LED for indication. You need to send 0 in order to turn LED o . And 255 in order to turn LED on.
Or just use Blynk API as described below :

WidgetLED led1(V1); //register to virtual pin 1


led1.off();
led1.on();

All values between 0 and 255 will change LED brightness :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
WidgetLED led2(V2);
led2.setValue(127); //set brightness of LED to 50%.

Sketch: LED

Gauge

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
A great visual way to display incoming numeric values.
Blynk

Sketch: BlynkBlink

Formatting options

For example: your sensor sends vaule of 12.6789 to Blynk application. Next formatting options are
supported:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
/pin/ - displays the value without formatting (12.6789)
Blynk
/pin./ - displays the rounded value without decimal part (13)

/pin.#/ - displays the value with 1 decimal digit (12.7)

/pin.##/ - displays the value with two decimal places (12.68)

LCD
This is a regular 16x2 LCD display made in our secret facility in China.

SIMPLE / ADVANCED MODE

Commands

You need to use special commands with this widget:

lcd.print(x, y, "Your Message");

Where x is a symbol position (0-15), y is a line id (0 or 1),

lcd.clear();

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Sketch: LCD Advanced Mode Sketch: LCD Simple Mode Pushing Sketch: LCD Simple Mode Reading

Formatting options

For example: your sensor sends vaule of 12.6789 to Blynk application. Next formatting options are
supported:

/pin/ - displays the value without formatting (12.6789)

/pin./ - displays the rounded value without decimal part (13)

/pin.#/ - displays the value with 1 decimal digit (12.7)

/pin.##/ - displays the value with two decimal places (12.68)

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

SuperChart
SuperChart is used to visualise live and historical data. You can use it for sensor data, for binary event
logging and more.

To use SuperChart widget you would need to push the data from the hardware with the desired interval by
using timers.
Here is a basic example for data pushing.

Interactions:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Switch between time ranges and Live mode
Blynk Tap time ranges at the bottom of the widget to change time ranges

Tap Legend Elements to show or hide datastreams

Tap’n’hold to view timestamp and corresponding values

Quick swipe from left to right to reveal previous data

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Then you can then scroll data back and forward within the given time range.

Full Screen Mode


Press this button to open Full Screen view in landscape orientation:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Simply rotate the phone back to portrait mode. Chart should rotate automagically. In full screen view you
will see X (time) and multiple Y scales. Full Screen Mode can be disabled from widget Settings.

Menu Button
Menu button will open additional functions:

Export to CSV
Erase Data on the server

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

SuperChart (History Graph) Settings:

Chart Title

Title Font Size You have a choice of 3 font sizes

Title Alignment Choose chart title alignment. This setting also a ects Title and Legend position on the
Widget.

Datastreams - add datastreams (read below how to con gure datastreams)

Show/Hide Title
Show/Hide Legend

Datastream Settings

Widget supports up to 4 Datastreams. Press Datastream Settings Icon to open Datastream Settings.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Design: Choose available types of Chart:

Line
Area
Bar
Binary (anchor LINK to binary)

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Color: Choose solid colors or gradients
Blynk
Source and input: You can use 3 types of Data source:

1. Virtual Pin Choose the desired Device and Virtual Pin to read the data from.

2. Tags SuperChart can aggregate data from multiple devices using built-in aggregation functions. For
example, if you have 10 Temperature sensors sending temperature with the given period, you can plot
average value from 10 sensors on the widget.

To use Tags:

Add Tag to every device you want to aggregate data from.


Push data to the same Virtual Pin on every device. (e.g. Blynk.virtualWrite (V0,
temperature); )
Choose Tag as a source in SuperChart Widget and use the pin where the data is coming to (e.g V0)

Functions available:

SUM, will summarize all incoming values to the speci ed Virtual Pin across all devices tagged with
the chosen tag
AVG, will plot average value
MED, will nd a median value
MIN, will plot minimum value
MAX will plot minimum value

☝ IMPORTANT: Tags are not working in Live Mode.

1. Device Selector If you add Device Selector Widget to your project, you can use it as a source for
SuperChart. In this case, when you change the device in Device Selector, chart will be updated
accordingly

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Y-Axis Settings
Blynk There are two modes of how to scale data along the Y axis

1. Values
When this mode is selected, Y scale will be set to the values you choose. For example, if your
hardware sends data with values varying from -100 to 100, you can set the chart to this values and
data will be rendered correctly.

You may also want to visualize the data within some speci c range. Let’s say incoming data has values in
the range of 0-55, but you would like to see only values in the range 30-50. You can set it up and if values
are out of Y scale you con gured, chart will be cropped

1. % of Height
This option allows you to auto-scale incoming data on the widget and position it the way you want.
In this mode, you set up the percentage of widget height on the screen, from 0% to 100%.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

If you set 0-100%, in fact it’s a full auto-scale. No matter in which range the data is coming,
it will be always scaled to the whole height of the widget.

If you set it to 0-25%, then this chart will only be rendered on 1/4 of the widget height:

This setting is very valuable for Binary Chart or for visualizing a few datastreams on the same chart in a
di erent way.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Su ix:
Here you can specify a su ix that will be shown during the Tap’n’hold

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Connect Missing Data Points
Blynk If this switch is ON, then SuperChart will connect all the dots even if there was no data

If it’s set to OFF, then you will see gaps in case there was no data.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Binary Chart Settings


This type of chart is useful to plot binary data, for example when unit was ON or OFF, or when motion was
detected or when certain threshold was reached.

You need to specify a FLIP point, which is the point where incoming data will be turned into TRUE or FALSE
state.

For example, you send the data in the range of 0 to 1023 . If you set 512 as a FLIP point, then
everything above 512 (excluding 512) will be recorded as TRUE , any value below 512 (including
512) will be FALSE .

Another example, if you send 0 and 1 and set 0 as a FLIP point, then 1 will be TRUE , 0 will
be FALSE

State Labels:
Here you can specify how TRUE/FALSE should be shown in Tap’n’Hold mode.

For example, you can set to TRUE to “Equipment ON” label, FALSE to “Equipment OFF”.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Superchart supports currently 2 types of granularity:

Minute granularity - 1h , 6h , 1d ;
Hour granularity - 1w , 1m , 3m ;

This means that minimum chart update interval is 1 minute for 1h , 6h , 1d periods. 1 hour for 1w ,
1m and 3m periods. As Blynk Cloud is free to use we have a limit on how many data you can store. At
the moment Blynk Cloud accepts 1 message per minute per pin. In case you send your data more frequently
your values will be averaged. For example, in case you send value 10 at 12:12:05 and than again 12 at
12:12:45 as result in chart you’ll see value 11 for 12:12.

In order to see data in chart you need to use either widgets with “Frequency reading” interval (in that case
your app should be open and running) or you can use Blynk.virtualWrite on hardware side. Every
Blynk.virtualWrite command is stored on server automatically. In that case you don’t need
application to be up and running.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Terminal
Displays data from your hardware. Allows to send any string to your hardware. Terminal always stores last
25 messages your hardware had send to Blynk Cloud. This limit may be increased on Local Server with
terminal.strings.pool.size property.

You need to use special commands with this widget:

terminal.print(); // Print values, like Serial.print


terminal.println(); // Print values, like Serial.println()
terminal.write(); // Write a raw data buffer
terminal.flush(); // Ensure that data was sent out of device

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Sketch: Terminal

Video Streaming
Simple widget that allows you to display any live stream. Widget supports RTSP (RP, SDP), HTTP/S
progressive streaming, HTTP/S live streaming. For more info please follow o icial Android documentation.

At the moment Blynk doesn’t provide streaming servers. So you can either stream directly from camera, use
3-d party services or host streaming server on own server (on raspberry for example).

You can also change video url from hardware with :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Blynk.setProperty(V1, "url", "http://my_new_video_url");

Level Display
Displays incoming data from your sensors or Virtual Pins. Level Display is very similar to progress bar, it is
very nice and fancy view for indication of “ lled” events, like “level of battery”. You can update value
display from hardware side with code :

Blynk.virtualWrite(V1, val);

Every message that hardware sends to server is stored automatically on server. PUSH mode doesn’t require
application to be online or opened.

Sketch: Push Example

Noti cations

Twitter
Twitter widget connects your Twitter account to Blynk and allows you to send Tweets from your hardware.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Example code:

Blynk.tweet("Hey, Blynkers! My Arduino can tweet now!");

Limitations :

you cant’ send 2 tweets with same message (it’s Twitter policy)
only 1 tweet per 15 seconds is allowed

Sketch: Twitter

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Email
Email widget allows you to send email from your hardware to any address.

Example code:

Blynk.email("[email protected]", "Subject", "Your message goes here");

It also contains to eld. With this eld you may de ne receiver of email in the app. In that case you don’t
need to specify receiver on hardware :

Blynk.email("Subject", "Your message goes here");

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Limitations :

Maximum allowed email + subject + message length is 120 symbols. However you can increase this
limit if necessary by adding #de ne BLYNK_MAX_SENDBYTES XXX to you sketch. Where XXX is
desired max length of your email. For example for ESP you can set this to 1200 max length
#define BLYNK_MAX_SENDBYTES 1200 . The #define BLYNK_MAX_SENDBYTES 1200 must be
included before any of the Blynk includes.
Only 1 email per 15 seconds is allowed
In case you are using gmail on the Local Server you are limited with 500 mails per day (by google).
Other providers may have similar limitations, so please be careful.
User is limited with 100 messages per day in the Blynk Cloud;

Sketch: Email

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Push Noti cations
Push Noti cation widget allows you to send push noti cation from your hardware to your device. Currently
it also contains 2 additional options :

Notify when hardware o line - you will get push noti cation in case your hardware went o ine.
O line Ignore Period - de nes how long hardware could be o ine (after it went o ine) before
sending noti cation. In case period is exceeded - “hardware o ine” noti cation will be send. You
will get no noti cation in case hardware was reconnected within speci ed period.
Priority high priority gives more chances that your message will be delivered without any delays. See
detailed explanation here.

WARNING : high priority contributes more to battery drain compared to normal priority messages.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Example code:

Blynk.notify("Hey, Blynkers! My hardware can push now!");

Limitations :

Maximum allowed body length is 120 symbols.


Only 1 noti cation per 15 seconds is allowed

Sketch: PushNoti cation

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Unicode in notify, email, push, …
The library handles all strings as UTF8 Unicode. If you’re facing problems, try to print your message to the
Serial and see if it works (the terminal should be set to UTF-8 encoding). If it doesn’t work, probably you
should read about unicode support of your compiler.
If it works, but your message is truncated - you need to increase message length limit (all Unicode symbols
consume at least twice the size of Latin symbols).

Increasing message length limit


You can increase maximum message length by putting on the top of your sketch (before Blynk includes):

#define BLYNK_MAX_SENDBYTES 256 // Default is 128

Interface

Tabs
The only purpose of Tabs widget is to extend your project space. You can have up to 4 tabs. Also you can
drag widgets between tabs. Just drag widget on the label of required tab of tabs widget.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Menu
Menu widget allows you to send command to your hardware based on selection you made on UI. Menu
sends index of element you selected and not label string. Sending index is starts from 1. It works same way
as usual ComboBox element. You can also set Menu items from hardware side.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Example code:

switch (param.asInt())
{
case 1: { // Item 1
Serial.println("Item 1 selected");
break;
}
case 2: { // Item 2
Serial.println("Item 2 selected");
break;
}
}

Sketch: Menu

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Time Input
Time input widget allows you to select start/stop time, day of week, timezone, sunrise/sunset formatted
values and send them to your hardware. Supported formats for time now are HH:MM and HH:MM
AM/PM .

Hardware will get selected on UI time as seconds of day ( 3600 * hours + 60 * minutes ) for
start/stop time. Time that widget sends to hardware is user local time. Selected days indexes :

Monday - 1
Tuesday - 2
...
Saturday - 6
Sundays - 7

You can also change state of widget on UI. See below sketches.

Sketch: Simple Time Input for start time

Sketch: Advanced Time Input

Sketch: Update Time Input State on UI

Map
Map widget allows you set points/pins on map from hardware side. This is very useful widget in case you
have multiple devices and you want track their values on map.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
You can send a point to map with regular virtual wrtei command :
Blynk
Blynk.virtualWrite(V1, pointIndex, lat, lon, "value");

We also created wrapper for you to make suage of map simpler :

You can change button labels from hardware with :

WidgetMap myMap(V1);
...
int index = 1;
float lat = 51.5074;
float lon = 0.1278;
myMap.location(index, lat, lon, "value");

Using save index allows you to override existing point value.

Sketch: Basic Sketch

Table
Table widget comes handy when you need to structure similar data within 1 graphical element. It works as a
usual table.

You can add a row to the table with :

Blynk.virtualWrite(V1, "add", id, "Name", "Value");

You can update a row in the table with :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk.virtualWrite(V1, "update", id, "UpdatedName", "UpdatedValue");

Blynk
To highlight any item in a table by using it’s id in a table:

Blynk.virtualWrite(V1, "pick", 0);

To select/deselect (make icon green/grey) item in a table by using it’s row id in a table :

Blynk.virtualWrite(V1, "select", 0);


Blynk.virtualWrite(V1, "deselect", 0);

Move row to another position in the table by it index (row is removed and after that is added, have that in
mind when sending second index):

//1 is old row index, 2 is new row index


Blynk.virtualWrite(V1, "order", 1, 2);

To clear the table at any time with:

Blynk.virtualWrite(V1, "clr");

You can also handle other actions coming from table. For example, use row as a switch button.

BLYNK_WRITE(V1) {
String cmd = param[0].asStr();
if (cmd == "select") {
//row in table was selected.
int rowId = param[1].asInt();
}

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
if (cmd == "deselect") {
//row in table was deselected.
Blynk int rowId = param[1].asInt();
}
if (cmd == "order") {
//rows in table where reodered
int oldRowIndex = param[1].asInt();
int newRowIndex = param[2].asInt();
}
}

Note : Max number of rows in the table is 100. When you reach the limit, table will work as FIFO (First In
First Out) list. This limit can be changed by con guring table.rows.pool.size property for Local
Server.

Sketch: Simple Table usage

Sketch: Advanced Table usage

Device Selector
Device selector is a powerful widget which allows you to update widgets based on one active device. This
widget is particlularly helpful when you have a eet of devices with similar functionality.

Imagine you have 4 devices and every device has a Temperature & Humidity sensor connected to it. To
display the data for all 4 devices you would need to add 8 widgets.

With Device Selector, you can use only 2 Widgets which will display Temperature and Humidity based on
the active device chosen in Device Selector.

All you have to do is:

1. Add Device Selector Widget to the project

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
2. Add 2 widgets (for example Value Display Widget) to show Temperature and Humidity
3. In Widgets Settings you will be able assign them to Device Selector (Source or Target section)
Blynk 4. Exit settings, Run the project.

Now you can change the active device in Device Selector and you will see that Temperature and Humidity
values are re ecting the data updates for the device you just picked.

NOTE : Webhook Widget will not work with Device Selector (yet).

Device Tiles
Device tiles is a powerful widget and very similar to the device selector widget, but with UI. It allows you to
display 1 pin per device per tile. This widget is particularly helpful when you have a eet of devices with
similar functionality. So you can group similar devices within one layout (template).

Sensors

Accelerometer
Accelerometer is kind of motion sensors that allows you to detect motion of your smartphone. Useful for
monitoring device movement, such as tilt, shake, rotation, or swing. Conceptually, an acceleration sensor
determines the acceleration that is applied to a device by measuring the forces that are applied to the
sensor. Measured in m/s^2 applied to x , y , z axis.

In order to accept data from it you need to :

BLYNK_WRITE(V1) {
//acceleration force applied to axis x
int x = param[0].asFloat();

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
//acceleration force applied to axis y
int y = param[1].asFloat();
Blynk //acceleration force applied to axis y
int z = param[2].asFloat();
}

Accelerometer doesn’t work in background.

Barometer/pressure
Barometer/pressure is kind of environment sensors that allows you to measure the ambient air pressure.

Measured in in hPa or mbar .

In oder to accept data from it you need to :

BLYNK_WRITE(V1) {
//pressure in mbar
int pressure = param[0].asInt();
}

Barometer doesn’t work in background.

Gravity
Gravity is kind of motion sensors that allows you to detect motion of your smartphone. Useful for
monitoring device movement, such as tilt, shake, rotation, or swing.

The gravity sensor provides a three dimensional vector indicating the direction and magnitude of gravity.
Measured in m/s^2 of gravity force applied to x , y , z axis.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
In oder to accept data from it you need to :
Blynk
BLYNK_WRITE(V1) {
//force of gravity applied to axis x
int x = param[0].asFloat();
//force of gravity applied to axis y
int y = param[1].asFloat();
//force of gravity applied to axis y
int z = param[2].asFloat();
}

Gravity doesn’t work in background.

Humidity
Humidity is kind of environment sensors that allows you to measure ambient relative humidity.

Measured in % - actual relative humidity in percent.

In oder to accept data from it you need to :

BLYNK_WRITE(V1) {
// humidity in %
int humidity = param.asInt();
}

Humidity doesn’t work in background.

Light

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Light is kind of environment sensors that allows you to measure level of light (measures the ambient light
Blynk level (illumination) in lx). In phones it is used to control screen brightness.

In order to accept data from it you need to :

BLYNK_WRITE(V1) {
//light value
int lx = param.asInt();
}

Light doesn’t work in background.

Proximity
Proximity is kind of position sensors that allows you to determine how close the face of a smartphone is to
an object. Measured in cm - distance from phone face to object. However most of this sensors returns
only FAR / NEAR information. So return value will be 0/1 . Where 0/LOW is FAR and 1/HIGH is
NEAR .

In order to accept data from it you need to :

BLYNK_WRITE(V1) {
// distance to object
int proximity = param.asInt();
if (proximity) {
//NEAR
} else {
//FAR
}
}

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Proximity doesn’t work in background.
Blynk
Temperature
Temperature is kind of environment sensors that allows you to measure ambient air temperature.
Measured in °C - celcius.

In order to accept data from it you need to :

BLYNK_WRITE(V1) {
// temperature in celcius
int celcius = param.asInt();
}

Temperature doesn’t work in background.

GPS Trigger
GPS trigger widget allows easily trigger events when you arrive to or leave from some destination. This
widget will work in background and periodically will check your coordinates. In case your location is
within/out required radius (selected on widget map) widget will send HIGH / LOW command to
hardware. For example, let’s assume you have GPS Trigger widget assigned to pin V1 and option
Trigger When Enter . In that case when you’ll arrive to destination point widget will trigger HIGH
event.

BLYNK_WRITE(V1) {
int state = param.asInt();
if (state) {
//You enter destination
} else {

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
//You leave destination
}
Blynk }

More details on how GPS widget works you can read here.

GPS trigger widget works in background.

GPS Streaming
Useful for monitoring smartphone location data such as latitude, longitude, altitude and speed (speed
could be often 0
in case smartphone doesn’t support it).

In order to accept data from this widget you need to :

BLYNK_WRITE(V1) {
float latitude = param[0].asFloat();
float longitude = param[1].asFloat();
float altitude = param[2].asFloat();
float speed = param[3].asFloat();
}

or you can use prepared wrapper GpsParam :

BLYNK_WRITE(V1) {
GpsParam gps(param);
// Print 6 decimal places for Lat
Serial.println(gps.getLat(), 7);
Serial.println(gps.getLon(), 7);

Serial.println(gps.getAltitude(), 2);

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Serial.println(gps.getSpeed(), 2);
}
Blynk
GPS Streaming works in background.

Sketch: GPS Stream

Other

Bridge
Bridge can be used for Device-to-Device communication (no app. involved). You can send
digital/analog/virtual write commands from one device to another, knowing it’s auth token. At the moment
Bridge widget is not required on application side (it is mostly used for indication that we have such feature).
You can use multiple bridges to control multiple devices.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Bridge widget takes a virtual pin, and turns it into a channel to control another device. It means you can
control any virtual, digital or analog pins of the target device. Be careful not to use pins like A0, A1, A2
... when communicating between di erent device types, as Arduino Core may refer to wrong pins in
such cases.

Example code for device A which will send values to device B :

WidgetBridge bridge1(V1); //Initiating Bridge Widget on V1 of Device A


...
void setup() {
Blynk.begin(...);
while (Blynk.connect() == false) {
// Wait until Blynk is connected
}
bridge1.digitalWrite(9, HIGH); // will trigger D9 HIGH on Device B. No co

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
bridge1.analogWrite(10, 123);
bridge1.virtualWrite(V1, "hello"); // you need to write code on Device B
Blynk bridge1.virtualWrite(V2, "value1", "value2", "value3");
}

BLYNK_CONNECTED() {
bridge1.setAuthToken("OtherAuthToken"); // Token of the hardware B
}

IMPORTANT: when performing virtualWrite() with Bridge Widget, Device B will need to process the
incoming data from Device A. For example, if you are sending value from Device A to Device B using
bridge.virtualWrite(V5) you would need to use this handler on Device B:

BLYNK_WRITE(V5){
int pinData = param.asInt(); //pinData variable will store value that cam
}

Keep in mind that bridge.virtualWrite doesn’t send any value to mobile app. You need to call
Blynk.virtualWrite for that.

Sketch: Bridge

Eventor
Eventor widget allows you to create simple behaviour rules or events. Let’s look at a typical use case: read
temperature from DHT sensor and send push noti cation when the temperature is over a certain limit :

float t = dht.readTemperature();
if (isnan(t)) {
return;
}

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
if (t > 40) {
Blynk.notify(String("Temperature is too high : ") + t);
Blynk }

With Eventor you don’t need to write this code. All you need is to send the value from the sensor to the
server :

float t = dht.readTemperature();
Blynk.virtualWrite(V0, t);

Don’t forget that virtualWrite commands should be wrapped in the timer and can’t be used in the
main loop.

Now con gure new Event in Eventor widget:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
NOTE Don’t forget to add noti cation widget.
Blynk
Eventor comes handy when you need to change conditions on the y without re-uploading new sketch on
the hardware. You can create as many events as you need. Eventor also could be triggered from the
application side. You just need to assign the widget to the same pin as your Event within Eventor. Eventor
doesn’t constantly sends events. Let’s consider simple event as above if (temperature > 40) send
notification . When temperature goes beyond 40 threshold - noti cation action is triggered. If
temperature continues to stay above the 40 threshold no actions will be triggered. But if temperature
goes below threshold and then passes it again - noti cation will be sent again (there is no 15 sec limit on
Eventor noti cations).

Eventor also supports Timer events. For example, you can set a pin V1 ON/HIGH at 21:00:00 every
Friday. With Eventor Time Event you can assign multiple timers on same pin, send any string/number,
select days and timezone.

In order to remove created event please use swipe. You can also swipe out last element in the Event itself.

NOTE: The timer widget rely on the server time and not your phone time. Sometimes the phone time may
not match the server time. NOTE : Events are triggered only once when the condition is met. That’s mean
chaining of events is not possible (however, could be enabled for commercials).

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Sketch: Eventor

NOTE : Events are triggered only once when the condition is met. However there is one exclusion: Let’s
consider simple event as above if (temperature > 40) send notification . When temperature
goes beyond 40 threshold - noti cation action is triggered. If temperature continues to stay above the 40
threshold no actions will be triggered. But if temperature goes below threshold and then passes it
again - noti cation will be sent again (there is no 15 sec limit on Eventor noti cations).

RTC
Real-time clock allows you to get time from server. You can preselect any timezone on UI to get time on
hardware in required locale. No pin required for RTC widget.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Sketch: RTC

BLE
Widget for enabling Bluetooth Low Energy support. At the moment BLE widget requires internet
connection in order to login and load your pro le. However this will be xed soon. Also some Blynk widget
not allowed with BLE widget.

Blynk currently support bunch of di erent modules. Please check sketches below.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Sketches: BLE

Bluetooth
Widget for enabling Bluetooth support. At the moment Bluetooth widget supported only for Android and
requires internet connection in order to login and load your pro le. However this will be xed soon. Also
some Blynk widget not allowed with Bluetooth widget.

Blynk currently support bunch of di erent modules. Please check sketches below.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Sketches: Bluetooth

Music Player
Simple UI element with 3 buttons - simulates music player interface. Every button sends it’s own command
to hardware : play , stop , prev , next .

You can change widget state within the app from hardware side with next commands:

Blynk.virtualWrite(Vx, “play”);
Blynk.virtualWrite(Vx, “stop”);

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
You can also change widget play/stop state with next code (equivalent to above commands) :
Blynk
Blynk.setProperty(V1, "isOnPlay", "false");

Sketch: Music Player

Webhook
Webhook is a widget for 3-d party integrations. With webhook widget you can send HTTP/S requests to
any 3-d party server or device that has HTTP/S API (Philips Hue for instance).

Any write operation from hardware side will trigger webhook widget (same way as for eventor). You can
also trigger webhook from application side in case control widget assigned to same pin as webhook. You
can trigger 3-d party service with single button click.

For example, imagine a case when you want to send data from your hardware not only to Blynk but also to
Thingspeak server. In typical, classic use case you’ll need to write code like this (this is minimal and not full
sketch) :

WiFiClient client;
if (client.connect("api.thingspeak.com", 80)) {
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + apiKeyThingspeak1 + "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
}

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
With webhook widget this is not necessary anymore. All you need just ll below elds :
Blynk

And do usual :

Blynk.virtualWrite(V0, value);

where V0 is pin assigned to webhook widget.

Also you can use usual Blynk placeholders for pin value in body or url, for example :

https://api.thingspeak.com/update?api_key=xxxxxx&field1=/pin/

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
or for body
Blynk
["/pin/"]

You can also refer to speci c index of multi value pin (multi pin supports up to 10 values) :

/pin[0]/ , /pin[1]/ , /pin[2]/

Another cool thing about webhook is that you can make GET requests from Blynk Server side and return
response directly to your hardware. The beauty here is that you don’t need to code request to 3-d party
service. Imagine a case when you want to get weather from some 3-d party service. For example, you have
an url http://api.sunrise-sunset.org/json?lat=33.3823&lng=35.1856&date=2016-10-01 , you
can put it in widget, select V0 pin, and do usual :

BLYNK_WRITE(V0){
String webhookdata = param.asStr();
Serial.println(webhookdata);
}

Now, every time you’ll trigger V0 pin (with Blynk.virtualWrite(V0, 1) from hardware side or with
control widget assigned to V0 ) - BLYNK_WRITE(V0) will be triggered.

NOTE : usually 3-d party servers returns big responses, so you have to increase hardware maximum
allowed message size with #define BLYNK_MAX_READBYTES 1024 . Where 1024 - is maximum
allowed message size.

NOTE : Blynk cloud has limitation for webhook widget - you are allowed to send only 1 request per second.
You can change this on local server with webhooks.frequency.user.quota.limit . Please be very
careful using webhooks, as many resources not capable to handle even 1 req/sec, so you may be banned on
some of them. For example thingspeak allows to send 1 request per 15 seconds.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
NOTE : In order to avoid spamming Blynk Webhook has one more limitation - in case your webhook
Blynk requests were failed 10 times in row your webhook widget will be stopped. In order to resume it you need
to open widget and save it again. Failed requests are requests that return status code that are not equal to
200 or 302.

NOTE : Webhook widget may a ect Blynk.syncAll() feature. As returned response from server may
be big. So, please, be careful with it.

Sharing
Blynk o ers two types of sharing your projects with other people:

Share access to your hardware. Think about giving someone an App for your Project. They can’t modify,
but can control and see what’s there.

Share your Project con guration. Others will get a clone of your project by scanning a given QR link, but
they won’t be able to control your hardware. It’s great for tutorials, instructables, etc.

Shared access to your hardware

Imagine giving someone an App to control your Project.

people you’ve shared your project with can’t modify anything. They can only use it
you can update your app, change the layout, add widgets and it’s immediately synced to everyone
you can revoke access at any moment

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
How it works: - you send the QR code to your users (you can email, print, post to social media, do whatever
Blynk you want) - others download Blynk app, scan the QR code and your app opens for them ready to use. They
don’t even need to login or create an account.

Go to your Project’s Settings:

Click on “Generate Link” button :

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

It will generate QR code you can share with others:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

That’s it! Now Exit the settings and press PLAY button.

Another person would need to install Blynk app and scan QR code from the login screen (scanning from
existing pro le is not yet supported) ;

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

NOTE: Your Project should be active, don’t forget to press Play button.

WARNING: Sharing costs 1000 energy and this energy is not recoverable even you didn’t use sharing at all.

Share your Project con guration

In case you want to share your Project’s set up without giving access to your hardware (for example to
make a tutorial or instructable)- follow the steps:

In Project’s Settings go to Clone button.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

It will generate QR code you can share with anyone.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

HOME GET TING STARTED DOCS COMMUNITY


Another person should Log In to Blynk app and press QR button in Projects gallery

INTRO
How Blynk Works
Features
What do I need to Blynk?

DOWNLOADS
Blynk Apps for iOS or Android
Blynk Library

GETTING STARTED
Getting Started With The Blynk App
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Gett g Sta ted t e ly pp
1. Create a Blynk Account

Blynk
2. Create a New Project
3. Choose Your Hardware
4. Auth Token
5. Add a Widget
6. Run The Project
Getting Started With Hardware
How To Use an Example Sketch
Auth Token
Blynking

HARDWARE SET-UPS
Arduino over USB (no shield)
Raspberry Pi
ESP8266 Standalone
NodeMCU

After the scan, a new Project will be created, all the widgets, settings, layout will be cloned. Another person
would need enough Energy Balance to clone your Project.

Auth Token will be di erent!. Nobody will get access to your hardware. They just get a copy of the layout
and settings.

HTTP RESTful API


Blynk HTTP RESTful API allows to easily read and write values of Pins in Blynk apps and Hardware.
API description can be found here.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Supported Hardware
Blynk supports more than 400 boards already, including support for Arduino, Particle, ARM mbed, TI
Energia, MicroPython, Node.js, OpenWRT and many Single Board Computers. You can add your own
connection types easily (see these examples for Arduino)!

Platforms

Arduino (https://github.com/blynkkk/blynk-library)

Arduino Uno, Duemilanove


Arduino Nano, Mini, Pro Mini, Pro Micro, Due, Mega
Arduino 101 (Intel Curie, with BLE)
Arduino MKR1000
Arduino Zero
Arduino Yún (onboard WiFi and Ethernet, via Bridge)
Arduino.org UNO WiFi

Arduino-like

Blynk Board
ESP8266 (Generic, NodeMCU, Witty Cloud, Huzzah, WeMos D1, Seeed Wio Link, etc.)
ESP32 (WiFi, BLE)
Nordic nRF51/nRF52 - based boards
Teensy 3.2/3.1
Blue Pill (STM32F103C)
Realtek RTL8710 / Ameba via RTLduino

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
BBC micro:bit
LightBlue Bean , soon
Blynk DFRobot Bluno
RedBear Duo (WiFi, BLE)
RedBearLab Blend Micro
RedBearLab BLE Nano (v1 and v2)
Seeed Tiny BLE
Simblee BLE
RFduino BLE
The AirBoard (BLE-Link, RN-XV)
Feather M0 WiFi
Feather 32u4 BLE
Intel Edison
Intel Galileo
Fishino Guppy, Uno, Mega
TinyCircuits TinyDuino (CC3000)
Microduino/mCookie Core, Core+, CoreUSB
Wicked WildFire V2, V3, V4
Digistump Oak
chipKIT Uno32
Alorium XLR8 (FPGA)
LinkIt ONE (WiFi only)

Energia

Texas Instruments
CC3220SF-LaunchXL
CC3200-LaunchXL
Tiva C Connected LaunchPad
Stellaris LM4F120 LaunchPad
MSP430F5529 + CC3100
LaunchPad MSP432

RedBearLab (CC3200, WiFi Mini)

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Particle https://github.com/vshymanskyy/blynk-library-spark)

Blynk Core
Photon
Electron
RPi
SparkFun RedBoard
RedBear Duo (WiFi & BLE)

ARM mbed (https://developer.mbed.org/users/vshymanskyy/code/Blynk/)

Seeed Tiny BLE


RedBearLab BLE Nano
BBC micro:bit
STM32 Nucleo + Wiznet 5100 , soon

JavaScript (Node.js, Espruino, Browsers) (https://www.npmjs.com/package/blynk-library)

Regular PC with Linux / Windows / OS X


Raspberry Pi (Banana Pi, Orange Pi, …)
BeagleBone Black
Onion Omega
Onion Omega 2
Intel Galileo
Intel Edison
Intel Joule
LeMaker Guitar
LeMaker Banana Pro
Samsung ARTIK 5
PandaBoard, CubieBoard, pcDuino, Tessel 2
VoCore (OpenWRT + Espruino package)
Espruino Pico

Python (https://github.com/vshymanskyy/blynk-library-python)

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
MicroPython
Blynk Python 2
Python 3

Lua (https://github.com/blezek/blynk-esp)

NodeMCU

Arduino connection types

USB (Serial), connected to your laptop or desktop

Ethernet:

Arduino Ethernet Shield (W5100)


Arduino Ethernet Shield 2 (W5500)
SeeedStudio Ethernet Shield V2.0 (W5200)
ENC28J60-based modules

WiFi:

ESP8266 as WiFi modem (running original rmware)


Arduino WiFi 101 Shield
Arduino WiFi Shield
WIZnet WizFi310
Adafruit CC3000 WiFi Breakout / Shield
RN-XV WiFly

Bluetooth Smart (BLE 4.0):

HM-10, HC-08
DFRobot BLE-Link module

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Microduino/mCookie BLE
RedBearLab BLE Mini
Blynk nRF8001-based boards (Adafruit Bluefruit LE, etc.)

Bluetooth 2.0 Serial Port Pro le (SPP)

HC-05, HC-06, …

GSM/3G:

SIMCom SIM800 series (SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868)


SIMCom SIM900 series (SIM900A, SIM900D, SIM908, SIM968)
A6/A7
M590 (beta)
GPRSbee
Microduino GSM
Adafruit FONA (Mini Cellular GSM Breakout)
Adafruit FONA 800/808 Shield

Made by Community

WIZnet-W5500-EVB
LabVIEW
Node-RED (can be used as bridge to HTTP, TCP, UDP, MQTT, XMPP, IRC, OSC…)

Problematic Boards

These boards are not supported and do not work out of the box: - Arduino Tian

Here is a list of known library issues

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Troubleshooting

Connection

If you experience connection problems, follow these steps:

1. Check that your hardware, wires, cables and power supply are good quality, not harmed or
damaged, etc.
Use high power USB cables and USB ports.
2. Check your wiring using the examples (TCP/HTTP Client or similar) provided with your shield and
hardware.

Once you understand how to manage connection, it’s much easier to use Blynk.

3. Try running command telnet blynk-cloud.com 80 from your PC, connected to the same network as
your hardware. You should see something like: Connected to blynk-cloud.com. .
4. Try running Blynk default examples for your platform without modi cations to see if it is working.

Double-check that you have selected the right example for your connection type and hardware
model.
Our examples come with comments and explanations. Read them carefully.
Check that your Auth Token is valid (copied from the App and doesn’t contain spaces, etc.)
If it doesn’t work, try looking into serial debug prints.

5. Done! Add your modi cations and functionality. Enjoy Blynk!

Note: when you have multiple devices connected to your network, they should all have di erent MAC and
IP addresses. For example, when using 2 Arduino UNO with Ethernet shields, ashing default example to
both of them will cause connection problems. You should use manual ethernet con guration example.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

WiFi network connection

If you encounter WiFi connection problems, please check these pitfalls:

You’re trying to connect to “WPA & WPA2 Enterprise” network (often used in o ces), and your shield
does not support this security method
Your WiFi network has a login page that requests entering an access token (often used in
restaurants)
Your WiFi network security disallows connecting alien devices completely (MAC ltering, etc)
There is a rewall running. Default port for hardware connections is 80 (8080 on the Local Server).
Make sure it’s open.

Delay

If you use long delay() or send your hardware to sleep inside of the loop() expect connection
drops and downgraded performance.

DON’T DO THAT:

void loop()
{
...
delay(1000); // this is long delay, that should be avoided
other_long_operation();
...
Blynk.run();
}

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Note: This also applies to the BLYNK_READ & BLYNK_WRITE handlers!
Blynk
SOLUTION: If you need to perform actions in time intervals - use timers, for example BlynkTimer.

Flood Error

If your code frequently sends a lot of requests to our server, your hardware will be disconnected. Blynk App
may show “Your hardware is o line”

When Blynk.virtualWrite is in the void loop , it generates hundreds of “writes” per second

Here is an example of what may cause ood. DON’T DO THAT:

void loop()
{
Blynk.virtualWrite(1, value); // This line sends hundreds of messages to Bl
Blynk.run();
}

SOLUTION: If you need to perform actions in time intervals - use timers, for example BlynkTimer.

Using delay() will not solve the problem either. It may cause another issue. Use timers!

If sending hundreds of requests is what you need for your product you may increase ood limit on local
server and within Blynk library. For local server you need to change user.message.quota.limit
property within server.properties le :

#100 Req/sec rate limit per user.


user.message.quota.limit=100

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
For library you need to change BLYNK_MSG_LIMIT property within BlynkConfig.h le :
Blynk
//Limit the amount of outgoing commands.
#define BLYNK_MSG_LIMIT 20

Enable debug

To enable debug prints on the default Serial, add this on the top of your sketch (it should be the rst line in
your sketch):

#define BLYNK_DEBUG // Optional, this enables lots of prints


#define BLYNK_PRINT Serial

And enable serial in void setup() :

Serial.begin(9600);

You can also use spare Hardware serial ports or SoftwareSerial for debug output (you will need an adapter
to connect to it with your PC).

Note: enabling debug mode will slow down your hardware processing speed up to 10 times.

Geo DNS problem

Blynk Cloud utilizes Geo DNS for non-commercial solutions in order to minimize servers maintenance
costs. It means that when you connect to blynk-cloud.com , DNS service redirects you to the closest

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
server based on your IP address. The issue is that the hardware and application sometimes are not in the
same network. And there is a chance that hardware and smartphone are connected to di erent servers. You
Blynk will get User is not registered message in that case.

There are 2 ways to resolve this issue:

Use Local Blynk Server


ping blynk-cloud.com from the network your hardware is connected to. Use the IP address that
you get during this ping and put it in mobile app like that:

Reset password

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
On login screen click on “Problems signing in?” label and than “Reset Password” button. You’ll get
Blynk instruction on your email.

Security
Blynk server has 3 ports open for di erent security levels.

8441 - SSL/TLS connection for the hardware


80 - plain TCP connection for the hardware (no security)
443 - SSL/TLS connection for the Mobile Apps
8080 - plain TCP connection for hardware on the Local Server (no security)
9443 - SSL/TLS connection for the Mobile Apps on the Local Server

Hardware may select to connect to 8441 or 80, depending on it’s capabilities.

Use SSL gateway

Most platforms are not capable to handle SSL, so they connect to 80. However, our gateway script can be
used to add SSL security layer to communication.

./blynk-ser.sh -f SSL

This will forward all hardware connections from 8441 port to the server via SSL gateway. You can run this
script on your Raspberry Pi, desktop computer, or even directly on your router!

Note: when using your own server, you should overwrite the bundled server.crt certi cate, or specify it to
the script using --cert switch:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
./blynk-ser.sh -f SSL -s <server ip> -p 8441 --cert=<certificate>.crt

Flag -f SSL is enabled by default for USB communication so you don’t have to explicit declare it.

Note: SSL is supported by the gateway only on Linux/OSX for now

If you want to skip SSL, and connect to TCP, you can also do that:

./blynk-ser.sh -t TCP

Use Local Blynk Server

In order to gain maximum security you could install Blynk server locally and restrict access to your network,
so nobody except you could access it. In this case all data is stored locally within your network and not
send via Internet.

In case of Local Blynk Server there is also no need to protect connection between your hardware and Local
Blynk Server. This is true for Ethernet connection and partially true for Wi-Fi connection. In case of Wi-Fi
you have to use at least WPA, WPA2 (Wi-Fi Protected Access) Wi-Fi type in order to protect wireless tra ic.

WPA and WPA2 o er a very robust encryption that is likely to protect all data travelling over the air—given
that a strong enough password is used. Even if your data is plain TCP/IP, another user won’t be able to
decipher captured packets. Still, make sure that your password is strong enough, otherwise the only
limiting factor for an attacker is time.

OTA

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk also supports over the air updates for - ESP8266, NodeMCU and SparkFun Blynk boards. OTA
Blynk supported only for the private servers and for the paid customers for now.

How does it work?

You need to use regular sketch for exported apps;


After you launched your hardware you are ready for OTA;
You can trigger the rmware update for the speci c hardware via it’s token or for all hardware.

Flow
1. User triggers OTA with one of below HTTPS request;
2. User provides within HTTPS request admin credentials and rmware binary le to update hardware
with;
3. When hardware connects to server - server checks it rmware. In case, hardware rmware build
date di ers from uploaded rmware, than server sends special command to hardware with url for
the new rmware;
4. Hardware processes url with below handler:

BLYNK_WRITE(InternalPinOTA) {
//url to get firmware from. This is HTTP url
//http://localhost:8080/static/ota/FUp_2441873656843727242_upload.bin
overTheAirURL = param.asString();
...
}

1. Hardware downloads new rmware and starts ashing rmware;

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Trigger update for the speci c hardware

curl -v -F file=@Template_ESP8266.ino.nodemcu.bin --insecure -u [email protected]

Template_ESP8266.ino.nodemcu.bin - is relative (or full) path to your rmware;


--insecure ag for servers with self-generated certi cates. You don’t need this ag if you used Let’s
Encrypt or other trusted certi cates;
[email protected]:admin admin credentials to your server. This is default ones. Format is
username:password . You can change it in server.properties le;
token is token of your hardware you want apply the rmware update to. The rmware update
will be initiated only in case device is online;

Trigger OTA for all devices

Update for all devices will be triggered only when they are connected to the cloud. You need to remove the
token part for that.

curl -v -F file=@Template_ESP8266.ino.nodemcu.bin --insecure -u [email protected]

In that case, OTA will be triggered right after device connected to the server. In case device is online
rmware update will be initiated only when device will be connected again.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Trigger OTA for the speci c user

In that case rmware update will be triggered for all devices of speci ed user.

curl -v -F file=@Template_ESP8266.ino.nodemcu.bin --insecure -u [email protected]

Trigger OTA for speci c user and project

In that case rmware update will be triggered for all devices of speci ed user within speci ed project.

curl -v -F file=@Template_ESP8266.ino.nodemcu.bin --insecure -u [email protected]

Stop OTA

curl -v --insecure -u [email protected]:admin https://localhost:9443/admin/ota/s

How to make rmware

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
In order to make rmware in Arduino IDE - go to menu: Sketch -> Export compiled Binary.
Blynk
NOTE: ESP8266 right now takes rmware only via HTTP. And not HTTPS.

Blynk server
Blynk Server is an Open Source Java server, responsible for forwarding messages between Blynk mobile
application and various microcontroller boards (i.e. Arduino, Raspberry Pi. etc).

Download latest server build:

DOWNLOAD BLYNK SERVER

Why do I need Local Blynk Server?

Better security. You are the only one who knows about the server. You can setup security policies
tied to your speci c needs (MAC, IPs, login names, etc). You can also make it accessible only within
your private network.
Better stability. No need to rely on 3rd party Cloud solution. You have the full control.
Lower latency. Server is as close to you as it could be.
Maximum privacy. All data is stored locally and is not shared with anyone.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Installing your own Local Blynk Server

For detailed instruction please follow github page.

Blynk Firmware

Con guration

Blynk.begin()
The simplest way to con gure Blynk is to call Blynk.begin() :

Blynk.begin(auth, ...);

It has various parameters for di erent hardware, depending on the type of connection you use. Follow the
example sketches for your board.

begin() is basically doing these steps:

1. Connects to network (WiFi, Ethernet, …)

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
2. Calls Blynk.con g(...) - sets auth token, server address
3. Tries to connects to the server once (can block for more than 30s)
Blynk
If your shield/connection type is not supported yet - you can craft it yourself easily! Here are some
examples.

Blynk.con g()
config() allows you to manage network connection yourself. You can set up your shield (WiFi,
Ethernet, …) manually, and then call:

Blynk.config(auth, server, port);

or just

Blynk.config(auth);

Note: Just after Blynk.config(...) , Blynk is not yet connected to the server.
It will try to connect when it reaches rst Blynk.run() or Blynk.connect() call.
If you want to skip connecting to the server, just call Blynk.disconnect() right after con guration.

For setting-up WiFi connection, you can use a connectWiFi (just for convenience):

Blynk.connectWiFi(ssid, pass);

To connect to open WiFi networks, set pass to an empty string ( "" ).

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Connection management

There are several functions to help with connection management:

Blynk.connect()

# This functions will try connecting to Blynk server.


# Returns true when connected, false if timeout reached.
# Default timeout is 30 seconds.
bool result = Blynk.connect();
bool result = Blynk.connect(timeout);

Blynk.disconnect()
To disconnect from Blynk server, use:

Blynk.disconnect();

Blynk.connected()
To get the status of connection to Blynk Server use:

bool result = Blynk.connected();

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Blynk.run()
This function should be called frequently to process incoming commands and perform housekeeping of
Blynk connection. It is usually called in void loop() {} .

You can initiate it in other places, unless you run out of heap memory (in the cascaded functions with local
memory). For example, it is not recommended to call Blynk.run() inside of the BLYNK_READ and
BLYNK_WRITE functions on low-RAM devices.

Digital & Analog pins control

The library can perform basic pin IO (input-output) operations out-of-the-box:

digitalRead
digitalWrite
analogRead
analogWrite (PWM or Analog signal depending on the platform)

No need to write code for simple things like LED, Relay control and analog sensors.

Virtual pins control

Virtual Pins are designed to send any data from your microcontroller to the Blynk App and back. Think
about Virtual Pins as channels for sending any data. Make sure you di erentiate Virtual Pins from physical
pins on your hardware. Virtual Pins have no physical representation.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Virtual Pins can be used to interface with libraries (Servo, LCD and others) and implement custom
Blynk functionality. The device may send data to the App using Blynk.virtualWrite(pin, value) and
receive data from the App using BLYNK_WRITE(vPIN) .

Virtual Pin data types

The actual values are sent as strings, so there are no practical limits on the data that can be sent.
However, remember the limitations of the platform when dealing with numbers. For example the integer on
Arduino is 16-bit, allowing range -32768 to 32767. You can interpret incoming data as Integers, Floats,
Doubles and Strings:

param.asInt();
param.asFloat();
param.asDouble();
param.asStr();

You can also get the RAW data from the param bu er:

param.getBuffer()
param.getLength()

Blynk.virtualWrite(vPin, value)
You can send all the formats of data to Virtual Pins

// Send string
Blynk.virtualWrite(pin, "abc");

// Send integer
Blynk.virtualWrite(pin, 123);

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
// Send float
Blynk Blynk.virtualWrite(pin, 12.34);

// Send multiple values as an array


Blynk.virtualWrite(pin, "hello", 123, 12.34);

// Send RAW data


Blynk.virtualWriteBinary(pin, buffer, length);

Note: Calling virtualWrite attempts to send the value to the network immediately.

Blynk.setProperty(vPin, “property”, value)


This allows changing widget properties

BLYNK_WRITE(vPIN)
BLYNK_WRITE de nes a function that is called when device receives an update of Virtual Pin value from
the server:

BLYNK_WRITE(V0)
{
int value = param.asInt(); // Get value as integer

// The param can contain multiple values, in such case:


int x = param[0].asInt();
int y = param[1].asInt();
}

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
BLYNK_READ(vPIN)
BLYNK_READ de nes a function that is called when device is requested to send it’s current value of
Virtual Pin to the server. Normally, this function should contain some Blynk.virtualWrite calls.

BLYNK_READ(V0)
{
Blynk.virtualWrite(V0, newValue);
}

BLYNK_WRITE_DEFAULT()
This rede nes the handler for all pins that are not covered by custom BLYNK_WRITE functions.

BLYNK_WRITE_DEFAULT()
{
int pin = request.pin; // Which exactly pin is handled?
int value = param.asInt(); // Use param as usual.
}

BLYNK_READ_DEFAULT()
This rede nes the handler for all pins that are not covered by custom BLYNK_READ functions.

BLYNK_READ_DEFAULT()
{

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
int pin = request.pin; // Which exactly pin is handled?
Blynk.virtualWrite(pin, newValue);
Blynk }

BLYNK_CONNECTED()
This function is called every time Blynk gets connected to the server. It’s convenient to call sync functions
here.

BLYNK_CONNECTED() {
// Your code here
}

BLYNK_APP_CONNECTED()
This function is called every time the Blynk app gets connected to the server.

BLYNK_APP_CONNECTED() {
// Your code here
}

Note: you need to enable this feature within project settings:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Example

BLYNK_APP_DISCONNECTED()
This function is called every time the Blynk app gets connected to the server.

BLYNK_APP_DISCONNECTED() {
// Your code here
}

Note: you need to enable this feature within project settings:

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

Example

Blynk.syncAll()
Request server to send the most recent values for all widgets. In other words, all analog/digital pin states
will be restored and every virtual pin will generate BLYNK_WRITE event.

BLYNK_CONNECTED() {
Blynk.syncAll();
}

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
Blynk.syncVirtual(vPin)
Requests virtual pins value update. The corresponding BLYNK_WRITE handler is called as the result.

Blynk.syncVirtual(V0);
# Requesting multiple pins is also supported:
Blynk.syncVirtual(V0, V1, V6, V9, V16);

BlynkTimer

BlynkTimer enables you to perform periodic actions in the main loop() context.
It is the same as widely used SimpleTimer, but xes several issues.
BlynkTimer is included in Blynk library by default, so no need to install SimpleTimer separately or
include SimpleTimer.h
Please note that a single BlynkTimer object allows to schedule up to 16 timers.

For more information on timer usage, please see: http://playground.arduino.cc/Code/SimpleTimer


And here is a BlynkTimer example sketch.

Debugging

#de ne BLYNK_PRINT

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk
#de ne BLYNK_DEBUG
To enable debug prints on the default Serial, add on the top of your sketch (should be the rst line):

#define BLYNK_PRINT Serial // Defines the object that is used for printing
#define BLYNK_DEBUG // Optional, this enables more detailed prints

And enable Serial Output in setup():

Serial.begin(9600);

Open Serial Monitor and you’ll see the debug prints.

You can also use spare Hardware serial ports or SoftwareSerial for debug output (you will need an adapter
to connect to it with your PC).

WARNING: Enabling BLYNK_DEBUG will slowdown your hardware processing speed up to 10 times!

BLYNK_LOG()
When BLYNK_PRINT is de ned, you can use BLYNK_LOG to print your logs. The usage is similar to
printf :

BLYNK_LOG("This is my value: %d", 10);

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
On some platforms (like Arduino 101) the BLYNK_LOG may be unavailable, or may just use too much
Blynk resources.
In this case you can use a set of simpler log functions:

BLYNK_LOG1("Heeey"); // Print a string


BLYNK_LOG1(10); // Print a number
BLYNK_LOG2("This is my value: ", 10); // Print 2 values
BLYNK_LOG4("Temperature: ", 24, " Humidity: ", 55); // Print 4 values
...

Minimizing footprint

To minimize the program Flash/RAM, you can disable some of the built-in functionality:

1. Comment-out #de ne BLYNK_PRINT to remove prints


2. Put on the top of your sketch:

#define BLYNK_NO_BUILTIN // Disable built-in analog & digital pin operation


#define BLYNK_NO_FLOAT // Disable float operations

Please also remember that a single BlynkTimer can schedule many timers, so most probably you need
only one instance of BlynkTimer in your sketch.

Porting, hacking

If you want to dive into crafting/hacking/porting Blynk library implementation, please also check this
documemtation.

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Blynk

FAQ
I backed Blynk on Kickstarter. Where are my widgets and why the app is free?

App is free because otherwise you would have to pay to download it. This is how AppStore and Google
Play works. Current Blynk release has a limited amount of widgets. We decided to make them free for
everyone until we implement store. After that, every widget will be paid. However every backer will get
them for free (according to their pledge).

What is Blynk Cloud?

Blynk Cloud is a open-source software written on Java using plain TCP/IP and secured TCP/IP (for
hardware that supports it) sockets and running on our server. Blynk iOS and Android apps connect to
Blynk Cloud by default. Access is free for every Blynk user. We also provide a Private Server distribution
for those who want to install it locally.

How much access to Cloud Blynk Server cost?

It is free for every Blynk user.

Can I run Blynk server locally?

Yes. Those of you, who want extra security or don’t have internet connection, can install Local Blynk
Server and run it in your own local network. Blynk Server is Open-Source and it takes less than few
seconds to deploy. All the instructions and les are here.

What are the requirements to run Private Blynk Server?

To run Private Blynk Server, all you need is Java Runtime Environment.

Can I run Blynk server on Raspberry Pi?

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Yes, surely! Here is instruction.

Blynk Does Blynk app work over Bluetooth?

Yes. It is in beta right now.

Does Blynk support Ethernet / Wi-FI / UART?

Yes, all of them. See full list of supported hardware and shields.

I don’t have any shield. Can I use Blynk with my computer?

Yes, you can use Blynk just with a USB cable. There is a step-by-step instruction on how to do it.

Can Blynk handle multiple Arduinos?

Yes. There 3 ways right now :

add multiple devices to your project.


you may use same Auth Token for di erent hardware. In that case you can control few
hardwares from 1 dashboard.
you can do it using Bridge functionality which allows you to send messages from one hardware
to another.

Does Blynk server store sensor data when app goes o line?

Yes, every command that hardware sends to server is stored. You could use History Graph widget in
order to view it.

How many Virtual Pins I can use?

It depends mostly on your hardware. Low-end hardware may use up to 32 Virtual Pins. More powerful
(like ESP8266) can use up to 128 but it requires also BLYNK_USE_128_VPINS property in your sketch.
Example.

Why app requires all this permissions?

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
http://help.blynk.cc/faq/blynk-android-permissions-explained
Blynk

Links
Blynk site
Blynk community
Facebook
Twitter
Blynk Library
Blynk Examples
Blynk Server
Kickstarter campaign

License
This project is released under The MIT License (MIT)

Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD

You might also like