使用以下代码可以获取连接的Wi-Fi的ip地址:

#include <ESP8266WiFi.h>

void setup() {
  Serial.begin(115200);
  // 连接Wi-Fi
  WiFi.begin("your_SSID", "your_PASSWORD");

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }

  // 打印连接的Wi-Fi的ip地址
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  // 你的代码
}

其中,WiFi.localIP()可以获取连接的Wi-Fi的ip地址。

esp8266获取连接的Wi-Fi的ip

原文地址: https://www.cveoy.top/t/topic/bfJZ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录