{"id":91088,"date":"2019-11-22T12:36:24","date_gmt":"2019-11-22T12:36:24","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=91088"},"modified":"2020-07-30T14:07:53","modified_gmt":"2020-07-30T14:07:53","slug":"micropython-wi-fi-manager-esp32-esp8266","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/micropython-wi-fi-manager-esp32-esp8266\/","title":{"rendered":"MicroPython: Wi-Fi Manager with ESP32 (ESP8266 compatible)"},"content":{"rendered":"\n<p>In this tutorial we&#8217;ll show you how to use Wi-Fi Manager with the ESP32 using MicroPython firmware. Wi-Fi Manager allows you to connect your ESP32 to different Access Points (different networks) without having to hard-code your credentials and upload new code to your board.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-MicroPython-ESP32-ESP8266.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"MicroPython: Wi-Fi Manager with ESP32 ESP8266 compatible\" class=\"wp-image-91161\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-MicroPython-ESP32-ESP8266.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-MicroPython-ESP32-ESP8266.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-MicroPython-ESP32-ESP8266.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-MicroPython-ESP32-ESP8266.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n\n<p class=\"rntbox rntclblue\">This guide is also fully compatible with the ESP8266 board. However, since Wi-Fi manager library uses quite a lot of memory you may encounter a memory error while saving the script to your board. From our experience, restarting the board after uploading the script, removes the error and makes the project work after that. We recommend using the ESP32, but you can also continue this tutorial using an ESP8266 board.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Wi-Fi Manager Works<\/h2>\n\n\n\n<p>With the Wi-Fi Manager you no longer have to hard-code your network credentials (SSID and password). The ESP32 will set up an Access Point that you can use to configure the network credentials, or it will automatically join to a known saved network.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifi-manager-esp32-micropython-show-available-networks.png?resize=375%2C389&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Wi-Fi Client Setup WiFi Manager MicroPython\" class=\"wp-image-91119\" width=\"375\" height=\"389\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifi-manager-esp32-micropython-show-available-networks.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifi-manager-esp32-micropython-show-available-networks.png?resize=290%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 290w\" sizes=\"(max-width: 375px) 100vw, 375px\" \/><\/figure><\/div>\n\n\n\n<p>Here\u2019s how the process works:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>When the ESP32 boots for the first time, it&#8217;s set as an <a href=\"https:\/\/randomnerdtutorials.com\/micropython-esp32-esp8266-access-point-ap\/\">Access Point<\/a>;<\/li><li>You can connect to that Access Point by establishing a connection with the WiFiManager network and going to the IP address 192.164.4.1;<\/li><li>A web page opens that allows you to choose and configure a network;<\/li><li>The ESP32 saves those network credentials so that later it can connect to that network (Station mode);<\/li><li>Once a new SSID and password is set, the ESP32 reboots, it is set to Station mode and tries to connect to the previously saved network;<\/li><li>If it establishes a connection, the process is completed successfully. Otherwise, it will be set up as an Access Point for you to configure new network credentials.<\/li><\/ul>\n\n\n\n<p>To set up the Wi-Fi Manager on the ESP32 using MicroPython, we&#8217;ll use the <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/github.com\/tayfunulu\/WiFiManager\" target=\"_blank\">WiFiManager library by tayfunulu<\/a>. In the library GitHub page, you can find the following diagram that shows an overview on how everything works.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-micropython-diagram.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1200\" height=\"868\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-micropython-diagram.png?resize=1200%2C868&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Wi-Fi Manager for ESP with MicroPython\" class=\"wp-image-91089\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-micropython-diagram.png?w=1226&amp;quality=100&amp;strip=all&amp;ssl=1 1226w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-micropython-diagram.png?resize=300%2C217&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-micropython-diagram.png?resize=1024%2C741&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-micropython-diagram.png?resize=768%2C556&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><figcaption><center><a href=\"https:\/\/github.com\/tayfunulu\/WiFiManager\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Image source<\/a><\/center><\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>To follow this tutorial you need MicroPython firmware installed in your ESP board. You also need an IDE to write and upload the code to your board. We suggest using Thonny IDE or uPyCraft IDE:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Thonny IDE:<ul><li><a href=\"https:\/\/randomnerdtutorials.com\/getting-started-thonny-micropython-python-ide-esp32-esp8266\/\">Installing and getting started with Thonny IDE<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/flashing-micropython-firmware-esptool-py-esp32-esp8266\/\">Flashing MicroPython Firmware with esptool.py<\/a><\/li><\/ul><\/li><li>uPyCraft IDE:<ul><li><a href=\"https:\/\/randomnerdtutorials.com\/getting-started-micropython-esp32-esp8266\/\">Getting Started with uPyCraft IDE<\/a><\/li><li>Install uPyCraft IDE (<a href=\"https:\/\/randomnerdtutorials.com\/install-upycraft-ide-windows-pc-instructions\/\">Windows<\/a>,&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/install-upycraft-ide-mac-os-x-instructions\/\">Mac OS X<\/a>,&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/install-upycraft-ide-linux-ubuntu-instructions\/\">Linux<\/a>)<\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/flash-upload-micropython-firmware-esp32-esp8266\/\">Flash\/Upload MicroPython Firmware to ESP32 and ESP8266<\/a><\/li><\/ul><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Parts Required<\/h3>\n\n\n\n<p>For this tutorial you need an ESP32 (or <a href=\"https:\/\/makeradvisor.com\/tools\/esp8266-esp-12e-nodemcu-wi-fi-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"ESP8266 board (opens in a new tab)\">ESP8266 board<\/a>):<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\">ESP32 DEVKIT DOIT board<\/a> &#8211; read&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/esp32-development-boards-review-comparison\/\" target=\"_blank\">ESP32 Development Boards Review and Comparison<\/a><\/li><\/ul>\n\n\n\n<p class=\"rntbox rntclblue\">Learn more about MicroPython:&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/micropython-programming-with-esp32-and-esp8266\/\">Grab our MicroPython Programming with ESP32 and ESP8266 eBook<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">WiFiManager MicroPython Library<\/h2>\n\n\n\n<p>The library to set up Wi-Fi Manager on the ESP32 isn\u2019t part of the standard MicroPython library by default. So, you need to upload the following library to your ESP board (save it with this exact name&nbsp;<em>wifimgr.py<\/em>).<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\">import network\nimport socket\nimport ure\nimport time\n\nap_ssid = &quot;WifiManager&quot;\nap_password = &quot;tayfunulu&quot;\nap_authmode = 3  # WPA2\n\nNETWORK_PROFILES = 'wifi.dat'\n\nwlan_ap = network.WLAN(network.AP_IF)\nwlan_sta = network.WLAN(network.STA_IF)\n\nserver_socket = None\n\n\ndef get_connection():\n    &quot;&quot;&quot;return a working WLAN(STA_IF) instance or None&quot;&quot;&quot;\n\n    # First check if there already is any connection:\n    if wlan_sta.isconnected():\n        return wlan_sta\n\n    connected = False\n    try:\n        # ESP connecting to WiFi takes time, wait a bit and try again:\n        time.sleep(3)\n        if wlan_sta.isconnected():\n            return wlan_sta\n\n        # Read known network profiles from file\n        profiles = read_profiles()\n\n        # Search WiFis in range\n        wlan_sta.active(True)\n        networks = wlan_sta.scan()\n\n        AUTHMODE = {0: &quot;open&quot;, 1: &quot;WEP&quot;, 2: &quot;WPA-PSK&quot;, 3: &quot;WPA2-PSK&quot;, 4: &quot;WPA\/WPA2-PSK&quot;}\n        for ssid, bssid, channel, rssi, authmode, hidden in sorted(networks, key=lambda x: x[3], reverse=True):\n            ssid = ssid.decode('utf-8')\n            encrypted = authmode &gt; 0\n            print(&quot;ssid: %s chan: %d rssi: %d authmode: %s&quot; % (ssid, channel, rssi, AUTHMODE.get(authmode, '?')))\n            if encrypted:\n                if ssid in profiles:\n                    password = profiles[ssid]\n                    connected = do_connect(ssid, password)\n                else:\n                    print(&quot;skipping unknown encrypted network&quot;)\n            else:  # open\n                connected = do_connect(ssid, None)\n            if connected:\n                break\n\n    except OSError as e:\n        print(&quot;exception&quot;, str(e))\n\n    # start web server for connection manager:\n    if not connected:\n        connected = start()\n\n    return wlan_sta if connected else None\n\n\ndef read_profiles():\n    with open(NETWORK_PROFILES) as f:\n        lines = f.readlines()\n    profiles = {}\n    for line in lines:\n        ssid, password = line.strip(&quot;\\n&quot;).split(&quot;;&quot;)\n        profiles[ssid] = password\n    return profiles\n\n\ndef write_profiles(profiles):\n    lines = []\n    for ssid, password in profiles.items():\n        lines.append(&quot;%s;%s\\n&quot; % (ssid, password))\n    with open(NETWORK_PROFILES, &quot;w&quot;) as f:\n        f.write(''.join(lines))\n\n\ndef do_connect(ssid, password):\n    wlan_sta.active(True)\n    if wlan_sta.isconnected():\n        return None\n    print('Trying to connect to %s...' % ssid)\n    wlan_sta.connect(ssid, password)\n    for retry in range(200):\n        connected = wlan_sta.isconnected()\n        if connected:\n            break\n        time.sleep(0.1)\n        print('.', end='')\n    if connected:\n        print('\\nConnected. Network config: ', wlan_sta.ifconfig())\n        \n    else:\n        print('\\nFailed. Not Connected to: ' + ssid)\n    return connected\n\n\ndef send_header(client, status_code=200, content_length=None ):\n    client.sendall(&quot;HTTP\/1.0 {} OK\\r\\n&quot;.format(status_code))\n    client.sendall(&quot;Content-Type: text\/html\\r\\n&quot;)\n    if content_length is not None:\n      client.sendall(&quot;Content-Length: {}\\r\\n&quot;.format(content_length))\n    client.sendall(&quot;\\r\\n&quot;)\n\n\ndef send_response(client, payload, status_code=200):\n    content_length = len(payload)\n    send_header(client, status_code, content_length)\n    if content_length &gt; 0:\n        client.sendall(payload)\n    client.close()\n\n\ndef handle_root(client):\n    wlan_sta.active(True)\n    ssids = sorted(ssid.decode('utf-8') for ssid, *_ in wlan_sta.scan())\n    send_header(client)\n    client.sendall(&quot;&quot;&quot;\\\n        &lt;html&gt;\n            &lt;h1 style=&quot;color: #5e9ca0; text-align: center;&quot;&gt;\n                &lt;span style=&quot;color: #ff0000;&quot;&gt;\n                    Wi-Fi Client Setup\n                &lt;\/span&gt;\n            &lt;\/h1&gt;\n            &lt;form action=&quot;configure&quot; method=&quot;post&quot;&gt;\n                &lt;table style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;\n                    &lt;tbody&gt;\n    &quot;&quot;&quot;)\n    while len(ssids):\n        ssid = ssids.pop(0)\n        client.sendall(&quot;&quot;&quot;\\\n                        &lt;tr&gt;\n                            &lt;td colspan=&quot;2&quot;&gt;\n                                &lt;input type=&quot;radio&quot; name=&quot;ssid&quot; value=&quot;{0}&quot; \/&gt;{0}\n                            &lt;\/td&gt;\n                        &lt;\/tr&gt;\n        &quot;&quot;&quot;.format(ssid))\n    client.sendall(&quot;&quot;&quot;\\\n                        &lt;tr&gt;\n                            &lt;td&gt;Password:&lt;\/td&gt;\n                            &lt;td&gt;&lt;input name=&quot;password&quot; type=&quot;password&quot; \/&gt;&lt;\/td&gt;\n                        &lt;\/tr&gt;\n                    &lt;\/tbody&gt;\n                &lt;\/table&gt;\n                &lt;p style=&quot;text-align: center;&quot;&gt;\n                    &lt;input type=&quot;submit&quot; value=&quot;Submit&quot; \/&gt;\n                &lt;\/p&gt;\n            &lt;\/form&gt;\n            &lt;p&gt;&amp;nbsp;&lt;\/p&gt;\n            &lt;hr \/&gt;\n            &lt;h5&gt;\n                &lt;span style=&quot;color: #ff0000;&quot;&gt;\n                    Your ssid and password information will be saved into the\n                    &quot;%(filename)s&quot; file in your ESP module for future usage.\n                    Be careful about security!\n                &lt;\/span&gt;\n            &lt;\/h5&gt;\n            &lt;hr \/&gt;\n            &lt;h2 style=&quot;color: #2e6c80;&quot;&gt;\n                Some useful infos:\n            &lt;\/h2&gt;\n            &lt;ul&gt;\n                &lt;li&gt;\n                    Original code from &lt;a href=&quot;https:\/\/github.com\/cpopp\/MicroPythonSamples&quot;\n                        target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;cpopp\/MicroPythonSamples&lt;\/a&gt;.\n                &lt;\/li&gt;\n                &lt;li&gt;\n                    This code available at &lt;a href=&quot;https:\/\/github.com\/tayfunulu\/WiFiManager&quot;\n                        target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;tayfunulu\/WiFiManager&lt;\/a&gt;.\n                &lt;\/li&gt;\n            &lt;\/ul&gt;\n        &lt;\/html&gt;\n    &quot;&quot;&quot; % dict(filename=NETWORK_PROFILES))\n    client.close()\n\n\ndef handle_configure(client, request):\n    match = ure.search(&quot;ssid=([^&amp;]*)&amp;password=(.*)&quot;, request)\n\n    if match is None:\n        send_response(client, &quot;Parameters not found&quot;, status_code=400)\n        return False\n    # version 1.9 compatibility\n    try:\n        ssid = match.group(1).decode(&quot;utf-8&quot;).replace(&quot;%3F&quot;, &quot;?&quot;).replace(&quot;%21&quot;, &quot;!&quot;)\n        password = match.group(2).decode(&quot;utf-8&quot;).replace(&quot;%3F&quot;, &quot;?&quot;).replace(&quot;%21&quot;, &quot;!&quot;)\n    except Exception:\n        ssid = match.group(1).replace(&quot;%3F&quot;, &quot;?&quot;).replace(&quot;%21&quot;, &quot;!&quot;)\n        password = match.group(2).replace(&quot;%3F&quot;, &quot;?&quot;).replace(&quot;%21&quot;, &quot;!&quot;)\n\n    if len(ssid) == 0:\n        send_response(client, &quot;SSID must be provided&quot;, status_code=400)\n        return False\n\n    if do_connect(ssid, password):\n        response = &quot;&quot;&quot;\\\n            &lt;html&gt;\n                &lt;center&gt;\n                    &lt;br&gt;&lt;br&gt;\n                    &lt;h1 style=&quot;color: #5e9ca0; text-align: center;&quot;&gt;\n                        &lt;span style=&quot;color: #ff0000;&quot;&gt;\n                            ESP successfully connected to WiFi network %(ssid)s.\n                        &lt;\/span&gt;\n                    &lt;\/h1&gt;\n                    &lt;br&gt;&lt;br&gt;\n                &lt;\/center&gt;\n            &lt;\/html&gt;\n        &quot;&quot;&quot; % dict(ssid=ssid)\n        send_response(client, response)\n        time.sleep(1)\n        wlan_ap.active(False)\n        try:\n            profiles = read_profiles()\n        except OSError:\n            profiles = {}\n        profiles[ssid] = password\n        write_profiles(profiles)\n\n        time.sleep(5)\n\n        return True\n    else:\n        response = &quot;&quot;&quot;\\\n            &lt;html&gt;\n                &lt;center&gt;\n                    &lt;h1 style=&quot;color: #5e9ca0; text-align: center;&quot;&gt;\n                        &lt;span style=&quot;color: #ff0000;&quot;&gt;\n                            ESP could not connect to WiFi network %(ssid)s.\n                        &lt;\/span&gt;\n                    &lt;\/h1&gt;\n                    &lt;br&gt;&lt;br&gt;\n                    &lt;form&gt;\n                        &lt;input type=&quot;button&quot; value=&quot;Go back!&quot; onclick=&quot;history.back()&quot;&gt;&lt;\/input&gt;\n                    &lt;\/form&gt;\n                &lt;\/center&gt;\n            &lt;\/html&gt;\n        &quot;&quot;&quot; % dict(ssid=ssid)\n        send_response(client, response)\n        return False\n\n\ndef handle_not_found(client, url):\n    send_response(client, &quot;Path not found: {}&quot;.format(url), status_code=404)\n\n\ndef stop():\n    global server_socket\n\n    if server_socket:\n        server_socket.close()\n        server_socket = None\n\n\ndef start(port=80):\n    global server_socket\n\n    addr = socket.getaddrinfo('0.0.0.0', port)[0][-1]\n\n    stop()\n\n    wlan_sta.active(True)\n    wlan_ap.active(True)\n\n    wlan_ap.config(essid=ap_ssid, password=ap_password, authmode=ap_authmode)\n\n    server_socket = socket.socket()\n    server_socket.bind(addr)\n    server_socket.listen(1)\n\n    print('Connect to WiFi ssid ' + ap_ssid + ', default password: ' + ap_password)\n    print('and access the ESP via your favorite web browser at 192.168.4.1.')\n    print('Listening on:', addr)\n\n    while True:\n        if wlan_sta.isconnected():\n            wlan_ap.active(False)\n            return True\n\n        client, addr = server_socket.accept()\n        print('client connected from', addr)\n        try:\n            client.settimeout(5.0)\n\n            request = b&quot;&quot;\n            try:\n                while &quot;\\r\\n\\r\\n&quot; not in request:\n                    request += client.recv(512)\n            except OSError:\n                pass\n\n            # Handle form data from Safari on macOS and iOS; it sends \\r\\n\\r\\nssid=&lt;ssid&gt;&amp;password=&lt;password&gt;\n            try:\n                request += client.recv(1024)\n                print(&quot;Received form data after \\\\r\\\\n\\\\r\\\\n(i.e. from Safari on macOS or iOS)&quot;)\n            except OSError:\n                pass\n\n            print(&quot;Request is: {}&quot;.format(request))\n            if &quot;HTTP&quot; not in request:  # skip invalid requests\n                continue\n\n            # version 1.9 compatibility\n            try:\n                url = ure.search(&quot;(?:GET|POST) \/(.*?)(?:\\\\?.*?)? HTTP&quot;, request).group(1).decode(&quot;utf-8&quot;).rstrip(&quot;\/&quot;)\n            except Exception:\n                url = ure.search(&quot;(?:GET|POST) \/(.*?)(?:\\\\?.*?)? HTTP&quot;, request).group(1).rstrip(&quot;\/&quot;)\n            print(&quot;URL is {}&quot;.format(url))\n\n            if url == &quot;&quot;:\n                handle_root(client)\n            elif url == &quot;configure&quot;:\n                handle_configure(client, request)\n            else:\n                handle_not_found(client, url)\n\n        finally:\n            client.close()\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/tayfunulu\/WiFiManager\/raw\/master\/wifimgr.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>Follow the next set of instructions for the IDE you\u2019re using:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>A. Upload WiFiManager library with&nbsp;<strong>uPyCraft IDE<\/strong><\/li><li>B. Upload WiFiManager library with&nbsp;<strong>Thonny IDE<\/strong><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">A. Upload WiFiManager library with uPyCraft IDE<\/h3>\n\n\n\n<p>This section shows how to upload a library using uPyCraft IDE. If you\u2019re using Thonny IDE, read the next section.<\/p>\n\n\n\n<p><strong>1.<\/strong>&nbsp;Create a new file by pressing the&nbsp;<strong>New File<\/strong>&nbsp;button.<\/p>\n\n\n\n<p><strong>2.<\/strong>&nbsp;Copy the WiFiManager library code into that file. The WiFiManager library code can be copied <a rel=\"noreferrer noopener\" aria-label=\"here (opens in a new tab)\" href=\"https:\/\/raw.githubusercontent.com\/tayfunulu\/WiFiManager\/master\/wifimgr.py\" target=\"_blank\">here<\/a>.<\/p>\n\n\n\n<p><strong>3.<\/strong>&nbsp;After copying the code, save the file by pressing the&nbsp;<strong>Save&nbsp;<\/strong>button.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"600\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/installing-wifimanager-upycraft-ide-micropython-1.png?resize=730%2C600&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Uploading wifmgr Library using upycraft IDE MicroPython\" class=\"wp-image-91092\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/installing-wifimanager-upycraft-ide-micropython-1.png?w=730&amp;quality=100&amp;strip=all&amp;ssl=1 730w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/installing-wifimanager-upycraft-ide-micropython-1.png?resize=300%2C247&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 730px) 100vw, 730px\" \/><\/figure><\/div>\n\n\n\n<p><strong>4.<\/strong>&nbsp;Name this new file \u201c<em>wifimgr.py<\/em>\u201d and press&nbsp;<strong>ok<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"402\" height=\"112\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/save-wifimanager-library-upycraft-ide.png?resize=402%2C112&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Saving wifimgr.py library in upycraft IDE\" class=\"wp-image-91093\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/save-wifimanager-library-upycraft-ide.png?w=402&amp;quality=100&amp;strip=all&amp;ssl=1 402w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/save-wifimanager-library-upycraft-ide.png?resize=300%2C84&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 402px) 100vw, 402px\" \/><\/figure><\/div>\n\n\n\n<p><strong>5.<\/strong>&nbsp;Click the&nbsp;<strong>Download and Run<\/strong>&nbsp;button.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"41\" height=\"52\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/10\/download-run.png?resize=41%2C52&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Install BME280 library MicroPython ESP32 ESP8266 uPyCraft IDE step 3\" class=\"wp-image-75031\"\/><\/figure><\/div>\n\n\n\n<p>The file should be saved on the device folder with the name \u201c<em>wifimgr.py<\/em>\u201d as highlighted in the following figure.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"600\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifimanager-library-uploaded-micropython-upycraft-ide.png?resize=730%2C600&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"wifimngr Library Successfully Uploaded to ESP32\" class=\"wp-image-91094\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifimanager-library-uploaded-micropython-upycraft-ide.png?w=730&amp;quality=100&amp;strip=all&amp;ssl=1 730w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifimanager-library-uploaded-micropython-upycraft-ide.png?resize=300%2C247&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 730px) 100vw, 730px\" \/><\/figure><\/div>\n\n\n\n<p>Now, you can use the library functionalities in your code by importing the library.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">B. Upload WiFiManager library with Thonny IDE<\/h3>\n\n\n\n<p>If you\u2019re using Thonny IDE, follow the next steps:<\/p>\n\n\n\n<p><strong>1.<\/strong>&nbsp;Copy the library code to a new file. The&nbsp;WiFiManager library code can be copied <a href=\"https:\/\/raw.githubusercontent.com\/tayfunulu\/WiFiManager\/master\/wifimgr.py\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"here (opens in a new tab)\">here<\/a>.<\/p>\n\n\n\n<p><strong>2<\/strong>. Save that file as&nbsp;<em>wifimgr.py<\/em>.<\/p>\n\n\n\n<p><strong>3.<\/strong>&nbsp;Go to&nbsp;<strong>Device&nbsp;<\/strong>&gt;&nbsp;<strong>Upload current script with the current name<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"735\" height=\"546\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/thonny-ide-upload-wifimanager-library.png?resize=735%2C546&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Uploading wifmgr Library using Thonny IDE MicroPython\" class=\"wp-image-91096\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/thonny-ide-upload-wifimanager-library.png?w=735&amp;quality=100&amp;strip=all&amp;ssl=1 735w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/thonny-ide-upload-wifimanager-library.png?resize=300%2C223&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 735px) 100vw, 735px\" \/><\/figure><\/div>\n\n\n\n<p>And that\u2019s it. The library was uploaded to your board. To make sure that it was uploaded successfully, in the Shell you can type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%lsdevice<\/code><\/pre>\n\n\n\n<p>It should return the files currently saved on your board. One of them should be the&nbsp;<em>wifimgr.py<\/em>&nbsp;file.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"174\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifimanager-successfully-uploaded-thonny-ide.png?resize=725%2C174&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"wifimgr.py Library successfully saved on ESP32 MicroPython\" class=\"wp-image-91097\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifimanager-successfully-uploaded-thonny-ide.png?w=725&amp;quality=100&amp;strip=all&amp;ssl=1 725w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifimanager-successfully-uploaded-thonny-ide.png?resize=300%2C72&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 725px) 100vw, 725px\" \/><\/figure><\/div>\n\n\n\n<p>After uploading the library to your board, you can use the library functionalities in your code by importing the library.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code &#8211; Setting Up Wi-Fi Manager with the ESP32<\/h2>\n\n\n\n<p>The following code implementes Wi-Fi Manager on the ESP32. We&#8217;ll add Wi-Fi Manager capabilities to a previous <a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-micropython-web-server\/\">MicroPython Web Server project<\/a>. By the end of the tutorial, you should be able to implement Wi-Fi Manager in your won projects.<\/p>\n\n\n\n<p>Create a <em>main.py<\/em> file and copy the following code.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Complete project details at https:\/\/RandomNerdTutorials.com\n\nimport wifimgr\nfrom time import sleep\nimport machine\n\ntry:\n  import usocket as socket\nexcept:\n  import socket\n\nled = machine.Pin(2, machine.Pin.OUT)\n\nwlan = wifimgr.get_connection()\nif wlan is None:\n    print(&quot;Could not initialize the network connection.&quot;)\n    while True:\n        pass  # you shall not pass :D\n\n# Main Code goes here, wlan is a working network.WLAN(STA_IF) instance.\nprint(&quot;ESP OK&quot;)\n\ndef web_page():\n  if led.value() == 1:\n    gpio_state=&quot;ON&quot;\n  else:\n    gpio_state=&quot;OFF&quot;\n  \n  html = &quot;&quot;&quot;&lt;html&gt;&lt;head&gt; &lt;title&gt;ESP Web Server&lt;\/title&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;\n  &lt;link rel=&quot;icon&quot; href=&quot;data:,&quot;&gt; &lt;style&gt;html{font-family: Helvetica; display:inline-block; margin: 0px auto; text-align: center;}\n  h1{color: #0F3376; padding: 2vh;}p{font-size: 1.5rem;}.button{display: inline-block; background-color: #e7bd3b; border: none; \n  border-radius: 4px; color: white; padding: 16px 40px; text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}\n  .button2{background-color: #4286f4;}&lt;\/style&gt;&lt;\/head&gt;&lt;body&gt; &lt;h1&gt;ESP Web Server&lt;\/h1&gt; \n  &lt;p&gt;GPIO state: &lt;strong&gt;&quot;&quot;&quot; + gpio_state + &quot;&quot;&quot;&lt;\/strong&gt;&lt;\/p&gt;&lt;p&gt;&lt;a href=&quot;\/?led=on&quot;&gt;&lt;button class=&quot;button&quot;&gt;ON&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\n  &lt;p&gt;&lt;a href=&quot;\/?led=off&quot;&gt;&lt;button class=&quot;button button2&quot;&gt;OFF&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;&lt;\/body&gt;&lt;\/html&gt;&quot;&quot;&quot;\n  return html\n  \ntry:\n  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n  s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n  s.bind(('', 80))\n  s.listen(5)\nexcept OSError as e:\n  machine.reset()\n\nwhile True:\n  try:\n    if gc.mem_free() &lt; 102000:\n      gc.collect()\n    conn, addr = s.accept()\n    conn.settimeout(3.0)\n    print('Got a connection from %s' % str(addr))\n    request = conn.recv(1024)\n    conn.settimeout(None)\n    request = str(request)\n    print('Content = %s' % request)\n    led_on = request.find('\/?led=on')\n    led_off = request.find('\/?led=off')\n    if led_on == 6:\n      print('LED ON')\n      led.value(1)\n    if led_off == 6:\n      print('LED OFF')\n      led.value(0)\n    response = web_page()\n    conn.send('HTTP\/1.1 200 OK\\n')\n    conn.send('Content-Type: text\/html\\n')\n    conn.send('Connection: close\\n\\n')\n    conn.sendall(response)\n    conn.close()\n  except OSError as e:\n    conn.close()\n    print('Connection closed')\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP-MicroPython\/esp_wifimanager_example.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How the Code Works<\/h2>\n\n\n\n<p>This code is based on a previous <a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-micropython-web-server\/\">ESP32\/ESP8266 MicroPython web server project<\/a>. We&#8217;ve just made a few modifications to add the Wi-Fi Manager. <\/p>\n\n\n\n<p>To add the Wi-Fi Manager, you need to import the library you&#8217;ve previously uploaded to your board.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>import wifimgr<\/code><\/pre>\n\n\n\n<p>The following lines of code, handle the Wi-Fi Manager for you:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>wlan = wifimgr.get_connection()\nif wlan is None:\n    print(\"Could not initialize the network connection.\")\n    while True:\n        pass  # you shall not pass :D<\/code><\/pre>\n\n\n\n<p><span class=\"rnthl rntliteral\">wlan<\/span> is a working <span class=\"rnthl rntliteral\">network.WLAN(STA_IF)<\/span> instance that is initialized by the library. So, you don&#8217;t need to include that to set your ESP32 as a Station.<\/p>\n\n\n\n<p>When the ESP32 is first set as an Access Point, it leaves a socket open, which results in an error and makes the ESP32 crash. To make sure that doesn&#8217;t happen, we initialize and bind the socket inside <span class=\"rnthl rntliteral\">try<\/span> and <span class=\"rnthl rntliteral\">except<\/span> statements. <\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>try:\n  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n  s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n  s.bind(('', 80))\n  s.listen(5)\nexcept OSError as e:\n  machine.reset()<\/code><\/pre>\n\n\n\n<p>In case, there&#8217;s a socket left open, we&#8217;ll get an OS error, and reset the ESP32 with <span class=\"rnthl rntliteral\">machine.reset()<\/span>. This will &#8220;forget&#8221; the open socket. <\/p>\n\n\n\n<p>When the code runs the second time, the network credentials are already saved, so the ESP32 is not set as an Access Point, there isn&#8217;t any problem with open sockets, and the code proceeds smoothly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing the WiFiManager<\/h2>\n\n\n\n<p>Upload the <em>main.py<\/em> file to your ESP32. After that, press the ESP32 on-board RST (EN) button to start running the program.<\/p>\n\n\n\n<p>On the Python Shell, you should get a similar message.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"186\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/esp32-start-wi-fi-manager-micropython.png?resize=727%2C186&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"WiFiManager Set Up ESP32 MicroPython\" class=\"wp-image-91099\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/esp32-start-wi-fi-manager-micropython.png?w=727&amp;quality=100&amp;strip=all&amp;ssl=1 727w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/esp32-start-wi-fi-manager-micropython.png?resize=300%2C77&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 727px) 100vw, 727px\" \/><\/figure><\/div>\n\n\n\n<p>That means that the ESP32 was successfully set as an Access Point. Now, you can connect to that Access Point to choose your network and type your credentials. To do that, follow the next steps.<\/p>\n\n\n\n<p>In your computer, or smartphone, open the Wi-Fi settings and connect to the <strong>WifiManager <\/strong>network. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/connect-to-wifimanager-network.png?resize=375%2C475&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Connect to WiFiManager Network ESP32 MicroPython\" class=\"wp-image-91102\" width=\"375\" height=\"475\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/connect-to-wifimanager-network.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/connect-to-wifimanager-network.png?resize=237%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 237w\" sizes=\"(max-width: 375px) 100vw, 375px\" \/><\/figure><\/div>\n\n\n\n<p>The password is <strong>tayfunulu<\/strong>. You can change the default SSID and password on the library code.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifi-manager-micropython-password.png?resize=375%2C386&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Enter network password wifimanager\" class=\"wp-image-91103\" width=\"375\" height=\"386\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifi-manager-micropython-password.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifi-manager-micropython-password.png?resize=291%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 291w\" sizes=\"(max-width: 375px) 100vw, 375px\" \/><\/figure><\/div>\n\n\n\n<p>Once you&#8217;re successfully connected to the WiFiManager network, open a browser and type 192.168.4.1. The following page should load:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"525\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/selecting-wi-fi-network-wifimanager.png?resize=750%2C525&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Selecting Wi-Fi Network - WiFiManager MicroPython ESP32\" class=\"wp-image-91104\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/selecting-wi-fi-network-wifimanager.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/selecting-wi-fi-network-wifimanager.png?resize=300%2C210&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n\n<p>Select your network, type the password and click <strong>Submit<\/strong>. After a few seconds, you should receive a success message.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"747\" height=\"245\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/successfully-connected-to-network-wifimanager.png?resize=747%2C245&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 successfully connected to Wifi Network - WiFiManager\" class=\"wp-image-91106\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/successfully-connected-to-network-wifimanager.png?w=747&amp;quality=100&amp;strip=all&amp;ssl=1 747w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/successfully-connected-to-network-wifimanager.png?resize=300%2C98&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 747px) 100vw, 747px\" \/><\/figure><\/div>\n\n\n\n<p>This message means that your ESP32 is set up as a Wi-Fi Station and it is connected to your local network. Now, to access the ESP32, go again to your Wi-Fi settings in your computer or smartphone and connect again to your network.<\/p>\n\n\n\n<p>In the Python shell, the ESP32 IP address should be printed.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"221\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifi-manager-esp32-station-ip.png?resize=707%2C221&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Station IP Address - WiFiManager MicroPython\" class=\"wp-image-91107\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifi-manager-esp32-station-ip.png?w=707&amp;quality=100&amp;strip=all&amp;ssl=1 707w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/wifi-manager-esp32-station-ip.png?resize=300%2C94&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 707px) 100vw, 707px\" \/><\/figure><\/div>\n\n\n\n<p class=\"rntbox rntclblue\"><strong>Note: <\/strong> in a real world scenario, you&#8217;ll probably won&#8217;t have access to the Python shell. In that situation, we recommend printing the IP address on an <a href=\"https:\/\/randomnerdtutorials.com\/micropython-oled-display-esp32-esp8266\/\">OLED display<\/a>.<\/p>\n\n\n\n<p>Open your browser and type that IP address. You&#8217;ll get access to the following web server and you can control the ESP32 GPIO.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/web-server-esp32-micropython-station.png?resize=656%2C413&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Web Server Control Outputs MicroPython - WiFiManager\" class=\"wp-image-91108\" width=\"656\" height=\"413\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/web-server-esp32-micropython-station.png?w=655&amp;quality=100&amp;strip=all&amp;ssl=1 655w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/web-server-esp32-micropython-station.png?resize=300%2C189&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 656px) 100vw, 656px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>With the WiFiManager library you no longer have to hard-code your network credentials. The ESP32 sets an Access Point that displays the available Wi-Fi networks. You just need to choose your network and enter your password to set the ESP32 as a Wi-Fi Station.<\/p>\n\n\n\n<p>We hope you&#8217;ve found this tutorial useful. You may also like:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-micropython-web-server\/\">ESP32\/ESP8266 MicroPython Web Server \u2013 Control Outputs<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-esp32-esp8266-access-point-ap\/\">MicroPython: ESP32\/ESP8266 Access Point (AP)<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/category\/0-esp32-micropython\/\">MicroPython: ESP32\/ESP8266 with DHT11\/DHT22 Web Server<\/a><\/li><li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-oled-display-esp32-esp8266\/\">MicroPython: OLED Display with ESP32 and ESP8266<\/a><\/li><\/ul>\n\n\n\n<p><strong>Learn more about MicroPython with our eBook:<\/strong> <a href=\"https:\/\/randomnerdtutorials.com\/micropython-programming-with-esp32-and-esp8266\/\">MicroPython Programming with ESP32 and ESP8266<\/a><\/p>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we&#8217;ll show you how to use Wi-Fi Manager with the ESP32 using MicroPython firmware. Wi-Fi Manager allows you to connect your ESP32 to different Access Points (different &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"MicroPython: Wi-Fi Manager with ESP32 (ESP8266 compatible)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/micropython-wi-fi-manager-esp32-esp8266\/#more-91088\" aria-label=\"Read more about MicroPython: Wi-Fi Manager with ESP32 (ESP8266 compatible)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":91161,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[276,281,277,309,264],"tags":[],"class_list":["post-91088","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32","category-esp32-project","category-esp32-arduino-ide","category-0-esp32-micropython","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/WiFi-Manager-MicroPython-ESP32-ESP8266.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/91088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=91088"}],"version-history":[{"count":0,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/91088\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/91161"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=91088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=91088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=91088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}