TA的每日心情 | 奋斗 2023-7-6 08:48 |
---|
签到天数: 169 天 连续签到: 1 天 [LV.7]常住居民III
|
上一篇开发板的本地开发环境搭建完成。
但是这是一个物联网开发板,联网功能是首要的。
安装wifimanager库
file:///C:UsersADMINI~1AppDataLocalTempmsohtml1 1clip_image002.jpg输入如下和程序。
#include <esp8266wifi.h> //<a href="https://github.com/esp8266/Arduino">https://github.com/esp8266/Arduino</a> //needed for library#include <dnsserver.h>#include <esp8266webserver.h>#include <wifimanager.h> //<a href="https://github.com/tzapu/WiFiManager">https://github.com/tzapu/WiFiManager</a> 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("LinkNodeAP"); //or use this for auto generated name ESP + ChipID //wifiManager.autoConnect(); //if you get here you have connected to the WiFi Serial.println("connected... ");} void loop() { // put your main code here, to run repeatedly:}</wifimanager.h></esp8266webserver.h></dnsserver.h></esp8266wifi.h>下载的开发板
串口输出
使用手机登录到开发板产生的热点。
输入网络地址:10.0.1.1
选择Configure WiFi,选择一个无线进行连接。
连接后会有如下的网页
此时,网络的密码也已经保存了,再次会自动连接上的。
如果打开发串口,串口会输出你开发板的IP地址的。
|
|