[Arduino物联网开发实战2]数据反馈-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

楼主: 奈何col

[使用文档] [Arduino物联网开发实战2]数据反馈

  [复制链接]
 楼主| 发表于 2020-5-7 18:55 | 显示全部楼层
huanglecheg 发表于 2020-5-7 17:26
你好,请问Button1.print("on");这个具体是什么意思,开发文档里面写的是发送按键当前的状态(多用于开关模 ...

向app反馈该button组件状态为on
发表于 2020-5-21 18:48 | 显示全部楼层
goodstudy 发表于 2019-4-21 14:38
希望解答一下,多谢了。

LOW不是关灯,是低电平,低电平开灯。
发表于 2020-5-29 18:10 | 显示全部楼层

数据传过去了但是组件没反应怎么回事...
In file included from D:\Arduino\libraries\blinker-library-master\src/BlinkerSerialBLE.h:25:0,

                 from D:\Arduino\libraries\blinker-library-master\src/Blinker.h:21,

                 from C:\Users\Administrator\Desktop\sketch_may29a\sketch_may29a.ino:4:

D:\Arduino\libraries\blinker-library-master\src/Adapters/BlinkerSerial.h: In member function 'virtual char* BlinkerSerial::lastRead()':

D:\Arduino\libraries\blinker-library-master\src/Adapters/BlinkerSerial.h:36:75: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

         char * lastRead()   { if (isFresh) return streamData; else return ""; }

                                                                           ^~

In file included from D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:83:0,

                 from D:\Arduino\libraries\blinker-library-master\src/BlinkerSerialBLE.h:26,

                 from D:\Arduino\libraries\blinker-library-master\src/Blinker.h:21,

                 from C:\Users\Administrator\Desktop\sketch_may29a\sketch_may29a.ino:4:

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h: In member function 'char* BlinkerProtocol::dataParse()':

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h:234:86: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

         char* dataParse()       { if (canParse) return conn->lastRead(); else return ""; }

                                                                                      ^~

In file included from D:\Arduino\libraries\blinker-library-master\src/BlinkerSerialBLE.h:26:0,

                 from D:\Arduino\libraries\blinker-library-master\src/Blinker.h:21,

                 from C:\Users\Administrator\Desktop\sketch_may29a\sketch_may29a.ino:4:

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: At global scope:

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:777:97: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

         BlinkerWidgets_string _BUILTIN_SWITCH = BlinkerWidgets_string(BLINKER_CMD_BUILTIN_SWITCH);

                                                                                                 ^

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_str(uint8_t)':

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:7012:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

     else return "";

                 ^~

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_joy(uint8_t)':

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:7019:21: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

         else return "";

                     ^~

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_rgb(uint8_t)':

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:7026:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

     else return "";

                 ^~

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_int(uint8_t)':

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:7032:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

     else return "";

                 ^~

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_tab(uint8_t)':

D:\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:7038:17: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

     else return "";

                 ^~

C:\Users\Administrator\Desktop\sketch_may29a\sketch_may29a.ino: At global scope:

C:\Users\Administrator\Desktop\sketch_may29a\sketch_may29a.ino:6:26: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

BlinkerNumber HUMI("humi");

                          ^

C:\Users\Administrator\Desktop\sketch_may29a\sketch_may29a.ino:7:26: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

BlinkerNumber TEMP("temp");

                          ^
发表于 2020-6-8 12:21 | 显示全部楼层
谢谢分享,学习了
发表于 2020-7-12 21:31 | 显示全部楼层
这两个的差异是?
  1. #define BLINKER_WIFI
  2. #define BLINKER_MIOT_SENSOR

  3. #include <Blinker.h>

  4. char auth[] = "93******83"; // Blinker APP中添加设备时生成的Secret Key
  5. char ssid[] = "ty****op"; // WIFI名称
  6. char pswd[] = "********"; // WIFI密码

  7. BlinkerNumber HUMI("humi");
  8. BlinkerNumber TEMP("temp");

  9. // Download Adafruit DHT-sensor-library library here:
  10. // https://github.com/adafruit/DHT-sensor-library
  11. #include <DHT.h>

  12. #define DHTPIN 2

  13. #define DHTTYPE DHT11   // DHT 11
  14. //#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
  15. //#define DHTTYPE DHT21   // DHT 21 (AM2301)

  16. DHT dht(DHTPIN, DHTTYPE);

  17. uint32_t read_time = 0;

  18. float humi_read, temp_read;

  19. void miotQuery(int32_t queryCode)
  20. {
  21.     BLINKER_LOG("MIOT Query codes: ", queryCode);

  22.     switch (queryCode)
  23.     {
  24.         case BLINKER_CMD_QUERY_ALL_NUMBER :
  25.             BLINKER_LOG("MIOT Query All");
  26.             BlinkerMIOT.temp(20);
  27.             BlinkerMIOT.humi(20);
  28.             BlinkerMIOT.pm25(20);
  29.             BlinkerMIOT.co2(20);
  30.             BlinkerMIOT.print();
  31.             break;
  32.         default :
  33.             BlinkerMIOT.temp(20);
  34.             BlinkerMIOT.humi(20);
  35.             BlinkerMIOT.pm25(20);
  36.             BlinkerMIOT.co2(20);
  37.             BlinkerMIOT.print();
  38.             break;
  39.     }
  40. }

  41. void dataRead(const String & data)
  42. {
  43.     BLINKER_LOG("Blinker readString: ", data);

  44.     Blinker.vibrate();
  45.    
  46.     uint32_t BlinkerTime = millis();
  47.    
  48.     Blinker.print("millis", BlinkerTime);
  49. }

  50. void heartbeat()
  51. {
  52.     HUMI.print(humi_read);
  53.     TEMP.print(temp_read);
  54. }

  55. void setup()
  56. {
  57.     Serial.begin(115200);
  58.     BLINKER_DEBUG.stream(Serial);

  59.     pinMode(LED_BUILTIN, OUTPUT);
  60.     digitalWrite(LED_BUILTIN, LOW);

  61.     Blinker.begin(auth, ssid, pswd);
  62.     Blinker.attachData(dataRead);

  63.     BlinkerMIOT.attachQuery(miotQuery);

  64.     Blinker.attachHeartbeat(heartbeat);
  65.    
  66.     dht.begin();
  67. }

  68. void loop()
  69. {
  70.     Blinker.run();
  71.    
  72.     if (read_time == 0 || (millis() - read_time) >= 2000)
  73.     {
  74.         read_time = millis();

  75.         float h = dht.readHumidity();
  76.         float t = dht.readTemperature();        

  77.         if (isnan(h) || isnan(t)) {
  78.             BLINKER_LOG("Failed to read from DHT sensor!");
  79.             return;
  80.         }

  81.         float hic = dht.computeHeatIndex(t, h, false);

  82.         humi_read = h;
  83.         temp_read = t;

  84.         BLINKER_LOG("Humidity: ", h, " %");
  85.         BLINKER_LOG("Temperature: ", t, " *C");
  86.         BLINKER_LOG("Heat index: ", hic, " *C");
  87.     }
  88. }
复制代码
发表于 2020-7-12 21:32 | 显示全部楼层
molun 发表于 2020-7-12 21:31
这两个的差异是?

这个小爱同学查询不到是什么情况?
发表于 2020-7-12 21:33 | 显示全部楼层
  1.     else if (state == BLINKER_CMD_ON) {
  2.         BLINKER_LOG("Toggle on!");

  3.         Button1.icon("fal fa-light-switch-on");
  4.         Button1.color("#0000FF");
  5.         Button1.text("ON");
  6.         Button1.print("on");
复制代码

  1. // 心跳包函数
  2. void heartbeat() {
  3.     Button1.icon("fas fa-lightbulb");
  4.     Button1.color("#fddb00");
  5.     Button1.text("关灯","打开啦");
  6.     Button1.print("on");
  7. }
复制代码



这两地方效果有啥不一样?

点评

第一个是响应开关动作,第二个是响应心跳查询  详情 回复 发表于 2020-7-12 22:36
 楼主| 发表于 2020-7-12 22:36 | 显示全部楼层
molun 发表于 2020-7-12 21:33
这两地方效果有啥不一样?

第一个是响应开关动作,第二个是响应心跳查询
发表于 2020-7-12 23:11 | 显示全部楼层
奈何col 发表于 2020-7-12 22:36
第一个是响应开关动作,第二个是响应心跳查询

感谢解答
发表于 2020-7-13 18:24 | 显示全部楼层
楼主,没加心跳包可以,加了之后没反应

点评

肯定是你写错了,看调试信息  详情 回复 发表于 2020-7-13 19:58
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-12-1 01:52 , Processed in 0.114628 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表