WiFiManager for ESP8266配网实例

Posted perseverance52

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WiFiManager for ESP8266配网实例相关的知识,希望对你有一定的参考价值。

WiFiManager for ESP8266配网实例

  • 所使用的库
#include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>         //https://github.com/tzapu/WiFiManager
  • WiFiManager库的地址:GitHub
  • 不需要手动写配置页面。省去了html代码的编写。

实例程序代码

#include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino

//needed for library
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>         //https://github.com/tzapu/WiFiManager


void setup() {
    // put your setup code here, to run once:
    Serial.begin(115200);

    //WiFiManager
    //Local intialization. Once its business is done, there is no need to keep it around
    WiFiManager wifiManager;
    //reset saved settings
    //wifiManager.resetSettings();
    
    //set custom ip for portal
    //wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));

    //fetches ssid and pass from eeprom and tries to connect
    //if it does not connect it starts an access point with the specified name
    //here  "AutoConnectAP"
    //and goes into a blocking loop awaiting configuration
    wifiManager.autoConnect("AutoConnectAP");
    //or use this for auto generated name ESP + ChipID
    //wifiManager.autoConnect();

    
    //if you get here you have connected to the WiFi
    Serial.println("connected...yeey :)");
}

void loop() {
    // put your main code here, to run repeatedly:
    
}
  • 配网无线AP
  • 连接吼吼自动跳转到配网页面:192.168.4.1

  • 查看设备信息

以上是关于WiFiManager for ESP8266配网实例的主要内容,如果未能解决你的问题,请参考以下文章

ESP8266Web配网+获取网络时间

ESP8266Web配网 + 获取网络时间

ESP8266Web配网+HTTPClient库获取一言网络数据+1.3“OLED显示

ESP8266Web配网+HTTPClient库获取一言网络数据

Arduino ESP8266 ESP8266WiFiMulti配网库实例

ESP8266+微信配网smartconfig,esp32可用