Wiznet makers

teddy

Published October 25, 2022 ©

97 UCC

8 WCC

73 VAR

0 Contests

0 Followers

0 Following

Original Link

How Blynk Works

This tutorial is mainly to teach you how to start using Blynk and introduce a comprehensive introduction to each function of Blynk, made by

COMPONENTS
PROJECT DESCRIPTION

How Blynk Works


Blynk was born for the internet. It can control hardware remotely, display sensor data, store data, graph data and some other cool things.

The Blynk platform mainly consists of the following parts:

Blynk App - allows you to create interfaces for your projects with plugins provided by Blynk
Blynk Server - responsible for all information exchange between your hardware and your phone. You can use Blynk's public cloud, or you can create your own private Blynk server. The simplest Blynk server can even be created with a Raspberry Pi.
Blynk Libraries - Compatible with a variety of popular hardware platforms, making user projects very simple.

Think about it: every time you press the blynk control button on your phone, this information will be transmitted to the Blynk cloud server through the network, and the server will then send precise commands to your hardware, and everything happens in an instant. The flow is as shown below.

characteristic


Clear and simple API interface and UI interface.
Support for connecting to the Blynk cloud
WIFI wireless
Bluetooth and Bluetooth Low Energy
Ethernet (wired network)
USB (serial port)
GSM
simple plugin
No code required to define pins
Easy integration and added functionality with virtual pins
Monitor historical data
Use bridge plug-ins to build device-to-device communication
Send emails, tweets, push notifications, etc.

what to prepare


Hardware: Arduino, Raspberry Pi or other development kits. Because UltiRobot is focused on Arduino, we only cover Arduino related ways.
Smartphone: You need to install Blynk's App software, which is supported on both Apple and Android platforms.

download


Mobile software download

Clicking the following icon will jump to the software market, google play needs to be accessed scientifically due to non-resistance factors. If you do not have this skill, you can go to our network disk to download.https://apps.apple.com/cn/app/blynk-control-arduino-raspberry/id808760481?ls=1https://play.google.com/store/apps/details?id=cc.blynk

Library file download

If the library files will not be installed, click here.

Getting started (based on W5100 simple example)


We will make a project to control the LED connected to the Arduino through the Blynk software on the smartphone.

First, connect the LED to the UNO main control board as shown in the figure below.

APP software part


1. Create a Blynk account

After you download and install the Blynk mobile app, you need to create an account of your own. Be sure to use a real email address when creating an account.

2. Create a new project

After you have created your account, create a new project in your account.

3. Choose your hardware

Select the hardware model you are using

4. Project key

A secret key is a unique identifier for the connection between your phone and your hardware. Each new project generates its own secret key. This key will be automatically sent to your mailbox when you create the project. Click on the device option and select a device you are using.Then you will see the keyNote : Do not share your key with anyone unless you want others to have access to your device. Set the name of your project, click Create, and the project will be generated to generate the secret key. Be sure to check your email.

5. Add plugins

Your project content is currently empty, let's add a button to control our LED. Click anywhere on the interface, and all the optional plugins will pop up. Now we click the button and drag it to the interface position. Each button has its own setting parameters, click the button, you can enter the setting.The most important parameter in the settings is the pin. In the pin sequence, select the pin you are currently connecting the LED to. If your LED is connected to digital pin 8, choose Digital D8.

6. Run the project

When you have finished setting the parameters, click the triangle symbol in the upper right corner, this will turn the project from edit mode to run mode. While in run mode, you can no longer drag and set plugins. You will get a message "Arduino UNO is offline", we will fix this in the next section.

hardware device part


How to use the official example

First you should make sure that you have installed the Blynk library correctly in the Arduino library folder. If not, go back to the previous tutorial to install it. Standard examples will help you quickly connect your hardware to the network. Open the official example from the Arduino compiler, the path is as follows:Let's see an example of Arduino UNO+ Ethernet Shield. (You need UNO and W5100 Ethernet expansion board)

One
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
 
char auth[] = "YourAuthToken";
 
void setup()
{
  Serial.begin(9600); // 定义串口频率
  Blynk.begin(auth);  // 将你的Arduino连接到Blynk云
}
 
void loop()
{
  Blynk.run(); // 所有的运行程序在这里
}

 

modify key

Find this line from the example

One
char auth[] = "YourAuthToken";

Replace the English inside the double quotes with the secret key you received in your email. It might end up looking like this:

One
char auth[] = "f45626c103a94983b469637978b0c78a";

Upload your code to your Arduino board through the compiler, open the serial monitor, and the following information may appear:

One
2
3
4
Blynk v.X.X.X
Your IP is 192.168.0.11
Connecting...
Blynk connected!

Then congratulations, your hardware has successfully connected to the Blynk cloud.

 

Blynking


Go back to your Blynk APP and click the button you set earlier to light up the connected LED on your board.You can keep trying other examples.

We have provided video explanations for the above tutorials: click me to watch.

hardware setup


Arduino via USB (no shield)


If you don't have any expansion boards or communication modules, you can still use Blynk - directly via your USB cable.

Open the Arduino Serial USB example and replace the key with your own.

 

One
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 /*************************************************************
  Download latest Blynk library here:
 
  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.
 
    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app
 
  Blynk library is licensed under MIT license
  This example code is in public domain.
 
 *************************************************************
  =>
  =>          USB HOWTO: http://tiny.cc/BlynkUSB
  =>
 
  Feel free to apply it to any other example. It's simple!
 *************************************************************/
 
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT DebugSerial
 
 
// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX
 
#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
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);
}
 
void loop()
{
  Blynk.run();
}

 

Run the script (already in your Blynk scripts folder).
Windows:My Documents\Arduino\libraries\Blynk\scripts
Mac User$/Documents/Arduino/libraries/Blynk/scripts
On the computer, open the CMD command window and output the path to your blynk-ser.bat script

 

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

 

Run the blynk-ser.bat script program, for example: blynk-ser.bat -c COM4 (COM4 is the port of your arduino main control board, change it according to the actual situation.) Then press Enter. After running, the compiler serial monitor cannot be opened. The following is the information of my windows window:

 

One
2
3
4
5
6
7
8
9
Microsoft Windows [版本 10.0.17763.737]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Users\ultirobot>cd  C:\Program Files (x86)\Arduino\libraries\Blynk\scripts
C:\Program Files (x86)\Arduino\libraries\Blynk\scripts>blynk-ser.bat -c COM7
Connecting device at COM7 to blynk-cloud.com:80...
OpenC0C("\\.\COM7", baud=9600, data=8, parity=no, stop=1) - OK
Connect("blynk-cloud.com", "80") - OK
InOut() START
DSR is OFF

 

At this time, you only need to configure it correctly in your mobile phone software provider, and you can choose arduino for the board model and usb for the connection method. Click to run and you can control it normally.

We have provided video explanations for the above tutorials: click me to watch.

Arduino via 8266 wireless module


The 8266 modules sold in our store can be used without any configuration.
Connect ESP8266 to Arduino UNO, the position of soft serial port can be changed by yourself, the default program is 2, 3, you can also change other ones by yourself, the wiring should be consistent with the program for a while. 8266RX is connected to the main control board TX (soft serial port), and 8266TX is connected to the main control board RX (soft serial port).
Open the Arduino IDE compiler, and open the sample program Blynk → Boards_WiFi → ESP8266_Shield. After opening, you need to modify several places.
Upload the program to the main control board. If the image below appears, it means that the Blynk IoT server has been successfully connected.
video
https://www.bilibili.com/video/BV1aV411d7bY/
Documents
Comments Write