The network module is used to configure the WiFi connection. There are two WiFi interfaces, one for the station (when the ESP8266 connects to a router) and one for the access point (for other devices to connect to the ESP8266). In this example we would be creating an access point so that other devices (mobile phones/laptops etc) can connect to our ESP8266 module.

Run all the commands in REPL prompt sequentially.

Step 1: Create instance for station interface and access point interface.

import network
sta_if = network.WLAN(network.STA_IF)
ap_if = network.WLAN(network.AP_IF)

NOTE: Upon a fresh install the ESP8266 is configured in access point mode, so the AP_IF interface is active and the STA_IF interface is inactive. This can be verified by using the active() function.

Step 2: Verify the configuration of ESP8266.                   # Returns False.                    # Returns True.

Step 3: Activate the access point interface. (can skip this step if returns True, in step 2)

Step 4: Configure the access point interface.

ap.config(essid = "newnode", password = "node1234")

Step 5: Connect to node from mobile phone or laptop.

To connect a device to the node:

  • Go to device WiFi settings.
  • Scan for available networks.
  • Select "newnode"
  • Enter password "node1234".

Voila! You have successfully connected a device to ESP8266!

Note :

Please do let us know if we are missing any topic or you want us to elaborate any topic, comment below and subscribe to be updated.