When does "wifi_on_boot" happen?

  • Hi all!
    I'm fiddling with a kind of "smart provisioning"...
    What's working:

    • Setting my LoPy1 to AP mode
    • Having a tiny web server, showing of a page with the surrounding wifi networks
    • A simple form for giving the wanted ssid and password
      Then I save the ssid and password:

    and reset the device with machine.reset().
    In my boot.py I check if wifi_on_boot is True and set the depending main file with machine.main('main_wifi.py').
    In main_wifi.py I simply do

    from network import WLAN
    import time
    import machine
    wlan = WLAN()
        while not wlan.isconnected():
        rtc = RTC()
        rtc.ntp_sync("de.pool.ntp.org", 3600)
        print("reboot in 5s")
    print("Everything is running fine")

    But it will never connect. It allways runs into a timeout and reboots. SSID and Password are set correct. Is this only working with Pybytes?
    I run on the latest firmware but with deactivated Pybytes support.


  • which you are able to change on the fly if needed. For OEM modules, there's only one option as there's only one antenna port

  • That is a good point! I'll add it to the FW to-do list.

    Though I do not see any issues arise from the parameter missing directly. By default, the on-board antenna is selected for development modules, which you are able to change on the fly if needed. For OEM modules, there's only one option as there's only one antenna port

  • @Gijs Good to know that it happens bevor boot.py is executed.
    Therefor, I'm missing a parameter:
    pycom.wifi_mode_on_boot(mode, antenna). If the wifi is set before the boot.py is executed, it should also be possible, to set the right antenna, isn't it?


  • To clarify, the pycom.wifi_on_boot() sets the wifi settings even before the boot.py. You can use the accompanying functions from the API (https://docs.pycom.io/firmwareapi/pycom/pycom/#boot-methods) to set the SSID, AP or STA mode, and the password. Next to that, the method is only activated after resetting the module (meaning you will not see the behaviour directly after changing the settings, but only after a reset)


  • Ok, I can answer my questions by myself now ;-)
    Everything works now like expected. I just reset my home AP, after I recognized, that my mobile is also not connecting to my wifi network.
    Sometimes things are so stupid... ;-)

Log in to reply

Pycom on Twitter