micropython-esp-wifi-manager


Namemicropython-esp-wifi-manager JSON
Version 1.12.0 PyPI version JSON
download
home_pagehttps://github.com/brainelectronics/Micropython-ESP-WiFi-Manager
SummaryMicroPython WiFi Manager to configure and connect to networks
upload_time2023-06-12 07:58:21
maintainer
docs_urlNone
authorbrainelectronics
requires_python
licenseMIT
keywords micropython brainelectronics wifi wifimanager library
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ESP WiFi Manager

[![Downloads](https://pepy.tech/badge/micropython-esp-wifi-manager)](https://pepy.tech/project/micropython-esp-wifi-manager)
![Release](https://img.shields.io/github/v/release/brainelectronics/micropython-esp-wifi-manager?include_prereleases&color=success)
![MicroPython](https://img.shields.io/badge/micropython-Ok-green.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI](https://github.com/brainelectronics/micropython-esp-wifi-manager/actions/workflows/release.yml/badge.svg)](https://github.com/brainelectronics/micropython-esp-wifi-manager/actions/workflows/release.yml)

MicroPython WiFi Manager to configure and connect to networks

-----------------------

<!-- MarkdownTOC -->

- [Installation](#installation)
	- [Install required tools](#install-required-tools)
	- [Flash firmware](#flash-firmware)
	- [Upload files to board](#upload-files-to-board)
		- [Install package](#install-package)
		- [General](#general)
		- [Hook the WiFi Manager boot logic](#hook-the-wifi-manager-boot-logic)
		- [Specific version](#specific-version)
		- [Test version](#test-version)
		- [Manually](#manually)
			- [Upload files to board](#upload-files-to-board-1)
			- [Install additional MicroPython packages](#install-additional-micropython-packages)
- [Usage](#usage)

<!-- /MarkdownTOC -->

## Installation

### Install required tools

Python3 must be installed on your system. Check the current Python version
with the following command

```bash
python --version
python3 --version
```

Depending on which command `Python 3.x.y` (with x.y as some numbers) is
returned, use that command to proceed.

```bash
python3 -m venv .venv
source .venv/bin/activate

pip install -r requirements.txt
```

Test both tools by showing their man/help info description.

```bash
esptool.py --help
rshell --help
```

### Flash firmware

To flash the [micropython firmware][ref-upy-firmware-download] as described on
the micropython firmware download page, use the `esptool.py` to erase the
flash before flashing the firmware.

```bash
esptool.py --chip esp32 --port /dev/tty.SLAB_USBtoUART erase_flash
esptool.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, the
`esp32spiram-20210623-v1.16.bin` can also be used for ESP32 devices. If there
is no external PRSAM only the non SPIRAM version is working.

### Upload files to board

#### Install package

Connect your MicroPython board to a network

```python
import network
station = network.WLAN(network.STA_IF)
station.active(True)
station.connect('SSID', 'PASSWORD')
station.isconnected()
```

#### General

Install the latest package version of this lib on the MicroPython device

```python
import mip
mip.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 the `upip` package instead of `mip`

```python
import upip
upip.install('micropython-esp-wifi-manager')
# dependencies will be installed automatically
```

#### Hook the WiFi Manager boot logic

The `boot.py` and `main.py` files of this package are installed into `/lib` of
the MicroPython device by `mip`. They are fully functional and without any
other dependencies or MicroPython port specific commands. Simply add the
following line to the `boot.py` file of your device.

```python
from wifi_manager import boot
```

And also add this line to your `main.py`, before your application code

```python
from wifi_manager import main
```

#### Specific version

Install a specific, fixed package version of this lib on the MicroPython device

```python
import mip
# install a verions of a specific branch
mip.install("github:brainelectronics/micropython-esp-wifi-manager", version="feature/support-mip")
# install a tag version
mip.install("github:brainelectronics/micropython-esp-wifi-manager", version="1.7.0")
```

#### Test version

Install a specific release candidate version uploaded to
[Test Python Package Index](https://test.pypi.org/) on every PR on the
MicroPython device. If no specific version is set, the latest stable version
will be used.

```python
import mip
mip.install("github:brainelectronics/micropython-esp-wifi-manager", version="1.7.0-rc5.dev22")
```

For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`

```python
import upip
# overwrite index_urls to only take artifacts from test.pypi.org
upip.index_urls = ['https://test.pypi.org/pypi']
upip.install('micropython-esp-wifi-manager')
```

See also [brainelectronics Test PyPi Server in Docker][ref-brainelectronics-test-pypiserver]
for a test PyPi server running on Docker.

#### Manually

##### Upload files to board

Copy the module(s) to the MicroPython board and import them as shown below
using [Remote MicroPython shell][ref-remote-upy-shell]

Open the remote shell with the following command. Additionally use `-b 115200`
in case no CP210x is used but a CH34x.

```bash
rshell -p /dev/tty.SLAB_USBtoUART --editor nano
```

Create compressed CSS and JS files as described in the
[simulation static files README](simulation/static) to save disk space on the
device and increase the performance (webpages are loading faster)

```bash
mkdir /pyboard/lib/
mkdir /pyboard/lib/microdot/
mkdir /pyboard/lib/utemplate/
mkdir /pyboard/lib/wifi_manager/
mkdir /pyboard/lib/static/
mkdir /pyboard/lib/static/css
mkdir /pyboard/lib/static/js

cp static/css/*.gz /pyboard/lib/static/css
cp 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 40kB

mkdir /pyboard/lib/templates/
cp templates/* /pyboard/lib/templates/
# around 20kB

cp wifi_manager/* /pyboard/lib/wifi_manager/
cp microdot/* /pyboard/lib/microdot/
cp utemplate/* /pyboard/lib/utemplate/
cp main.py /pyboard
cp boot.py /pyboard
# around 40kB
```

##### Install additional MicroPython packages

As this package has not been installed with `upip` additional modules are
required, which are not part of this repo.

Connect the board to a network and install the package like this for
MicroPython 1.20.0 or never

```python
import mip
mip.install("github:brainelectronics/micropython-modules")
```

For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`

```python
import upip
upip.install('micropython-brainelectronics-helper')
```

## Usage

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 an
encrypted JSON file.

In case no network has been configured or no connection could be established
to any of the configured networks within the timeout of each 5 seconds an
AccessPoint at `192.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 to
establish 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 from `run` function |

To leave from the Webinterface, just press CTRL+C and wait until all threads
finish running. This takes around 1 second. The device will return to its REPL

<!-- Links -->
[ref-esptool]: https://github.com/espressif/esptool
[ref-remote-upy-shell]: https://github.com/dhylands/rshell
[ref-brainelectronics-test-pypiserver]: https://github.com/brainelectronics/test-pypiserver
[ref-upy-firmware-download]: https://micropython.org/download/



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/brainelectronics/Micropython-ESP-WiFi-Manager",
    "name": "micropython-esp-wifi-manager",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "micropython,brainelectronics,wifi,wifimanager,library",
    "author": "brainelectronics",
    "author_email": "info@brainelectronics.de",
    "download_url": "https://files.pythonhosted.org/packages/40/3e/b4327d607582727bd55f3ca9f52ef11605f8deea362b550cdf822cd13250/micropython-esp-wifi-manager-1.12.0.tar.gz",
    "platform": null,
    "description": "# ESP WiFi Manager\n\n[![Downloads](https://pepy.tech/badge/micropython-esp-wifi-manager)](https://pepy.tech/project/micropython-esp-wifi-manager)\n![Release](https://img.shields.io/github/v/release/brainelectronics/micropython-esp-wifi-manager?include_prereleases&color=success)\n![MicroPython](https://img.shields.io/badge/micropython-Ok-green.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![CI](https://github.com/brainelectronics/micropython-esp-wifi-manager/actions/workflows/release.yml/badge.svg)](https://github.com/brainelectronics/micropython-esp-wifi-manager/actions/workflows/release.yml)\n\nMicroPython WiFi Manager to configure and connect to networks\n\n-----------------------\n\n<!-- MarkdownTOC -->\n\n- [Installation](#installation)\n\t- [Install required tools](#install-required-tools)\n\t- [Flash firmware](#flash-firmware)\n\t- [Upload files to board](#upload-files-to-board)\n\t\t- [Install package](#install-package)\n\t\t- [General](#general)\n\t\t- [Hook the WiFi Manager boot logic](#hook-the-wifi-manager-boot-logic)\n\t\t- [Specific version](#specific-version)\n\t\t- [Test version](#test-version)\n\t\t- [Manually](#manually)\n\t\t\t- [Upload files to board](#upload-files-to-board-1)\n\t\t\t- [Install additional MicroPython packages](#install-additional-micropython-packages)\n- [Usage](#usage)\n\n<!-- /MarkdownTOC -->\n\n## Installation\n\n### Install required tools\n\nPython3 must be installed on your system. Check the current Python version\nwith the following command\n\n```bash\npython --version\npython3 --version\n```\n\nDepending on which command `Python 3.x.y` (with x.y as some numbers) is\nreturned, use that command to proceed.\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate\n\npip install -r requirements.txt\n```\n\nTest both tools by showing their man/help info description.\n\n```bash\nesptool.py --help\nrshell --help\n```\n\n### Flash firmware\n\nTo flash the [micropython firmware][ref-upy-firmware-download] as described on\nthe micropython firmware download page, use the `esptool.py` to erase the\nflash before flashing the firmware.\n\n```bash\nesptool.py --chip esp32 --port /dev/tty.SLAB_USBtoUART erase_flash\nesptool.py --chip esp32 --port /dev/tty.SLAB_USBtoUART --baud 460800 write_flash -z 0x1000 esp32-20210623-v1.16.bin\n```\n\nIf the Micropython board is equipped with an external PSRAM chip, the\n`esp32spiram-20210623-v1.16.bin` can also be used for ESP32 devices. If there\nis no external PRSAM only the non SPIRAM version is working.\n\n### Upload files to board\n\n#### Install package\n\nConnect your MicroPython board to a network\n\n```python\nimport network\nstation = network.WLAN(network.STA_IF)\nstation.active(True)\nstation.connect('SSID', 'PASSWORD')\nstation.isconnected()\n```\n\n#### General\n\nInstall the latest package version of this lib on the MicroPython device\n\n```python\nimport mip\nmip.install(\"github:brainelectronics/micropython-esp-wifi-manager\")\n\n# maybe install the dependencies manually afterwards\n# mip.install(\"github:brainelectronics/micropython-modules\")\n```\n\nFor MicroPython versions below 1.19.1 use the `upip` package instead of `mip`\n\n```python\nimport upip\nupip.install('micropython-esp-wifi-manager')\n# dependencies will be installed automatically\n```\n\n#### Hook the WiFi Manager boot logic\n\nThe `boot.py` and `main.py` files of this package are installed into `/lib` of\nthe MicroPython device by `mip`. They are fully functional and without any\nother dependencies or MicroPython port specific commands. Simply add the\nfollowing line to the `boot.py` file of your device.\n\n```python\nfrom wifi_manager import boot\n```\n\nAnd also add this line to your `main.py`, before your application code\n\n```python\nfrom wifi_manager import main\n```\n\n#### Specific version\n\nInstall a specific, fixed package version of this lib on the MicroPython device\n\n```python\nimport mip\n# install a verions of a specific branch\nmip.install(\"github:brainelectronics/micropython-esp-wifi-manager\", version=\"feature/support-mip\")\n# install a tag version\nmip.install(\"github:brainelectronics/micropython-esp-wifi-manager\", version=\"1.7.0\")\n```\n\n#### Test version\n\nInstall a specific release candidate version uploaded to\n[Test Python Package Index](https://test.pypi.org/) on every PR on the\nMicroPython device. If no specific version is set, the latest stable version\nwill be used.\n\n```python\nimport mip\nmip.install(\"github:brainelectronics/micropython-esp-wifi-manager\", version=\"1.7.0-rc5.dev22\")\n```\n\nFor MicroPython versions below 1.19.1 use the `upip` package instead of `mip`\n\n```python\nimport upip\n# overwrite index_urls to only take artifacts from test.pypi.org\nupip.index_urls = ['https://test.pypi.org/pypi']\nupip.install('micropython-esp-wifi-manager')\n```\n\nSee also [brainelectronics Test PyPi Server in Docker][ref-brainelectronics-test-pypiserver]\nfor a test PyPi server running on Docker.\n\n#### Manually\n\n##### Upload files to board\n\nCopy the module(s) to the MicroPython board and import them as shown below\nusing [Remote MicroPython shell][ref-remote-upy-shell]\n\nOpen the remote shell with the following command. Additionally use `-b 115200`\nin case no CP210x is used but a CH34x.\n\n```bash\nrshell -p /dev/tty.SLAB_USBtoUART --editor nano\n```\n\nCreate compressed CSS and JS files as described in the\n[simulation static files README](simulation/static) to save disk space on the\ndevice and increase the performance (webpages are loading faster)\n\n```bash\nmkdir /pyboard/lib/\nmkdir /pyboard/lib/microdot/\nmkdir /pyboard/lib/utemplate/\nmkdir /pyboard/lib/wifi_manager/\nmkdir /pyboard/lib/static/\nmkdir /pyboard/lib/static/css\nmkdir /pyboard/lib/static/js\n\ncp static/css/*.gz /pyboard/lib/static/css\ncp static/js/*.gz /pyboard/lib/static/js\n# around 24kB compared to uncompressed 120kB\n\n# optional, not used so far\n# mkdir /pyboard/lib/static/js\n# cp static/js/*.gz /pyboard/lib/static/js\n# around 12kB compared to uncompressed 40kB\n\nmkdir /pyboard/lib/templates/\ncp templates/* /pyboard/lib/templates/\n# around 20kB\n\ncp wifi_manager/* /pyboard/lib/wifi_manager/\ncp microdot/* /pyboard/lib/microdot/\ncp utemplate/* /pyboard/lib/utemplate/\ncp main.py /pyboard\ncp boot.py /pyboard\n# around 40kB\n```\n\n##### Install additional MicroPython packages\n\nAs this package has not been installed with `upip` additional modules are\nrequired, which are not part of this repo.\n\nConnect the board to a network and install the package like this for\nMicroPython 1.20.0 or never\n\n```python\nimport mip\nmip.install(\"github:brainelectronics/micropython-modules\")\n```\n\nFor MicroPython versions below 1.19.1 use the `upip` package instead of `mip`\n\n```python\nimport upip\nupip.install('micropython-brainelectronics-helper')\n```\n\n## Usage\n\nAfter all files have been transfered or installed open a REPL to the device.\n\nThe device will try to load and connect to the configured networks based on an\nencrypted JSON file.\n\nIn case no network has been configured or no connection could be established\nto any of the configured networks within the timeout of each 5 seconds an\nAccessPoint at `192.168.4.1` is created.\n\nA simple Picoweb webserver is hosting the webpages to connect to new networks,\nto remove already configured networks from the list of connections to\nestablish and to get the latest available networks as JSON.\n\nThis is a list of available webpages\n\n| URL | Description |\n|-----|-------------|\n| `/`   | Root index page, to choose from the available pages |\n| `/select` | Select and configure a network |\n| `/configure` | Manage already configured networks |\n| `/scan_result` | JSON of available networks |\n| `/shutdown` | Shutdown webserver and return from `run` function |\n\nTo leave from the Webinterface, just press CTRL+C and wait until all threads\nfinish running. This takes around 1 second. The device will return to its REPL\n\n<!-- Links -->\n[ref-esptool]: https://github.com/espressif/esptool\n[ref-remote-upy-shell]: https://github.com/dhylands/rshell\n[ref-brainelectronics-test-pypiserver]: https://github.com/brainelectronics/test-pypiserver\n[ref-upy-firmware-download]: https://micropython.org/download/\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "MicroPython WiFi Manager to configure and connect to networks",
    "version": "1.12.0",
    "project_urls": {
        "Bug Reports": "https://github.com/brainelectronics/Micropython-ESP-WiFi-Manager/issues",
        "Homepage": "https://github.com/brainelectronics/Micropython-ESP-WiFi-Manager",
        "Source": "https://github.com/brainelectronics/Micropython-ESP-WiFi-Manager"
    },
    "split_keywords": [
        "micropython",
        "brainelectronics",
        "wifi",
        "wifimanager",
        "library"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "403eb4327d607582727bd55f3ca9f52ef11605f8deea362b550cdf822cd13250",
                "md5": "f7f816f16226b1f4cf79246f3909f261",
                "sha256": "e9b606a10f298b1c439b664df0aefca8a2f26a259ee0e7798889e182582eb1f0"
            },
            "downloads": -1,
            "filename": "micropython-esp-wifi-manager-1.12.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f7f816f16226b1f4cf79246f3909f261",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 100822,
            "upload_time": "2023-06-12T07:58:21",
            "upload_time_iso_8601": "2023-06-12T07:58:21.008325Z",
            "url": "https://files.pythonhosted.org/packages/40/3e/b4327d607582727bd55f3ca9f52ef11605f8deea362b550cdf822cd13250/micropython-esp-wifi-manager-1.12.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-12 07:58:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "brainelectronics",
    "github_project": "Micropython-ESP-WiFi-Manager",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "micropython-esp-wifi-manager"
}
        
Elapsed time: 0.11948s