esp32 dhcp server code example
Example: esp32 dhcp server
WiFiServer server(80);
static const char *ap_ssid = "ESP32-001";
static const char *ap_pass = "temp_pass";
void setup() {
Serial.begin(115200);
WiFi.softAP(ap_ssid, ap_pass);
Serial.print("Access point running. IP address: ");
Serial.print(WiFi.softAPIP());
Serial.println("");
server.begin();
}
void loop() {
WiFiClient client = server.available();
if (client) {
String client_ip = client.remoteIP().toString();
Serial.print("Client connected. IP address = ");
Serial.print(client_ip);
Serial.println("");
client.println("Hello ...");
client.stop();
}
}