You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何关闭搭载ESP8266的D1 WiFi开发板创建的热点?

How to Close ESP8266 SoftAP Hotspot Properly

Hey there! I get it—you've set up a SoftAP on your ESP8266 D1 WiFi board using the ESP8266WiFi library, but trying to shut it down with serverWF.close() or serverWF.stop() isn't working. Let's clear up why that's happening and fix it right away.

The Problem with Your Current Approach

First off, serverWF is a WiFiServer instance—those close() and stop() methods only shut down the TCP server you've started, not the SoftAP hotspot itself. The hotspot will keep running in the background even after the server is stopped, which is why you're still seeing it active.

The Correct Way to Shut Down the SoftAP

To fully turn off the SoftAP, you need to use the WiFi.softAPdisconnect() function. Here's the catch: by default, this function only disconnects connected clients but leaves the hotspot enabled. To completely disable the hotspot, pass true as the parameter.

Step-by-Step Solution with Code

Here's how to properly shut down both the server and the hotspot:

// First, shut down the WiFi server to clean up resources
serverWF.stop();

// Now, completely disable the SoftAP hotspot
WiFi.softAPdisconnect(true);

// Optional: Verify the hotspot is closed (check connected stations)
Serial.print("SoftAP status: Closed. Connected stations remaining: ");
Serial.println(WiFi.softAPgetStationNum());

Notes for Re-Enabling Later

If you want to start the hotspot again later, just re-run your original setup code:

WiFi.softAP(ssidHS, passwordHS);
serverWF.begin();

That should do the trick—your hotspot will disappear from available networks once you run the shutdown code.

内容的提问来源于stack exchange,提问作者Guy Luz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:01:36