Development of NodeMCU

Subsection 3.4: WiFi Test

WiFi in NodeMCU has three modes: AP(Access Point), STA(STATION), and AP+STA. In the AP mode, NodeMCU is used as a sender to send WiFi signal, and can accept the wireless connection from other nodes. At this time, NodeMCU can be viewed as a wireless router. In STA mode, NodeMCU is used as a node, and can connect to other AP (e.g., smartphone and/or wireless router).

LuaLoader can test the functions of NodeMCU at STA mode. About the test of AP and AP+STA modes, please read the NodeMCU documents. In the next section, we would present the example source code.

"SSID" and "Password" edit blocks are used to input the SSID name and password of wireless router.

"Survery"is used to search the SSID in the environment of NodeMCU,and print. The function is similar to the following code.

wifi.setmode(wifi.STATION) 
wifi.sta.getap(function(t) 
if t then print("\n\nVisible Access Points:\n") 
for k,v in pairs(t) do l = string.format("%-10s",k) print(l.."  "..v) end 
else 
print("Try again") 
end
end)

The result is listed as follows.

"Set AP" is that using SSID and Password to connect the wireless router.