蠻少看到中文的頁面上有人在討論AP如何設置靜態IP的文章,國外則是有人在討論但不是沒人回答或是沒有用

,這邊提供在AP模式下,設置靜態IP的方法,給需要的人

複製貼上燒到ESP32就可以看到192.168.0.100在監控視窗上顯示出來了

 

程式碼:

#include <WiFi.h>

const char *ssid = "ESP1234";//設置你的SSID
const char *password = "12345678";設置你的密碼

void setup() {
  Serial.begin(115200);
  Serial.println("Configuring access point...");

  WiFi.mode(WIFI_AP);
  WiFi.softAP(ssid, password);
  Serial.println("Wait 100 ms for AP_START...");
  delay(100);
  
  Serial.println("Set softAPConfig");
  IPAddress Ip(192, 168, 0, 100);
  IPAddress NMask(255, 255, 255, 0);
  WiFi.softAPConfig(Ip, Ip, NMask);
  
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
}

void loop() {
}

arrow
arrow
    創作者介紹
    創作者 凶王 的頭像
    凶王

    凶王的部落

    凶王 發表在 痞客邦 留言(0) 人氣()