You control WiFi using wifi.setmode()
.
ESP8266's WiFi is very versatil. You can be a client and/or an access point. You can get your IP from DHCP or static.
Per default, ESP8266 start in STATIONAP mode (as client and access point).
This is the pertinent part from the official page
wifi.setmode()
Configures the WiFi mode to use. NodeMCU can run in one of four WiFi modes:
Station mode, where the NodeMCU device joins an existing network
Access point (AP) mode, where it creates its own network that others can join
Station + AP mode, where it both creates its own network while at the same time being joined to another existing network
WiFi off
When using the combined Station + AP mode, the same channel will be used for both networks as the radio can only listen on a single channel.
Note
WiFi configuration will be retained until changed even if device is turned off.
Syntax
wifi.setmode(mode[, save])
Parameters
mode value should be one of
wifi.STATION for when the device is connected to a WiFi router. This is often done to give the device access to the Internet.
wifi.SOFTAP for when the device is acting only as an access point. This will allow you to see the device in the list of WiFi networks (unless you hide the SSID, of course). In this mode your computer can connect to the device, creating a local area network. Unless you change the value, the NodeMCU device will be given a local IP address of 192.168.4.1 and assign your computer the next available IP address, such as 192.168.4.2.
wifi.STATIONAP is the combination of wifi.STATION and wifi.SOFTAP. It allows you to create a local WiFi connection and connect to another WiFi router.
wifi.NULLMODE changing WiFi mode to NULL_MODE will put wifi into a low power state similar to MODEM_SLEEP, provided wifi.nullmodesleep(false) has not been called.
save choose whether or not to save wifi mode to flash
true WiFi mode configuration will be retained through power cycle. (Default)
false WiFi mode configuration will not be retained through power cycle.
Returns
current mode after setup
Example
wifi.setmode(wifi.STATION);
See also
wifi.getmode() wifi.getdefaultmode()
#include <ESP8266WiFi.h>
?