Вы находитесь на странице: 1из 45

http://docs.blynk.

cc/

1 de 45 21/04/2016 20:23
http://docs.blynk.cc/

2 de 45 21/04/2016 20:23
http://docs.blynk.cc/

3 de 45 21/04/2016 20:23
http://docs.blynk.cc/

4 de 45 21/04/2016 20:23
http://docs.blynk.cc/

5 de 45 21/04/2016 20:23
http://docs.blynk.cc/

6 de 45 21/04/2016 20:23
http://docs.blynk.cc/

#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...
}

char auth[] = "YourAuthToken";

char auth[] = "f45626c103a94983b469637978b0c78a";

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

7 de 45 21/04/2016 20:23
http://docs.blynk.cc/

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

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


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

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

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

/scripts

8 de 45 21/04/2016 20:23
http://docs.blynk.cc/

blynk-ser.bat blynk-ser.bat -c COM4

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

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

sudo

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

[ Press Ctrl+C to exit ]


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

/dev/tty.usbmodem1451

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

Resetting device /dev/tty.usbmodem1451...


Connecting: GOPEN:/dev/tty.usbmodem1451,raw,echo=0,clocal=1,cs8,nonblock=1,ixoff=0,ixon=0,ispe
2015/10/03 00:29:45 socat[30438.2046857984] N opening character device "/dev/tty.usbmodem1451"
2015/10/03 00:29:45 socat[30438.2046857984] N opening connection to LEN=16 AF=2 45.55.195.102:
2015/10/03 00:29:45 socat[30438.2046857984] N successfully connected from local address LEN=16
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 with FDs [3,3] and [

```
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
```

9 de 45 21/04/2016 20:23
http://docs.blynk.cc/

/etc/rc.local

node full_path_to_your_script.js <Auth Token>

01_PARTICLE.INO

10 de 45 21/04/2016 20:23
http://docs.blynk.cc/

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

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


{
int pinData = param.asInt();
}

1 0

11 de 45 21/04/2016 20:23
http://docs.blynk.cc/

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
}

BLYNK_READ(V5) // Widget in the app READs Virtal Pin V5 with the certain frequency
{
// This command writes Arduino's uptime in seconds to Virtual Pin V5
Blynk.virtualWrite(5, millis() / 1000);

12 de 45 21/04/2016 20:23
http://docs.blynk.cc/

#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h> // here is the SimpleTimer library

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

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

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

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

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(); // SimpleTimer is working
}

13 de 45 21/04/2016 20:23
http://docs.blynk.cc/

BLYNK_CONNECTED() {
if (isFirstConnect) {
Blynk.syncAll();
}
}

Blynk.syncAll()

Blynk.syncVirtual(pin)

Blynk.virtualWrite

Blynk.virtualWrite(V1, HIGH)

Blynk.virtualWrite Blynk.* void loop()

delay()

14 de 45 21/04/2016 20:23
http://docs.blynk.cc/

15 de 45 21/04/2016 20:23
http://docs.blynk.cc/

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

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
}

16 de 45 21/04/2016 20:23
http://docs.blynk.cc/

17 de 45 21/04/2016 20:23
http://docs.blynk.cc/

18 de 45 21/04/2016 20:23
http://docs.blynk.cc/

/pin/

/pin./

/pin.#/

/pin.##/

19 de 45 21/04/2016 20:23
http://docs.blynk.cc/

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


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

WidgetLED led2(2);
led2.setValue(127); //set brightness of LED to 50%.

20 de 45 21/04/2016 20:23
http://docs.blynk.cc/

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

lcd.clear();

/pin/

21 de 45 21/04/2016 20:23
http://docs.blynk.cc/

/pin.##/

6h
1w
3m

1h 6h 1d
1w 1m 3m

22 de 45 21/04/2016 20:23
http://docs.blynk.cc/

terminal.print();
terminal.flush();

23 de 45 21/04/2016 20:23
http://docs.blynk.cc/

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

24 de 45 21/04/2016 20:23
http://docs.blynk.cc/

Blynk.email("my_email@example.com", "Subject", "Your message goes here");

25 de 45 21/04/2016 20:23
http://docs.blynk.cc/

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

26 de 45 21/04/2016 20:23
http://docs.blynk.cc/

WidgetBridge bridge1(V1); //Bridge widget on virtual pin 1


...
void setup() {
Blynk.begin(...);
while (Blynk.connect() == false) {
// Wait until Blynk is connected
}
bridge1.digitalWrite(9, HIGH);
bridge1.analogWrite(10, 123);
bridge1.virtualWrite(V1, "hello");
bridge1.virtualWrite(V2, "value1", "value2", "value3");
}

BLYNK_CONNECTED() {
bridge1.setAuthToken("OtherAuthToken");
}

A0, A1, A2 ...


bridge.virtualWrite
Blynk.virtualWrite

27 de 45 21/04/2016 20:23
http://docs.blynk.cc/

28 de 45 21/04/2016 20:23
http://docs.blynk.cc/

29 de 45 21/04/2016 20:23
http://docs.blynk.cc/

30 de 45 21/04/2016 20:23
http://docs.blynk.cc/

31 de 45 21/04/2016 20:23
http://docs.blynk.cc/

Connected to blynk-cloud.com.

delay() loop()

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

32 de 45 21/04/2016 20:23
http://docs.blynk.cc/

Blynk.virtualWrite void loop

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

delay()

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


#define BLYNK_PRINT Serial

void setup()

Serial.begin(9600);

./blynk-ser.sh -f SSL

--cert

33 de 45 21/04/2016 20:23
http://docs.blynk.cc/

-f SSL

./blynk-ser.sh -t TCP

34 de 45 21/04/2016 20:23
http://docs.blynk.cc/

java -version
Output: java version "1.8.0_40"

.jar

cd Users/User/Blynk/Server

java -jar server-0.15.3.jar -dataFolder /path

./logs/blynk.log

sudo apt-get install oracle-java8-jdk

java -version
Output: java version "1.8.0_40"

wget "https://github.com/blynkkk/blynk-server/releases/download/v0.15.3/server-0.15.3.jar"

hardware port 8442 application port 8443

java -jar server-0.15.3.jar -dataFolder /home/pi/Blynk

./logs
/blynk.log file.

java -jar /home/pi/server-0.15.3.jar -dataFolder /home/pi/Blynk &

crontab -e

@reboot java -jar /home/pi/server-0.15.3.jar -dataFolder /home/pi/Blynk &

35 de 45 21/04/2016 20:23
http://docs.blynk.cc/

ps -aux | grep java

username 10539 1.0 12.1 3325808 428948 pts/76 Sl Jan22 9:11 java -jar server-0.15.3.j

kill 10539

Blynk.begin(auth);

Blynk.begin(auth, "your_host"); //or


Blynk.begin(auth, IPAddress(xxx,xxx,xxx,xxx));

Blynk.begin(auth, SSID, pass));

Blynk.begin(auth, SSID, pass, "your_host"); //or


Blynk.begin(auth, SSID, pass, IPAddress(XXX,XXX,XXX,XXX));

36 de 45 21/04/2016 20:23
http://docs.blynk.cc/

var blynk = new Blynk.Blynk(AUTH, options= {addr:"xxx.xxx.xxx.xxx"});

blynk-ser.sh -s

./blynk-ser.sh -s you_host_or_IP

app.ssl.port=8443

server.ssl.cert=./server_embedded.crt
server.ssl.key=./server_embedded.pem
server.ssl.key.pass=pupkin123

hardware.default.port=8442

https.port=7443

http.port=8080

data.folder=/tmp/blynk

logs.folder=./logs

log.level=trace

user.dashboard.max.limit=10

37 de 45 21/04/2016 20:23
http://docs.blynk.cc/

user.message.quota.limit.exceeded.warning.period=60000

user.profile.max.size=128

notifications.queue.limit=10000

profile.save.worker.period=60000

app.socket.idle.timeout=600

hard.socket.idle.timeout=15

enable.raw.data.store=true

https://your_ip:7443/admin

admin.rootPath=/admin

38 de 45 21/04/2016 20:23
http://docs.blynk.cc/

allowed.users.list=allowed1@gmail.com,allowed2@gmail.com

mail.smtp.auth=true
mail.smtp.starttls.enable=true
mail.smtp.host=smtp.gmail.com
mail.smtp.port=587
mail.smtp.username=YOUR_EMAIL_HERE
mail.smtp.password=YOUR_EMAIL_PASS_HERE

Blynk.virtualWrite()

dashBoardId_pin.csv

data/1_v5.csv

value,timestamp

10,1438022081332

openssl genrsa -out server.key 2048

39 de 45 21/04/2016 20:23
http://docs.blynk.cc/

openssl x509 -req -days 1825 -in server.csr -signkey server.key -out server.crt

openssl pkcs8 -topk8 -inform PEM -outform PEM -in server.key -out server.pem

sudo apt-add-repository ppa:webupd8team/java


sudo apt-get update
sudo apt-get install oracle-java8-installer

Blynk.begin()

Blynk.begin(auth, ...);

Blynk.config(auth);

Blynk.config(auth, server, port);

connectWiFi

Blynk.connectWiFi(ssid, pass)

40 de 45 21/04/2016 20:23
http://docs.blynk.cc/

# This functions will keep connecting to Blynk server. Default timeout is 30 seconds
bool result = Blynk.connect();
bool result = Blynk.connect(timeout);

Blynk.disconnect();

bool result = Blynk.connected();

Blynk.begin(...) Blynk.config(...)
Blynk.run() Blynk.connect()

Blynk.disconnect()

void loop() {}

Blynk.run()
BLYNK_READ BLYNK_WRITE

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

Blynk.virtualWrite(pin, value)
BLYNK_WRITE(vPIN)

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

41 de 45 21/04/2016 20:23
http://docs.blynk.cc/

param.getBuffer()
param.getLength()

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

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

// Send float
Blynk.virtualWrite(pin, 12.34);

// Send multiple values (up to 4) as an array


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

// Send RAW data


Blynk.virtualWriteBinary(pin, buffer, length);

virtualWrite

BLYNK_WRITE

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();
}

BLYNK_READ
Blynk.virtualWrite

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

BLYNK_WRITE

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

BLYNK_WRITE

BLYNK_READ_DEFAULT()

42 de 45 21/04/2016 20:23
http://docs.blynk.cc/

BLYNK_CONNECTED() {
// Your code here
}

BLYNK_CONNECTED() {
if (isFirstConnect) {
Blynk.syncAll();
}
}

BLYNK_WRITE

Blynk.syncVirtual(V0);

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

Serial.begin(9600);

BLYNK_DEBUG

BLYNK_PRINT BLYNK_LOG
printf

43 de 45 21/04/2016 20:23
http://docs.blynk.cc/

44 de 45 21/04/2016 20:23
http://docs.blynk.cc/

45 de 45 21/04/2016 20:23

Вам также может понравиться