收藏官网首页
查看: 12792|回复: 2

[问答] 【求助】Arduino无法正常接收/发送数据

2

主题

9

帖子

218

积分

中级会员

Rank: 3Rank: 3

积分
218
跳转到指定楼层
楼主
发表于 2017-10-6 18:46:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
免费使用STM32、APP自动代码生成工具
arduino Nano + esp8266-01 +DHT11 + WS2812 *8位LED
数据无法上传,也无法下达控制……
APP上的传感器数据都无法显示(显示为一个不正确的数据,且不会变化)
开关LED灯也没有反应。
但esp8266和Arduino上的串口指示灯有反应。
我检查过了,不是硬件的问题。
求到底是哪里有问题??


  1. #include "Gizwits.h"
  2. #include <Wire.h>

  3. #include "Adafruit_NeoPixel.h"
  4. #include "dht11.h"
  5. #include "BH1750FVI.h"

  6. Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, 9, NEO_GRB + NEO_KHZ800);

  7. Gizwits myGizwits;

  8. dht11 DHT11;
  9. BH1750FVI LightSensor;

  10. #define DHT11PIN 2
  11. #define ledPin 13


  12. void setup() {
  13.   // put your setup code here, to run once:

  14.   myGizwits.begin();
  15.   pinMode(KEY1, INPUT_PULLUP);
  16.   pinMode(KEY2, INPUT_PULLUP);
  17.   pinMode(ledPin, OUTPUT);


  18.   LightSensor.begin();
  19.   LightSensor.SetAddress(Device_Address_H);//Address 0x5C
  20.   LightSensor.SetMode(Continuous_H_resolution_Mode);

  21.   strip.begin();
  22.   strip.show();

  23. }

  24. void loop() {

  25.   //Configure network
  26.   //if(XXX) //Trigger Condition
  27.   //myGizwits.setBindMode(0x02);  //0x01:Enter AP Mode;0x02:Enter Airlink Mode

  28.   DHT11.read(DHT11PIN);
  29.   float varW_Temp = (float)DHT11.temperature;//Add Sensor Data Collection
  30.   float varW_Humi = (float)DHT11.humidity;//Add Sensor Data Collection
  31.   float  varW_Illu = LightSensor.GetLightIntensity();//Add Sensor Data Collection
  32.   myGizwits.write(VALUE_Temp, varW_Temp);
  33.   myGizwits.write(VALUE_Humi, varW_Humi);
  34.   myGizwits.write(VALUE_Illu, varW_Illu);

  35.   bool varR_Button = 0;
  36.   if (myGizwits.hasBeenSet(EVENT_Button))
  37.   {
  38.     myGizwits.read(EVENT_Button, &varR_Button); //Address for storing data
  39.   }
  40.   if (varR_Button == 1)
  41.   {
  42.     for (int i = 0; i < strip.numPixels(); i++) {
  43.       strip.setPixelColor(i, strip.Color( 200, 200, 200));
  44.       strip.show();
  45.     }
  46.   }
  47.   else
  48.   {
  49.     for (int i = 0; i < strip.numPixels(); i++) {
  50.       strip.setPixelColor(i, strip.Color( 0, 0, 0));
  51.       strip.show();
  52.     }
  53.   }


  54.   //binary datapoint handle
  55.   myGizwits.process();
  56. }
复制代码


2

主题

9

帖子

218

积分

中级会员

Rank: 3Rank: 3

积分
218
沙发
 楼主| 发表于 2017-10-6 23:48:46 | 只看该作者
【已解决】发现原来是更新了数据点,但MCU自动生成的代码是要在网页上输入密匙再次生成的,一直用着旧版的代码  ̄へ ̄……谢谢看过的各位!

致管理员:删帖按钮在哪里?这么简单的问题就不要占版面了吧……

36

主题

308

帖子

70

积分

注册会员

Rank: 2

积分
70
板凳
发表于 2017-10-8 11:26:44 | 只看该作者
没事.留着把帮助更多的人.只要数据点改变了.代码需要自动生成的
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

加入Q群 返回顶部

版权与免责声明 © 2006-2024 Gizwits IoT Technology Co., Ltd. ( 粤ICP备11090211号 )

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