EasyManuals Logo

Adafruit Feather HUZZAH ESP8266 User Manual

Adafruit Feather HUZZAH ESP8266
53 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #31 background imageLoading...
Page #31 background image
wifi.setmode(wifi.STATION)
Then you can run the scanner and have it print out the available AP's
-- print ap list
function listap(t)
for k,v in pairs(t) do
print(k.." : "..v)
end
end
wifi.sta.getap(listap)
or for more detail...
-- print ap list
function listap(t)
for ssid,v in pairs(t) do
authmode, rssi, bssid, channel = string.match(v, "(%d),(-?%d+),(%x%x:%x%x:
%x%x:%x%x:%x%x:%x%x),(%d+)")
print(ssid,authmode,rssi,bssid,channel)
end
end
wifi.sta.getap(listap)
We can connect to the access point with wifi.sta.config and wifi.sta.connect - it will
take a second or two to complete the connection, you can query the module to ask
the status with wifi.sta.status() - when you get a 5 it means the connection is
completed and DHCP successful
wifi.sta.config("accesspointname","yourpassword")
wifi.sta.connect()
tmr.delay(1000000) -- wait 1,000,000 us = 1 second
print(wifi.sta.status())
print(wifi.sta.getip())
WebClient example
Once you're got the IP address you can connect to adafruit, for example, and read a
webpage and print it out:
sk=net.createConnection(net.TCP, 0)
sk:on("receive", function(sck, c) print(c) end )
sk:connect(80,"207.58.139.247")
sk:send("GET /testwifi/index.html HTTP/1.1\r\nHost: www.adafruit.com\r\nConnection:
keep-alive\r\nAccept: */*\r\n\r\n")
©Adafruit Industries Page 31 of 53

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Adafruit Feather HUZZAH ESP8266 and is the answer not in the manual?

Adafruit Feather HUZZAH ESP8266 Specifications

General IconGeneral
BrandAdafruit
ModelFeather HUZZAH ESP8266
CategoryMicrocontrollers
LanguageEnglish

Related product manuals