<ESP8266NodeMCU>网络连接问题
在我家的WiFi可以连上,但在学校里无论是WiFi还是手机热点就是连不上。:'(想让各位康康是不是程序问题。
#define BLINKER_WIFI
#define BLINKER_ESP_SMARTCONFIG//采用EspTouch/SmartConfig方式配网
#define BLINKER_DUEROS_SENSOR
#define BLINKER_ALIGENIE_SENSOR//图表库
#include <Stepper.h>//步进电机库
#include <Blinker.h>
#include <dht11.h>
char auth[] = "**************";
BlinkerNumber HUMI("humi"); //定义湿度数据键名
BlinkerNumber TEMP("temp"); //定义温度数据键名
BlinkerButton Button1("feed");//定义喂食按钮
#defineDHT11PIN 4
dht11 DHT11;
#define STEPS 100
Stepper stepper(STEPS, D8, D7, D6, D5);
float humi_read = 0, temp_read = 0;
void heartbeat() //心跳包
{
if (humi_read< 45)
{
HUMI.color("#DC143C");//红
HUMI.unit("%RH(干燥)");
}
else if (humi_read> 75)
{
HUMI.color("#1E90FF");//蓝
HUMI.unit("%RH(湿润)");
}
else
{
HUMI.color("#00DE00");//绿
HUMI.unit("%RH(适宜)");
}
if (temp_read< 15)
{
TEMP.color("#1E90FF");//蓝
TEMP.unit("℃(低温)");
}
else if (temp_read> 30)
{
TEMP.color("#DC143C");//红
TEMP.unit("℃(高温)");
}
else
{
TEMP.color("#00DE00");//绿
TEMP.unit("℃(舒适)");
}
HUMI.print(humi_read ); //给blinker app回传湿度数据
TEMP.print(temp_read ); //给blinker app回传温度数据
}
void button1_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
Serial.println("喂食一次");
stepper.step(2048/14); //4步模式下旋转一周用2048 步
delay(500);
Blinker.vibrate();
}
void setup()
{
Serial.begin(115200);
stepper.setSpeed(90);
pinMode(DHT11PIN, OUTPUT);
BLINKER_DEBUG.stream(Serial);
BLINKER_DEBUG.debugAll();
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin(auth);
Blinker.attachData(dataRead);
Blinker.attachHeartbeat(heartbeat);
BlinkerDuerOS.attachQuery(duerQuery);
BlinkerAliGenie.attachQuery(aligenieQuery);
Button1.attach(button1_callback);
}
void aligenieQuery(int32_t queryCode)
{
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("AliGenie Query All");
BlinkerAliGenie.temp(temp_read);
BlinkerAliGenie.humi(humi_read);
BlinkerAliGenie.print();
break;
case BLINKER_CMD_QUERY_TEMP_NUMBER :
BlinkerAliGenie.temp(temp_read);
BlinkerAliGenie.print();
break;
case BLINKER_CMD_QUERY_HUMI_NUMBER :
BlinkerAliGenie.humi(humi_read);
BlinkerAliGenie.print();
break;
default :
BlinkerAliGenie.temp(20);
BlinkerAliGenie.humi(20);
BlinkerAliGenie.print();
break;
}
}
void duerQuery(int32_t queryCode)
{
BLINKER_LOG("DuerOS Query codes: ", queryCode);
int humi_read_int = humi_read; //去掉湿度浮点
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
}
void loop()
{
Blinker.run();
int chk = DHT11.read(DHT11PIN); //将读取到的值赋给chk
int tem = (float)DHT11.temperature; //将温度值赋值给tem
int hum = (float)DHT11.humidity; //将湿度值赋给hum
if (isnan(hum) || isnan(tem))
{
}
else
{
BLINKER_LOG("湿度: ", hum, " %");
BLINKER_LOG("温度: ", tem, " *C");
humi_read = hum;
temp_read = tem;
}
Blinker.delay(2000);
}
#在这里快速1111回复# 有没有人纠正一下,下载演示一下 esptouch在一些复杂网络环境中,确实可能出现配不上网的问题,可以尝试使用apconfig配网 https://www.arduino.cn/thread-98936-1-1.html
页:
[1]