arduino - 为什么 ESP8266 模块可以连接到我的 iPhone 热点,但无法连接到我的家庭 wifi?
问题描述
这是扫描WiFi网络并连接到WiFi的代码。
#include<ESP8266WiFi.h>
#include<Arduino.h>
#define USER_SERIAL Serial
const char* ssid = "*****";
const char* pass = "*****";
void setup() {
USER_SERIAL.begin(115200);
searchWifi();
WiFi.mode(WIFI_STA);
WiFi.hostname("ESP-host");
WiFi.setPhyMode(WIFI_PHY_MODE_11G);
WiFi.enableInsecureWEP(true);
WiFi.begin(ssid,pass);
while(WiFi.status() != WL_CONNECTED){
USER_SERIAL.print(".");
delay(1000);
}
USER_SERIAL.print("");
USER_SERIAL.println("WiFi connected");
USER_SERIAL.print("IP Address: ");
USER_SERIAL.println(WiFi.localIP());
WiFi.setAutoReconnect(true);
WiFi.persistent(true);
}
void loop() {
// put your main code here, to run repeatedly:
}
void searchWifi(){
int numberOfNetwork = WiFi.scanNetworks();
USER_SERIAL.println("-----");
for ( int i = 0; i< numberOfNetwork;i++){
USER_SERIAL.print("Network name: ");
USER_SERIAL.println(WiFi.SSID(i));
USER_SERIAL.print("Signal Strength: ");
USER_SERIAL.println(WiFi.RSSI(i));
USER_SERIAL.println("-------------");
}
}
我的 WiFi 处于 11bgn 混合模式,这意味着我的连接允许连接所有设备。此外,我的 WiFi 路由器也有 2.4GHz 频率,这是 ESP8266 允许连接的要求。
解决方案
推荐阅读
- r - 在 R 中,如何使用 gtsummary (或任何其他 r 包)制作一个包含五个二元因子的列联表
- c++ - 如何避免这个讨厌的概念陷阱(取决于顺序)
- string - XSL 循环通过故障块并将值附加到字符串而不使用模板
- python - 如何使用包含在一行中所有括号内的值创建一个新列?
- c++ - Direct2D 自定义效果 RegisterEffectFromString 不起作用
- swift - 如何在 for loop Swift 中发送响应 POST urlsession 任务?
- node.js - AWS Lambda 层中的 AccessDenied 可执行文件 - FFMPEG
- c# - 当代码在运行时更新时,将 Observable 集合绑定到组合框有效。但是在再次构建解决方案后它不起作用
- reactjs - React-rainbow 组件颜色主题
- bash - Bash - 如何将行转换为单行引用值