ESP8266 NodeMCU Module – WiFi

WiFi NodeMCU Lua Module

Functions

  • wifi.getchannel()  Gets the current WiFi channel.
  • wifi.getdefaultmode()  Gets default WiFi operation mode.
  • wifi.getmode()  Gets WiFi operation mode.
  • wifi.getphymode()  Gets WiFi physical mode.
  • wifi.nullmodesleep()  Configures whether or not WiFi automatically goes to sleep in NULL_MODE.
  • wifi.resume()  Wake up WiFi from suspended state or cancel pending wifi suspension.
  • wifi.setmode()  Configures the WiFi mode to use.
  • wifi.setphymode()  Sets WiFi physical mode.
  • wifi.startsmart()  Starts to auto configuration, if success set up SSID and password automatically.
  • wifi.stopsmart()  Stops the smart configuring process.
  • wifi.suspend()  Suspend Wifi to reduce current consumption.
  • wifi.sta.autoconnect()  Auto connects to AP in station mode.
  • wifi.sta.changeap()  Select Access Point from list returned by wifi.
  • wifi.sta.clearconfig()  Clears the currently saved WiFi station configuration, erasing it from the flash.
  • wifi.sta.config()  Sets the WiFi station configuration.
  • wifi.sta.connect()  Connects to the configured AP in station mode.
  • wifi.sta.disconnect()  Disconnects from AP in station mode.
  • wifi.sta.eventMonReg()  Registers callbacks for WiFi station status events.
  • wifi.sta.eventMonStart()  Starts WiFi station event monitor.
  • wifi.sta.eventMonStop()  Stops WiFi station event monitor.
  • wifi.sta.getap()  Scans AP list as a Lua table into callback function.
  • wifi.sta.getapindex()  Get index of current Access Point stored in AP cache.
  • wifi.sta.getapinfo()  Get information of APs cached by ESP8266 station.
  • wifi.sta.getbroadcast()  Gets the broadcast address in station mode.
  • wifi.sta.getconfig()  Gets the WiFi station configuration.
  • wifi.sta.getdefaultconfig()  Gets the default WiFi station configuration stored in flash.
  • wifi.sta.gethostname()  Gets current station hostname.
  • wifi.sta.getip()  Gets IP address, netmask, and gateway address in station mode.
  • wifi.sta.getmac()  Gets MAC address in station mode.
  • wifi.sta.getrssi()  Get RSSI(Received Signal Strength Indicator) of the Access Point which ESP8266 station connected to.
  • wifi.sta.setaplimit()  Set Maximum number of Access Points to store in flash.
  • wifi.sta.sethostname()  Sets station hostname.
  • wifi.sta.setip()  Sets IP address, netmask, gateway address in station mode.
  • wifi.sta.setmac()  Sets MAC address in station mode.
  • wifi.sta.sleeptype()  Configures the WiFi modem sleep type to be used while station is connected to an Access Point.
  • wifi.sta.status()  Gets the current status in station mode.
  • wifi.ap.config()  Sets SSID and password in AP mode.
  • wifi.ap.deauth()  Deauths (forcibly removes) a client from the ESP access point by sending a corresponding IEEE802.
  • wifi.ap.getbroadcast()  Gets broadcast address in AP mode.
  • wifi.ap.getclient()  Gets table of clients connected to device in AP mode.
  • wifi.ap.getconfig()  Gets the current SoftAP configuration.
  • wifi.ap.getdefaultconfig()  Gets the default SoftAP configuration stored in flash.
  • wifi.ap.getip()  Gets IP address, netmask and gateway in AP mode. ifi.ap.getmac() Gets MAC address in AP mode.
  • wifi.ap.setip()  Sets IP address, netmask and gateway address in AP mode.
  • wifi.ap.setmac()  Sets MAC address in AP mode.
  • wifi.ap.dhcp.config()  Configure the dhcp service.
  • wifi.ap.dhcp.start()  Starts the DHCP service.
  • wifi.ap.dhcp.stop()  Stops the DHCP service.
  • wifi.eventmon.register()  Register/unregister callbacks for WiFi event monitor.
  • wifi.eventmon.unregister()  Unregister callbacks for WiFi event monitor.
  • wifi.eventmon.reason  Table containing disconnect reasons.

 


Note : ESP8266 does not support number as password in NodeMCU firmware


Examples

Scan for available all station networks

  • Scans AP list as a Lua table into callback function. wifi.sta.getap()

Sets the WiFi station configuration.

 

Connect ESP8266 to WiFi Router

 

Disconnect ESP8266 from WiFi Router

  • Disconnects from AP in station mode. wifi.sta.disconnect()

 

View the ESP8266 Stored Access Point information

  • Get information of APs cached by ESP8266 station. wifi.sta.getapinfo()

 

Gets the WiFi station configuration.

 

Clears the currently saved WiFi station configuration

  • Clears the currently saved WiFi station configuration, erasing it from the flash. May be useful for certain factory-reset scenarios when a full  node.restore()  is not desired, or to prepare for using End-User Setup so that the SoftAP is able to lock onto a single hardware radio channel.
  • Ex : wifi.sta.clearconfig()

 

WiFi station status events

 

Gets current station hostname.

  • Ex : print("Current hostname is: \""..wifi.sta.gethostname().."\"")

 

Sets station hostname.

 

 

Gets IP address, netmask, and gateway address in station mode.

 

Gets IP address, netmask and gateway in AP mode.

 

Gets MAC address in station mode.

  • Ex : print(wifi.sta.getmac())

Set MAC address in AP mode.

  • Ex : print(wifi.ap.setmac())

Get RSSI(Received Signal Strength Indicator)

  • Get RSSI(Received Signal Strength Indicator) of the Access Point which ESP8266 station connected to.

 

Gets table of clients connected to device in AP mode

 

Gets the current SoftAP configuration.

 

Gets the default SoftAP configuration stored in flash.

 

 

 

 


End User Setup NodeMCU Lua

Functions

  • enduser_setup.manual()  Controls whether manual AP configuration is used.
  • enduser_setup.start()  Starts the captive portal.
  • enduser_setup.stop() Stops the captive portal.

Example

Configure the End User Setup

 


Next :

Previous :

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

if you have any queries call us +918300026060 or WhatsApp Dismiss

0

Your Cart

%d bloggers like this: