物联网W5100+ArduinoUno +yeeling实现2路开关2路模拟-Arduino中文社区 - Powered by Discuz! Archiver

感动常在 发表于 2014-4-7 22:44

物联网W5100+ArduinoUno +yeeling实现2路开关2路模拟

本帖最后由 感动常在 于 2014-4-7 23:16 编辑

以太网模块W5100,想必大家也都比较熟悉了,本人也买了一块,可惜买回来弄了一下没弄通,接下来便是打入冷宫,直到今天又想起,少不了拉出来摆弄一番,基于现成的物联网平台yeeling实现的,不过首先得注册一个账户,对于我小白来说肚里没啥墨水,最好用现成的也是最省事的,本例将使用yeeling论坛一个叫“亲亲, 哥哥”的坛友所写的库实现,目前该库的作者已经停止维护升级,不过再次表示感谢该作者;库下载地址在这里https://github.com/qinqingege/YeeLinkLib,手机客户端http://www.yeelink.net/developer/doc/9本例所用IDE版本为arduino-1.0.4,编译通过正常使用,就是响应有点慢5秒左右,也希望有能力的大神研究下,怎么让响应快一点,在本着大家帮大家的精神,好了直接上代码
#include <Ethernet.h>
#include <WiFi.h>
#include <SPI.h>
#include <yl_device.h>
#include <yl_w5100_client.h>
#include <yl_wifi_client.h>
#include <yl_messenger.h>
#include <yl_value_data_point.h>
#include <yl_sensor.h>
int LED1=2,LED2=3;
yl_device ardu(4828);//yeeling设备ID
yl_sensor therm(7387, &ardu);//开关1,yeeling传感器ID
yl_sensor therm1(14051, &ardu);//开关2
yl_sensor therm2(7389, &ardu);//AD0,yeeling传感器ID
yl_sensor therm3(14045, &ardu);//AD1
yl_w5100_client client;
yl_messenger messenger(&client, "xxxxxxxxxxxxxxx", "api.yeelink.net");//xx为API KEY

void setup()
{
    Serial.begin(9600);      //for output information
    byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xAA};
    Ethernet.begin(mac);
    pinMode(LED1,OUTPUT);
    pinMode(LED2,OUTPUT);
}
void loop()
{
yl_value_data_point dp;
yl_value_data_point dp1;
therm.single_get(messenger, dp);
therm1.single_get(messenger, dp1);
char led=dp.get_value();
if(led)digitalWrite(LED1,HIGH);
if(!led)digitalWrite(LED1,LOW);
char led1=dp1.get_value();
if(led1)digitalWrite(LED2,HIGH);
if(!led1)digitalWrite(LED2,LOW);
//-----------ADC---------------------
    int v1 = analogRead(A0);
    int v2 = analogRead(A1);
    Serial.println(v1);
    yl_value_data_point dp2(v1);
    yl_value_data_point dp3(v2);
    messenger.connect_yl();
    therm2.post(messenger, dp2, true);
    therm3.post(messenger, dp3, false);
    messenger.flush_stop();
}






_Scroll 发表于 2014-4-8 19:26

Wow cool,尝试下{:soso_e100:}

1033812315 发表于 2015-4-29 00:58

楼主可以留个QQ吗?

明娃子 发表于 2018-9-15 23:34

做好了吗

明娃子 发表于 2018-9-15 23:35

我也说一句 我也试试

jggjh5 发表于 2022-5-4 20:58

https://s6.jpg.cm/2022/05/01/Lx7OBh.png
https://s6.jpg.cm/2022/05/01/Lx7ZOS.png
https://s6.jpg.cm/2022/05/01/LxQIAW.png
https://s6.jpg.cm/2022/05/01/LxQLm2.png
https://s6.jpg.cm/2022/05/01/LxQPTH.png
https://s6.jpg.cm/2022/05/01/LxQqdL.png
https://s6.jpg.cm/2022/05/01/LxQWYf.png
https://s6.jpg.cm/2022/05/01/LxQnCU.png
https://s6.jpg.cm/2022/05/01/LxQ7RO.png
https://s6.jpg.cm/2022/05/01/LxQQ1w.png
https://s6.jpg.cm/2022/05/01/LxQdf8.png
https://s6.jpg.cm/2022/05/01/LxQeOi.png
https://s6.jpg.cm/2022/05/01/LxQ6Ak.png
https://s6.jpg.cm/2022/05/01/LxQVpe.png
https://s6.jpg.cm/2022/05/01/LxQ8Ty.png
https://s6.jpg.cm/2022/05/01/LxQXdr.png
https://s6.jpg.cm/2022/05/01/LxQcr5.png
https://s6.jpg.cm/2022/05/01/LxQUCC.png
https://s6.jpg.cm/2022/05/01/LxQuqt.png
https://s6.jpg.cm/2022/05/01/LxQ1HR.png
https://s6.jpg.cm/2022/05/01/LxQHfz.png
https://s6.jpg.cm/2022/05/01/LxQJZu.png
https://s6.jpg.cm/2022/05/01/LxQNXG.png
https://s6.jpg.cm/2022/05/01/LxQSp4.png
https://s6.jpg.cm/2022/05/01/LxQYaX.png
https://s6.jpg.cm/2022/05/01/LxQsdD.png
https://s6.jpg.cm/2022/05/01/LxQErp.png
https://s6.jpg.cm/2022/05/01/LxQFK6.png
https://s6.jpg.cm/2022/05/01/LxQmqT.png
https://s6.jpg.cm/2022/05/01/LxQpHE.png
https://s6.jpg.cm/2022/05/01/LxQvgQ.png
https://s6.jpg.cm/2022/05/01/LxQwZh.png


https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/28/MTAwMTIyXzE2NTEzODY0ODEzMjU=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/28/MTAwMTIyXzE2NTEzODY0ODk4MTU=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/28/MTAwMTIyXzE2NTEzODY0OTE3NDE=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/28/MTAwMTIyXzE2NTEzODY0OTkyNjI=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/28/MTAwMTIyXzE2NTEzODY1MDU1ODU=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/28/MTAwMTIyXzE2NTEzODY1MTQ0MTM=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/30/MTAwMTIyXzE2NTEzODY2MDg4NTE=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/30/MTAwMTIyXzE2NTEzODY2MDg3Mjg=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/30/MTAwMTIyXzE2NTEzODY2MDg5NjU=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/30/MTAwMTIyXzE2NTEzODY2MTA1ODg=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/30/MTAwMTIyXzE2NTEzODY2MTg1Njk=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/30/MTAwMTIyXzE2NTEzODY2MjMxOTk=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/31/MTAwMTIyXzE2NTEzODY3MTU3NTE=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/32/MTAwMTIyXzE2NTEzODY3MjQ3MTM=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/32/MTAwMTIyXzE2NTEzODY3MjY1MjM=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/32/MTAwMTIyXzE2NTEzODY3MzIwNzM=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/32/MTAwMTIyXzE2NTEzODY3Mzk2NDY=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/32/MTAwMTIyXzE2NTEzODY3NDgxNDM=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/33/MTAwMTIyXzE2NTEzODY4MzU3NDQ=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/34/MTAwMTIyXzE2NTEzODY4NDc4MDc=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/34/MTAwMTIyXzE2NTEzODY4NDg0NDQ=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/34/MTAwMTIyXzE2NTEzODY4NTM2OTE=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/34/MTAwMTIyXzE2NTEzODY4NTg0Nzg=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/34/MTAwMTIyXzE2NTEzODY4NjMxMzY=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/36/MTAwMTIyXzE2NTEzODY5NjQ2Nzk=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/36/MTAwMTIyXzE2NTEzODY5NzA2MzA=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/36/MTAwMTIyXzE2NTEzODY5ODExMjM=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/36/MTAwMTIyXzE2NTEzODY5ODQ3ODU=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/37/MTAwMTIyXzE2NTEzODcwNDQwNjQ=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/37/MTAwMTIyXzE2NTEzODcwNDgyMTA=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/37/MTAwMTIyXzE2NTEzODcwNTQyNzE=.png
https://e3f49eaa46b57.cdn.sohucs.com/2022/5/1/14/37/MTAwMTIyXzE2NTEzODcwNjI1NTk=.png
页: [1]
查看完整版本: 物联网W5100+ArduinoUno +yeeling实现2路开关2路模拟