WiFiNINA - WiFi.setHostname()

Description

Sets the hostname of the module, the hostname is sent in WiFi.begin(…) when an IP address is requested from a DHCP server.

Syntax

WiFi.setHostname(hostname)

Parameters

  • hostname - new hostname to use

Returns

  • Nothing

Example

…
  WiFi.setHostname("MyArduino");

  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
…