• Has someone put into their project a way to initially have their device first run as a host / access point and receive wifi information for subsequent bootup into client/station mode?

    This is similar to how you first setup a chromecast to go onto your wifi. Application of this would be to allow your "station device" to be deployed to different wifi routers.

  • I don't think I have seen anyone do this with Espruino (I think @tve did it with esp-link), but it shouldn't be too hard - just a few lines of code. Would this be with an Espruino board + ESP8266, or with Espruino running on the ESP8266 itself?

    If you need some ideas of how to get started, let us know!

    I'd consider maybe using the FlashEEPROM library to store and retrieve the Wifi credentials, as then you won't have to use save() - which would reboot Espruino.

  • Espruino on ESP8266.

    I am thinking of having a small switch on one of the GPIO to put it into station mode, then allow user to connect via phone/laptop to set the wifi credentials of the wifi router.

    I'll post the code once I am done.

  • On ESP8266 you can make it remember the Wifi details itself, so actually it should be pretty easy to get working (without FlashEEPROM). I believe ESP8266 can be an AP and can connect to another AP at the same time, so you could just leave the AP mode on all the time rather than needing a button.

  • Can someone direct me to an example using ESP8266 as access point? As near as I can tell, I am unable to get DHCP to return an IP address for my phone. It doesn't stay connected long enough for me to get to the 192.168.4.1 page.

    Here are what my settings look like:

    >wifi.getAPIP();
    ={
      "ip": "192.168.4.1",
      "netmask": "255.255.255.0",
      "gw": "192.168.4.1",
      "mac": "1a:fe:34:da:70:c8"
    
    >wifi.getAPDetails()
    ={
      "status": "enabled",
      "authMode": "wpa2",
      "hidden": false, "maxConn": 4,
      "ssid": "will",
      "password": "password",
      "savedSsid": null,
      "stations": [  ]
     }
    
    
  • I'll move this to the ESP8266 forum section - I think you might have more luck there...

  • Does the AP code have something equivalent to the arduino code to start DHCP?

    wifi.setmode(wifi.SOFTAP)
    wifi.ap.config({
        ssid = 'myssid'
        pwd = '12345678'
    })
    wifi.ap.dhcp.start()  -- important!
    
  • I found a project on github with similar goals. My "goal" will be to merge in a folder with same code, but for Espurino/ESP8266.
    github-wifimanger

  • I'm working on something like this, what would be the best way to send the result of wifi.scan back to the browser? You couldn't just add it in the page request as its Async and needs a callback, perhaps a global to keep track of the Scan, run once on startup then again after every request?

  • I think you have to make the async call when an initial page is called, then present the list when user clicks a button on a 2nd page.

  • I think you can just delay sending end?

    function pageRequest(req) {
      wifi.getAPs(function(info) {
        req.end(info);
      });
    }
    

    Just to give you an idea - I doubt the command-names are right in that code :

  • Brilliant idea, I'll try this method out later, I didn't know you could just delay END, Thanks.

  • I am in the last stages of testing my project, code is here.

    To power a ATX power supply put the GPIO2 to pin 16 on ATX power supply and this will turn it on.

  • I've solved the problem. I now can write applications that allow ESP to get it's SSID/pass from the users. Might later add ability to "scan" available AP's, but content with this for now.

    Feel free to share:
    https://github.com/wga22/esp8266/blob/ma­ster/espurino/AP_test.js

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

[ANSWERED]Is there "Chromecast" syle wifi configuration code

Posted by Avatar for Will @Will

Actions