- Notifications
You must be signed in to change notification settings - Fork9
MicroPython based ESP WiFi Manager
License
brainelectronics/Micropython-ESP-WiFi-Manager
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
MicroPython WiFi Manager to configure and connect to networks
Python3 must be installed on your system. Check the current Python versionwith the following command
python --versionpython3 --version
Depending on which commandPython 3.x.y
(with x.y as some numbers) isreturned, use that command to proceed.
python3 -m venv .venvsource .venv/bin/activatepip install -r requirements.txt
Test both tools by showing their man/help info description.
esptool.py --helprshell --help
To flash themicropython firmware as described onthe micropython firmware download page, use theesptool.py
to erase theflash before flashing the firmware.
esptool.py --chip esp32 --port /dev/tty.SLAB_USBtoUART erase_flashesptool.py --chip esp32 --port /dev/tty.SLAB_USBtoUART --baud 460800 write_flash -z 0x1000 esp32-20210623-v1.16.bin
If the Micropython board is equipped with an external PSRAM chip, theesp32spiram-20210623-v1.16.bin
can also be used for ESP32 devices. If thereis no external PRSAM only the non SPIRAM version is working.
Connect your MicroPython board to a network
importnetworkstation=network.WLAN(network.STA_IF)station.active(True)station.connect('SSID','PASSWORD')station.isconnected()
Install the latest package version of this lib on the MicroPython device
importmipmip.install("github:brainelectronics/micropython-esp-wifi-manager")# maybe install the dependencies manually afterwards# mip.install("github:brainelectronics/micropython-modules")
For MicroPython versions below 1.19.1 use theupip
package instead ofmip
importupipupip.install('micropython-esp-wifi-manager')# dependencies will be installed automatically
Theboot.py
andmain.py
files of this package are installed into/lib
ofthe MicroPython device bymip
. They are fully functional and without anyother dependencies or MicroPython port specific commands. Simply add thefollowing line to theboot.py
file of your device.The following commandsare not working if this package got installed byupip
importwifi_manager.boot
And also add this line to yourmain.py
, before your application code
importwifi_manager.main
Install a specific, fixed package version of this lib on the MicroPython device
importmip# install a verions of a specific branchmip.install("github:brainelectronics/micropython-esp-wifi-manager",version="feature/support-mip")# install a tag versionmip.install("github:brainelectronics/micropython-esp-wifi-manager",version="1.7.0")
Install a specific release candidate version uploaded toTest Python Package Index on every PR on theMicroPython device. If no specific version is set, the latest stable versionwill be used.
importmipmip.install("github:brainelectronics/micropython-esp-wifi-manager",version="1.7.0-rc5.dev22")
For MicroPython versions below 1.19.1 use theupip
package instead ofmip
importupip# overwrite index_urls to only take artifacts from test.pypi.orgupip.index_urls= ['https://test.pypi.org/pypi']upip.install('micropython-esp-wifi-manager')
See alsobrainelectronics Test PyPi Server in Dockerfor a test PyPi server running on Docker.
Copy the module(s) to the MicroPython board and import them as shown belowusingRemote MicroPython shell
Open the remote shell with the following command. Additionally use-b 115200
in case no CP210x is used but a CH34x.
rshell -p /dev/tty.SLAB_USBtoUART --editor nano
Create compressed CSS and JS files as described in thesimulation static files README to save disk space on thedevice and increase the performance (webpages are loading faster)
mkdir /pyboard/lib/mkdir /pyboard/lib/microdot/mkdir /pyboard/lib/utemplate/mkdir /pyboard/lib/wifi_manager/mkdir /pyboard/lib/static/mkdir /pyboard/lib/static/cssmkdir /pyboard/lib/static/jscp static/css/*.gz /pyboard/lib/static/csscp static/js/*.gz /pyboard/lib/static/js# around 24kB compared to uncompressed 120kB# optional, not used so far# mkdir /pyboard/lib/static/js# cp static/js/*.gz /pyboard/lib/static/js# around 12kB compared to uncompressed 40kBmkdir /pyboard/lib/templates/cp templates/* /pyboard/lib/templates/# around 20kBcp wifi_manager/* /pyboard/lib/wifi_manager/cp microdot/* /pyboard/lib/microdot/cp utemplate/* /pyboard/lib/utemplate/cp main.py /pyboardcp boot.py /pyboard# around 40kB
As this package has not been installed withupip
additional modules arerequired, which are not part of this repo.
Connect the board to a network and install the package like this forMicroPython 1.20.0 or never
importmipmip.install("github:brainelectronics/micropython-modules")
For MicroPython versions below 1.19.1 use theupip
package instead ofmip
importupipupip.install('micropython-brainelectronics-helper')
After all files have been transfered or installed open a REPL to the device.
The device will try to load and connect to the configured networks based on anencrypted JSON file.
In case no network has been configured or no connection could be establishedto any of the configured networks within the timeout of each 5 seconds anAccessPoint at192.168.4.1
is created.
A simple Picoweb webserver is hosting the webpages to connect to new networks,to remove already configured networks from the list of connections toestablish and to get the latest available networks as JSON.
This is a list of available webpages
URL | Description |
---|---|
/ | Root index page, to choose from the available pages |
/select | Select and configure a network |
/configure | Manage already configured networks |
/scan_result | JSON of available networks |
/shutdown | Shutdown webserver and return fromrun function |
To leave from the Webinterface, just press CTRL+C and wait until all threadsfinish running. This takes around 1 second. The device will return to its REPL
About
MicroPython based ESP WiFi Manager
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.