General area when it fits no where else

Moderator: Mmiscool

User avatar
By Jokkepappa
#39780 Getting the ip that router gives to ESP is bit tricky. Depending on application you could for example have windows/android application that goes through devices on the lan and tests if they answer like your device should. Hardware side having oled display would be best way to show the ip, but it again costs. You could blink led but thats not too user friendly.

There is though email command http://www.esp8266basic.com/smtp-email-commands.html So you could have your device connec to wifi and then send email to the user with link to the device. This requires that user inputs email address tho, but it could work really well.

and ofc station and ap mode at the same time.

for getting the wifi networks and making connection you could do something like
Code: Select allwprint "SSID: "
textbox networkSSID
textboxID = HTMLID()
wprint "<br>Password: "
passwordbox networkPW
wprint "<br>"
button "Scan for networks" [doScan]
button "Connect" [connectWifi]
wprint "<br>"
wait

[doScan]
    n = wifi.scan()
    n = n - 1
    html "Number of network found = "
    html n

    for x = 1 to n
    html "<hr>"
    html wifi.ssid(x)
    html ","
    html wifi.rssi(x)
    next x
wait


Produces this:
Image

would just need to add element on the ssdi, like "<p>" tags with onclick event to put contents of the tag to the textbox.

Or like Mmiscool pointed out you can populate dropdown or listbox with the wifi's
Code: Select all    let listWifis = ""
    n = wifi.scan()
    n = n - 1
    html "Number of network found = "
    html n

    for x = 1 to n
    let listWifis = listWifis & wifi.ssid(x)
    let listWifis = listWifis & ","
    next x
    wprint "<br>"
    dropdown listWifis selectedWifi


Bit example code.

EDIT: Felt like doing some coding/learning myself so i made both complete. They can be found at programming examples: viewtopic.php?f=40&t=7854&p=39785#p39785