最新消息:码丁实验室,一站式儿童编程学习产品,寻地方代理合作共赢,微信联系:leon121393608。

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

Arduino 少儿编程 2309浏览 0评论

码丁实验室,一站式儿童编程学习产品,寻地方代理合作共赢,微信联系:leon121393608。

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库向云端发送数据

串口显示获取到的数据


欢迎转发评论!


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