Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    When does "wifi_on_boot" happen?

    Scheduled Pinned Locked Moved Discussion
    wifi on boot
    6 Posts 3 Posters 86 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      Thomas Schaefer
      last edited by

      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:
      pycom.wifi_ssid_sta(set_ssid)
      pycom.wifi_pwd_sta(set_pwd)
      pycom.wifi_mode_on_boot(WLAN.STA)
      pycom.wifi_on_boot(True)
      

      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()
      time.sleep(2)
      try:
          while not wlan.isconnected():
              time.sleep_ms(50)
          print(wlan.ifconfig())
          rtc = RTC()
          rtc.ntp_sync("de.pool.ntp.org", 3600)
          print(rtc.now())
      except:
          print("reboot in 5s")
          time.sleep(5)
          machine.reset()
      pycom.rgbled(0x00FF00)
      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.

      Cheers,
      Thomas

      1 Reply Last reply Reply Quote 0
      • T Offline
        Thomas Schaefer
        last edited by

        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... ;-)

        1 Reply Last reply Reply Quote 1
        • G Offline
          Gijs
          last edited by

          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)

          Best,
          Gijs

          T 1 Reply Last reply Reply Quote 1
          • T Offline
            Thomas Schaefer @Gijs
            last edited by

            @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?

            Cheers,
            Thomas

            1 Reply Last reply Reply Quote 0
            • G Offline
              Gijs
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • A Offline
                Amit sharma
                last edited by

                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

                1 Reply Last reply Reply Quote 0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • 1 / 1
                • First post
                  Last post

                Pycom on Twitter

                Pycom