最新消息:680元/半年,推荐全网最具性价比的一站式编程学习平台码丁实验室

arduino WiFi开发(5)使用dweet-esp库向云端发送数据

Arduino 少儿编程 2286浏览 0评论

友情提示:680元/半年,儿童学编程,就上码丁实验室

arduino WiFi开发(5)使用dweet-esp库向云端发送数据

云端


你将学到什么

你将学到使用dweet-esp库向dweet.io发送数据

需要准备什么

电脑、wemos开发板一块

安装库

arduino WiFi开发(5)使用dweet-esp库向云端发送数据

库所在网址

网址:https://github.com/gamo256/dweet-esp

arduino WiFi开发(5)使用dweet-esp库向云端发送数据

下载zip库文件

arduino WiFi开发(5)使用dweet-esp库向云端发送数据

使用arduino IDE安装zip库

该库依赖另外一个库:

  • ArduinoJson library

arduino WiFi开发(5)使用dweet-esp库向云端发送数据

安装ArduinoJson库

发送数据

arduino WiFi开发(5)使用dweet-esp库向云端发送数据

发送数据

文字代码:

#include “dweetESP8266.h”

#define THIG_NAME  “my_test_dweetESP_thing”  // Put here your thing name

#define WIFISSID “your-WiFi”

#define PASSWORD “your-password”

dweet client;

void setup(){

    Serial.begin(115200);

    delay(10);

    client.wifiConnection(WIFISSID, PASSWORD);

}

void loop(){

    String val = String(random(100));

    client.add(“randomNum”, val); // specifies the args of type “String”

    client.sendAll(THIG_NAME);

}

获取数据

arduino WiFi开发(5)使用dweet-esp库向云端发送数据

获取数据

文字代码:

#include “dweetESP8266.h”

#define THIG_NAME  “my_test_dweetESP_thing”  // Put here your thing name

#define WIFISSID “your-wifi”

#define PASSWORD “your-password”

dweet client;

void setup() {

    Serial.begin(115200);

    delay(10);

    client.wifiConnection(WIFISSID, PASSWORD);

}

void loop() {

    // specifies the args of type “String”

    String value = client.getDweet(THIG_NAME, “randomNum”);

    Serial.println(value);

}

arduino WiFi开发(5)使用dweet-esp库向云端发送数据

串口显示获取到的数据


欢迎转发评论!


您必须 登录 才能发表评论!