友情提示:680元/半年,儿童学编程,就上码丁实验室。
云端
你将学到什么
你将学到使用dweet-esp库向dweet.io发送数据
需要准备什么
电脑、wemos开发板一块
安装库
库所在网址
网址:https://github.com/gamo256/dweet-esp
下载zip库文件
使用arduino IDE安装zip库
该库依赖另外一个库:
-
ArduinoJson library
安装ArduinoJson库
发送数据
发送数据
文字代码:
#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);
}
获取数据
获取数据
文字代码:
#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);
}
串口显示获取到的数据
欢迎转发评论!