Python Forum
[ESP32 Micropython]Total noob here, I don't understand why this while loop won't run.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[ESP32 Micropython]Total noob here, I don't understand why this while loop won't run.
#8
(Feb-28-2023, 06:27 PM)rob101 Wrote: Not that I've used the libraries that you are using, but would while not station.scan(): be better? That way (in theory, least ways) you're testing for 'truthfulness'. Also, do you not have to update station.scan() in the while: loop? If not, how will any change in state be detected?

I now have this code

# wifi_test.py
import network
import time

# Create a station object to store our connection
wifi = network.WLAN(network.STA_IF)
wifi.active(True)

available_wifi_networks = wifi.scan()

while len(available_wifi_networks) == 0:
    print("Waiting for wifi.scan() to return something...")
    time.sleep(1)
    available_wifi_networks = wifi.scan()
else:
    for i in available_wifi_networks:
        print (i)
It just keeps outputting

Output:
Waiting for wifi.scan() to return something...
Reply


Messages In This Thread
RE: [ESP32 Micropython]Total noob here, I don't understand why this while loop won't run. - by wh33t - Feb-28-2023, 06:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  micropython-stepper 1.0.3 trix 2 652 Nov-20-2023, 06:00 AM
Last Post: trix
  Read 2 Value with bleak via BLE notify from ESP32 Nietzsche 8 3,025 May-04-2023, 09:31 PM
Last Post: Nietzsche
  Noob here. Random quiz program. Using a while loop function and alot of conditionals. monkeydesu 6 1,494 Sep-07-2022, 02:01 AM
Last Post: kaega2
  Noob Alert! Wrong result using loop and if statemnent GJG 7 2,998 Dec-19-2020, 05:18 PM
Last Post: buran
  How do I understand "and" in a loop leoahum 2 1,720 Apr-24-2020, 05:57 AM
Last Post: leoahum
  Please Help , Total Noob need help to run Scrip on Windows ClicksCode 2 1,787 Mar-06-2020, 01:59 PM
Last Post: DeaD_EyE
  geting started with Micropython on ESP 32 - do i need to have a virtual environment? apollo 0 1,829 Sep-02-2019, 04:25 PM
Last Post: apollo
  Python on Linux, Total Noob to Both halcyon 4 3,155 May-27-2019, 10:40 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020