lauren 发表于 2014-6-24 19:45:16

yeelink与WIFI Shield v3递增数数据上传测试

用Grey大神发的帖子做的递增数wifi数据上传样例。Grey大神教程的连接:https://www.dfrobot.com.cn/commun ... viewthread&tid=2285

挺好用的,很好用的教程,配合上yeelink官方的一些配置信息很快的就能跑通。不过在通过手机配置路由器设置和外网ip设定,完成后,切断手机连接并且将V3扩展板上的开关切到Arduino一边,才能让系统正常工作。这个小细节需要注意一下。这点其实在其他小伙伴的帖子里面也有提到:https://mc.dfrobot.com.cn/forum.php?mod=viewthread&tid=2516&extra=page%3D1





这是我在yeelink上上传的递增数,不过,通过递增数的测试可以发现,yeelink服务器的采样率在10s,样例程序用了2s推送一个数据的形式往服务器上推递增数。硬件推送速率比服务器保存数据的速率高,所以,保存的实际有意义的数值,只有0,5,10,15,20.....其他数据全部都会被服务器滤掉。所以硬件节点端推送速率比10s长会比较合适!


以下是基于Grey大神的样例改的自己的yeelink,递增数样例=。=


void setup() {
Serial.begin(115200);
pinMode(13,OUTPUT);
}
int randomValue = 0;
void loop() {
if(randomValue < 255)randomValue ++;
else randomValue = 0;
//Serial.println(sensorValue, DEC);
digitalWrite(13,HIGH);
Serial.println("POST /v1.0/device/9351/sensor/19412/datapoints HTTP/1.1"); //“/device/4290/sensor/9970/”device,sensor 后面的数值用你自己的替代
Serial.println("Host: api.yeelink.net");
Serial.print("Accept: *");
Serial.print("/");
Serial.println("*");
Serial.print("U-ApiKey: ");
Serial.println("2400c0117d8c58b363f1b6e03132a9ee");   // 此处用你的APIKEY替代
Serial.print("Content-Length: ");
int thisLength = 10 + getLength(randomValue);
Serial.println(thisLength);   
Serial.println("Content-Type: application/x-www-form-urlencoded");
Serial.println("Connection: close");
Serial.println();
Serial.print("{\"value\":");
Serial.print(randomValue);
Serial.println("}");
delay(1000);
digitalWrite(13,LOW);
delay(1000);
}

int getLength(int someValue) {
// there's at least one byte:
int digits = 1;
// continually divide the value by ten,
// adding one to the digit count for each
// time you divide, until you're at 0:
int dividend = someValue /10;
while (dividend > 0) {
    dividend = dividend /10;
    digits++;
}
// return the number of digits:
return digits;
}

Grey 发表于 2014-6-25 10:02:56

确实如此,yeelink官网给的也是10s一次的样例,但对于某些设备,采样频率太低了

lauren 发表于 2014-6-25 15:49:14

Grey 发表于 2014-6-25 10:02
确实如此,yeelink官网给的也是10s一次的样例,但对于某些设备,采样频率太低了 ...

乐联和其他家的物联网呢,也是一样的吗?。

Grey 发表于 2014-6-25 17:15:52

本帖最后由 Grey 于 2014-6-25 17:30 编辑

lauren 发表于 2014-6-25 15:49
乐联和其他家的物联网呢,也是一样的吗?。
没有正式试过乐联,看过库,大同小异,上传的方式都一样,从样例上来看,采样率应该比yeelink高,毕竟是收费的

him 发表于 2015-1-22 11:12:32

为什么我的数据无法传到yeelink呢?

lauren 发表于 2015-1-22 13:46:00

him 发表于 2015-1-22 11:12
为什么我的数据无法传到yeelink呢?

你第一次玩WIFI吗?这个问题太模糊了,要看你具体的配置,代码,和硬件情况了。原因可能有很多,能分享下你的项目和现在的东西吗?比如照片和你用的源码什么的,这样别人才有可能帮你哈

johnny_87 发表于 2015-1-26 15:27:40

有没有通过wifi模块从yeelink上查询数据的样例
页: [1]
查看完整版本: yeelink与WIFI Shield v3递增数数据上传测试