blinker配网怎么用,为啥搜不到设备
下面是代码,blinker官网说20s后为联网会进入待配网状态,但是我APP显示搜索不到设备,#include <Wire.h>
#include <DHT.h>
#define BLINKER_WIFI
#include <Blinker.h>
#define ADDRESS_BH1750FVI 0x23 //ADDR="L" for this module
#define ONE_TIME_H_RESOLUTION_MODE 0x20
#define BLINKER_ESP_SMARTCONFIG
byte highByte = 0;
byte lowByte = 0;
char auth[] = "de1d2652e54c";
char ssid[] = ""; //你的WiFi热点名称
char pswd[] = "12345679"; //你的WiFi密码
unsigned int sensorOut = 0;
unsigned int illuminance = 0;
BlinkerButton f5("f5");
BlinkerNumber HUMI("humi");
BlinkerNumber TEMP("temp");
BlinkerNumber SMS ("SMS");
BlinkerNumber sun ("sun");
#define DHTPIN D4
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
float humi_read = 0, temp_read = 0,SMS_read=0,sun_read=0;
//void f5_callback(const String&f5){
//}
void heartbeat()
{
SMS.print(SMS_read);
HUMI.print(humi_read);
TEMP.print(temp_read);
sun.print(sun_read);
}
void dataStorage()
{
Blinker.dataStorage("temp", temp_read);
Blinker.dataStorage("HUMI", humi_read);
Blinker.dataStorage("SMS", SMS_read);
Blinker.dataStorage("sun", sun_read);
}
void wechat_h()
{
Blinker.wechat("温度:",temp_read," *C");
Blinker.wechat("湿度:",humi_read,"%");
Blinker.wechat("光照:",sun_read,"lux");
Blinker.wechat("土壤湿度:",SMS_read);
Blinker.delay(10000);
}
void setup()
{
Wire.begin();
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
BLINKER_DEBUG.debugAll();
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin(auth, ssid, pswd);
Blinker.attachHeartbeat(heartbeat);
Blinker.attachDataStorage(dataStorage);
dht.begin();
Blinker.attachHeartbeat(wechat_h);
Blinker.wechat("220v高压已上线!!!");
}
void loop()
{
Blinker.run();
Wire.beginTransmission(ADDRESS_BH1750FVI); //"notify" the matching device
Wire.write(ONE_TIME_H_RESOLUTION_MODE); //set operation mode
Wire.endTransmission();
Blinker.delay(180);
Wire.requestFrom(ADDRESS_BH1750FVI, 2); //ask Arduino to read back 2 bytes from the sensor
highByte = Wire.read();// get the high byte
lowByte = Wire.read(); // get the low byte
sensorOut = (highByte<<8)|lowByte;
illuminance = sensorOut/1.2;
Serial.print(illuminance);
Serial.println(" lux");
float SMS =analogRead(0);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t))
{
BLINKER_LOG("Failed to read from DHT sensor!");
}
else
{
BLINKER_LOG("sun",illuminance,"lux");
BLINKER_LOG("soil moisture",SMS,"%");
BLINKER_LOG("Humidity: ", h, " %");
BLINKER_LOG("Temperature: ", t, " *C");
humi_read = h;
temp_read = t;
SMS_read=SMS;
sun_read=illuminance;
}
Blinker.delay(2000);
}
而且串口监视器根联网下情况一样 通过手机APP 开发者>开发工具>EspTouch 进行配网
在进行配网前,你需要确保 设备端已经烧写了带有EspTouch功能的程序, keliyuan 发表于 2020-4-4 19:34
通过手机APP 开发者>开发工具>EspTouch 进行配网
在进行配网前,你需要确保 设备端已经烧写了带有EspTouch ...
你看一下我代码第七行添加那个smartconfig宏定义了,而且esptouch配网时无法发现设备 我用是正常的。
我说你没定义了吗?我只是提醒有类似问题的注意。
你按照上面操作就能联网,不操作就不能联网,就这么简单。 没看完示例,直接硬套,第11,12,60行就错了,配网是不用在代码里自己写WiFi的名称和密码的 你发送微信的方法也不i对,一下子就会触发限制了 liuchengqi1017 发表于 2020-4-4 19:36
你看一下我代码第七行添加那个smartconfig宏定义了,而且esptouch配网时无法发现设备 ...
看下自带的esptouch例程 多谢各位大佬指点
页:
[1]