|
是arduino Nano + esp8266-01 +DHT11 + WS2812 *8位LED
数据无法上传,也无法下达控制……
APP上的传感器数据都无法显示(显示为一个不正确的数据,且不会变化)
开关LED灯也没有反应。
但esp8266和Arduino上的串口指示灯有反应。
我检查过了,不是硬件的问题。
求到底是哪里有问题??
- #include "Gizwits.h"
- #include <Wire.h>
- #include "Adafruit_NeoPixel.h"
- #include "dht11.h"
- #include "BH1750FVI.h"
- Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, 9, NEO_GRB + NEO_KHZ800);
- Gizwits myGizwits;
- dht11 DHT11;
- BH1750FVI LightSensor;
- #define DHT11PIN 2
- #define ledPin 13
- void setup() {
- // put your setup code here, to run once:
- myGizwits.begin();
- pinMode(KEY1, INPUT_PULLUP);
- pinMode(KEY2, INPUT_PULLUP);
- pinMode(ledPin, OUTPUT);
- LightSensor.begin();
- LightSensor.SetAddress(Device_Address_H);//Address 0x5C
- LightSensor.SetMode(Continuous_H_resolution_Mode);
- strip.begin();
- strip.show();
- }
- void loop() {
- //Configure network
- //if(XXX) //Trigger Condition
- //myGizwits.setBindMode(0x02); //0x01:Enter AP Mode;0x02:Enter Airlink Mode
- DHT11.read(DHT11PIN);
- float varW_Temp = (float)DHT11.temperature;//Add Sensor Data Collection
- float varW_Humi = (float)DHT11.humidity;//Add Sensor Data Collection
- float varW_Illu = LightSensor.GetLightIntensity();//Add Sensor Data Collection
- myGizwits.write(VALUE_Temp, varW_Temp);
- myGizwits.write(VALUE_Humi, varW_Humi);
- myGizwits.write(VALUE_Illu, varW_Illu);
- bool varR_Button = 0;
- if (myGizwits.hasBeenSet(EVENT_Button))
- {
- myGizwits.read(EVENT_Button, &varR_Button); //Address for storing data
- }
- if (varR_Button == 1)
- {
- for (int i = 0; i < strip.numPixels(); i++) {
- strip.setPixelColor(i, strip.Color( 200, 200, 200));
- strip.show();
- }
- }
- else
- {
- for (int i = 0; i < strip.numPixels(); i++) {
- strip.setPixelColor(i, strip.Color( 0, 0, 0));
- strip.show();
- }
- }
- //binary datapoint handle
- myGizwits.process();
- }
复制代码
|
|