<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[best practice for wifi connection]]></title><description><![CDATA[<p dir="auto">Hello there,<br />
My project has a wifi connection and the set up looks like this:<br />
My question:</p>
<ul>
<li>how to prioritize networks? If two network is avaible, prefer one then the other.  In this setup it goes the first in the ABC.</li>
<li>I added a block if no known network found, then sleep for minute and search again. But somehow always goes to the else part. Can you hint why?</li>
<li>Is there a tool to debug the micropython code? It would be helpful sometimes</li>
<li>do you have any other tips? Thanks in advance! :)</li>
</ul>
<pre><code>while not wlan.isconnected():
    for net in nets:
        if net.ssid == '******':
            print(str(net.ssid)+&quot; found!&quot;)
            lcd.putstr(str(net.ssid)+&quot; found!&quot;)
            wlan.connect(&quot;******&quot;, auth=(WLAN.WPA2, &quot;*****&quot;), timeout=5000) 
        elif net.ssid == '***':
            print(str(net.ssid)+&quot; found!&quot;)
            lcd.putstr(str(net.ssid)+&quot; found!&quot;)
            wlan.connect(&quot;***&quot;, auth=(WLAN.WPA2, &quot;*******&quot;), timeout=5000)
        elif net.ssid == '******':
            print(str(net.ssid)+&quot; found!&quot;)
            lcd.putstr(str(net.ssid)+&quot; found!&quot;)
            wlan.connect(&quot;******&quot;, auth=(WLAN.WPA2, &quot;*********&quot;), timeout=5000)
        else:
            lcd.clear()
            lcd.putstr(&quot;No network, sleeping for 1 min&quot;)
            lcd.move_to(0, 1)
            lcd.backlight_off()
            machine.deepsleep(60000)
            machine.reset()
</code></pre>
]]></description><link>https://forum.pycom.io/topic/5434/best-practice-for-wifi-connection</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Mar 2026 02:14:36 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/5434.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Nov 2019 07:04:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to best practice for wifi connection on Mon, 25 Nov 2019 07:04:30 GMT]]></title><description><![CDATA[<p dir="auto">Hello there,<br />
My project has a wifi connection and the set up looks like this:<br />
My question:</p>
<ul>
<li>how to prioritize networks? If two network is avaible, prefer one then the other.  In this setup it goes the first in the ABC.</li>
<li>I added a block if no known network found, then sleep for minute and search again. But somehow always goes to the else part. Can you hint why?</li>
<li>Is there a tool to debug the micropython code? It would be helpful sometimes</li>
<li>do you have any other tips? Thanks in advance! :)</li>
</ul>
<pre><code>while not wlan.isconnected():
    for net in nets:
        if net.ssid == '******':
            print(str(net.ssid)+&quot; found!&quot;)
            lcd.putstr(str(net.ssid)+&quot; found!&quot;)
            wlan.connect(&quot;******&quot;, auth=(WLAN.WPA2, &quot;*****&quot;), timeout=5000) 
        elif net.ssid == '***':
            print(str(net.ssid)+&quot; found!&quot;)
            lcd.putstr(str(net.ssid)+&quot; found!&quot;)
            wlan.connect(&quot;***&quot;, auth=(WLAN.WPA2, &quot;*******&quot;), timeout=5000)
        elif net.ssid == '******':
            print(str(net.ssid)+&quot; found!&quot;)
            lcd.putstr(str(net.ssid)+&quot; found!&quot;)
            wlan.connect(&quot;******&quot;, auth=(WLAN.WPA2, &quot;*********&quot;), timeout=5000)
        else:
            lcd.clear()
            lcd.putstr(&quot;No network, sleeping for 1 min&quot;)
            lcd.move_to(0, 1)
            lcd.backlight_off()
            machine.deepsleep(60000)
            machine.reset()
</code></pre>
]]></description><link>https://forum.pycom.io/post/30677</link><guid isPermaLink="true">https://forum.pycom.io/post/30677</guid><dc:creator><![CDATA[tttadam]]></dc:creator><pubDate>Mon, 25 Nov 2019 07:04:30 GMT</pubDate></item></channel></rss>