Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to design an ESP32 WiFi manager using MicroPython

By Nikhil Agnihotri July 17, 2023

Nearly all the devices we use today — from smartphones, tablets, wearables, and even many of our appliances — connect to the Internet via a home (or office) WiFi network. Internet access to smart devices is typically managed through a web interface or mobile app.

Similarly, when we’re out and about, we’ll access WiFi for our mobile devices by connecting to a specific network and inputting the password. However, managing Internet access can be more challenging with self-built Internet of things (IoT) devices. This is because these credentials are usually hard-coded in IoT devices.

But what if a MicroPython port as simple as ESP32 could serve as a universal WiFi manager? This would allow all IoT-connected devices (including our smartphones, laptops, and wearables) to connect to random WiFi networks — without inputting passwords each time.

A WiFi manager configured on ESP32 will scan for the available networks and store the credentials for current and future use, saving time and energy.

Components required

  • ESP32 or ESP8266 board x1

Prerequisites
You must have uploaded MicroPython firmware to ESP32/ESP8266 and installed uPyCraft IDE or Thonny IDE on your computer. Click here to learn how to install uPyCraft IDE and upload MicroPython firmware to ESP32/ESP8266.

Circuit connections
There are no connections required. It’s only necessary to set up and configure ESP32/ESP8266 to work as a WiFi manager.

The MicroPython library
For this project, we’ll use the WiFi manager library built by Tayfunulu. It’s available on Github via this link. The source code of the library is below.

To upload the WiFi manager library to ESP32/ESP8266, connect the ESP board to your computer via a Micro-USB cable. Open uPyCraft IDE and navigate to File->New. Copy the WiFi manager library’s source code to the new file and click the save button.

Name the new file ‘WiFiManager.py,’ and save it by clicking OK.

Click the ‘Download and Run’ button to upload the library to the ESP board.

The MicroPython script
The WiFi manager library must be implemented in the main application code in the MicroPython firmware. To do so, create a new file by navigating to File->New and save it as ‘main.py.’

Copy the code below to main.py. Then, upload it to the ESP board by clicking the ‘Download and Run’ button.

How the WiFi manager works
When the ESP board boots for the first time after the code is uploaded, it’s set as a WiFi access point. This point is seen as the ‘WiFiManager,’ which can be connected to a computer or mobile. 

The password to connect with the WiFiManager is ‘tayfunulu.’ The password and SSID of the ESP WiFiManager can be changed by modifying the WiFiManager.py. 

After connecting to the WiFiManager, open its dashboard by going to the IP address 192.168.4.1. The available WiFi connections will be displayed on the webpage. Select a WiFi connection and enter its network key to configure the connection with the ESP board. After the correct credentials are entered, the WiFi connection can be accessed by any device by connecting to the WiFiManager.  

The code
The main application code imports the WiFiManager library. The available WiFi connections are scanned by calling the WiFiManager.get_connection() method. If there is no WiFi network available, the message “Could not initialize the network connection” is printed to the console. Otherwise, the WiFi connections will be accessible on 192.168.4.1. 

When the ESP board first boots as an access point, it leaves a socket open — which can crash the ESP board. To prevent this, the socket connection is managed by a ‘try-except’ exception handling routine. 

The main application code then hosts the webpage for connecting with an available WiFi connection, as well as a webpage that controls the LED on the ESP board.  

Testing the WiFi manager
After uploading the main application code, reset the ESP board by pressing the RESET button. The ESP WiFiManager will be activated, and a message will be printed to the MicroPython console. 

Next, open the WiFi settings on your computer or smartphone and connect to the WiFiManager network.

Once you’ve connected to the WiFiManager network, open the URL 192.168.4.1 in a web browser. You’ll see the available WiFi network connections. Select one and enter its password. Then, save the credentials to the WiFiManager by clicking the submit button.

The ESP board is now connected to the WiFi network. Any other devices you have can also directly access all the available WiFi networks by connecting to the WiFiManager without putting in a password or hard coding the credentials in the application code. 

Conclusion
The WiFi manager built in this project saves time, making WiFi easily accessible to all of your smart devices, including laptops and smartphones. So, you will no longer have to input the username and password into each one; nor will you have to hard code the WiFi credentials into each device. A WiFi manager configured on ESP32 scans for the available networks and stores the credentials for current and future use.

 

You may also like:


  • The top mobile app development tools for IoT and electronics

  • How to manage data on ESP32 for IoT projects

  • The top IoT platforms of 2023

  • How to build a portable WiFi repeater using ESP32 or…

  • How to send SMS alerts from ESP32 without a GSM…

Filed Under: Electronic Projects, ESP8266
Tagged With: ESP32, internet, internetofthings, IoT, MicroPython, wifi, wifimanager, wireless
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • High Side current sensing
  • How to simulate power electronics converter in PSpice?
  • Voltage mode pushpull is a nonsense SMPS?
  • Layout IRN reduction in Comparator

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe