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

    Faster Wifi Startup?

    Scheduled Pinned Locked Moved WiPy 2&3
    wifi
    9 Posts 5 Posters 2.1k Views 6 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.
    • S Offline
      semireg
      last edited by

      Coming from the ESP8266 I'm used to fast startup times where it seemed like the wifi connection was maintained between uPy soft reboots. When uploading to the WiPy (ESP32) it takes much longer for the wifi to start.

      Is there a configuration option that allows wifi to be saved between soft reboots? Faster the better - less time waiting to test new code that relies on WiFi.

      L robert-hhR 2 Replies Last reply Reply Quote 0
      • M Offline
        misterlisty
        last edited by

        I find wifi connection fairly fast but i have found that on my netgear..it fails to connect for an unknown reason.

        1 Reply Last reply Reply Quote 0
        • L Offline
          livius @semireg
          last edited by livius

          @semireg
          If you look into docs there is example

          if machine.reset_cause() != machine.SOFT_RESET:
              wlan.init(mode=WLAN.STA)
              # configuration below MUST match your home router settings!!
              wlan.ifconfig(config=('192.168.178.107', '255.255.255.0', '192.168.178.1', '8.8.8.8'))
          
          if not wlan.isconnected():
              # change the line below to match your network ssid, security and password
              wlan.connect('mywifi', auth=(WLAN.WPA2, 'mywifikey'), timeout=5000)
              while not wlan.isconnected():
                  machine.idle() # save power while waiting
          

          think about people first, then computers

          S 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @semireg
            last edited by

            @semireg Like the example below, you can test at boot time whether the device is already connected (using wlan.isconnected()), and reconnect only if not. That works fine for me.

            1 Reply Last reply Reply Quote 0
            • S Offline
              semireg
              last edited by

              Thanks for the replies. I'm using both of these techniques but upon sync via Atom (Pymakr plugin) the wlan is no longer connected.

              >>>
              Uploading project (src)...
              Reading file status
              [1/1] Writing file main.py
              Upload done, resetting board...
              ets Jun  8 2016 00:22:57
              
              rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
              configsip: 0, SPIWP:0xee
              clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
              mode:DIO, clock div:1
              load:0x3fff9028,len:8
              load:0x3fff9030,len:1060
              load:0x4009fa00,len:0
              ho 12 tail 0 room 4
              load:0x4009fa00,len:15072
              entry 0x400a063c
              Starting
              WLAN Not Connected
              
              1 Reply Last reply Reply Quote 0
              • S Offline
                ssmith @livius
                last edited by

                @livius said in Faster Wifi Startup?:

                @semireg
                If you look into docs there is example

                if machine.reset_cause() != machine.SOFT_RESET:
                    wlan.init(mode=WLAN.STA)
                    # configuration below MUST match your home router settings!!
                    wlan.ifconfig(config=('192.168.178.107', '255.255.255.0', '192.168.178.1', '8.8.8.8'))
                
                if not wlan.isconnected():
                    # change the line below to match your network ssid, security and password
                    wlan.connect('mywifi', auth=(WLAN.WPA2, 'mywifikey'), timeout=5000)
                    while not wlan.isconnected():
                        machine.idle() # save power while waiting
                

                Doesn't the while loop freeze the board if the WiFi doesn't connect?

                S L 2 Replies Last reply Reply Quote 0
                • S Offline
                  semireg @ssmith
                  last edited by

                  @ssmith, yes, but that's true with any contrived example.

                  1 Reply Last reply Reply Quote 0
                  • L Offline
                    livius @ssmith
                    last edited by livius

                    @ssmith
                    yes, but this is only example.
                    i self use different code

                    wasTimeout = 0
                    chrono = Timer.Chrono()
                    		chrono.start()
                    		while not wlan.isconnected():
                    			machine.idle()
                    			if chrono.read()>30: #30 sedcond timeout
                                                    wasTimeout = 1
                    				break
                    

                    but as discussed somewhere on the forum, this is only "missed timeout feature".
                    It should be passed to connect.

                    think about people first, then computers

                    S 1 Reply Last reply Reply Quote 1
                    • S Offline
                      semireg @livius
                      last edited by

                      @livius Thanks for the Chrono snippet. I'm always glad to find these nicely packaged design patterns.

                      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