WiFi.config() allows you to configure a static IP address as well as change the DNS, gateway, and subnet addresses on the WiFi shield.
WiFi.begin() which automatically configures the WiFi shield to use DHCP,
WiFi.config() allows you to manually set the network address of the shield.
begin() to configure the WiFi shield with the network addresses specified in
You can call
WiFi.begin(), but the shield will initialize with
begin() in the default DHCP mode. Once the
config() method is called, it will change the network address as requested.
WiFi.config(ip, dns, gateway);
WiFi.config(ip, dns, gateway, subnet);
ip: the IP address of the device (array of 4 bytes)
dns: the address for a DNS server.
gateway: the IP address of the network gateway (array of 4 bytes). optional: defaults to the device IP address with the last octet set to 1
subnet: the subnet mask of the network (array of 4 bytes). optional: defaults to 255.255.255.0
This example shows how to set the static IP address, 192.168.0.177, of the LAN network to the Arduino WiFi Shield 101:
Corrections, suggestions, and new documentation should be posted to the Forum.
The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.