bismillah

mail@pastecode.io avatar
unknown
c_cpp
7 days ago
881 B
2
Indexable
Never
#include <ESP8266WiFi.h>
const char* ssid = "desktop-alma"; 
const char* pass = "12345678";

IPAddress ip(192,168,137,200);  // Node static IP
IPAddress gateway(192,168,137,1);  // Default gateway
IPAddress subnet(255,255,255,0);  // Subnet mask

void setup() {
  Serial.begin(115200);  // Start the serial communication at a baud rate of 115200
  WiFi.begin(ssid, pass);  // Start the WiFi connection
  WiFi.config(ip, gateway, subnet);  // Configure static IP settings
  
  // Wait until connected to WiFi
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");  // Print dots to indicate ongoing connection attempts
  }

  // Display IP address upon successful connection
  Serial.println("");
  Serial.print("WiFi connected, using IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  Serial.println(WiFi.localIP()); 
  delay(1000); 

}
Leave a Comment