Configure MicroPython WLAN/AP/WebRepl startup with your own code
Configure automatic startup of MicroPython WLAN / AP / WebRepl / NTP time during boot
The information given in the files
webrepl_cfg.py are used for configuration.
wlan.cfg and softap.cfg are text files containing ESSID and password in 2 lines
webrepl_cfg.py is a python file containing a single line like
PASS = '123456'
During wlan start the time from NTP is fetched by default.
- send cntrl+c
- upload the module file along with the configuration files directly (the config files are
- send reset
Sample Code (in boot.py)
from mpyconfigbase import * try: configbase = MPyConfigBase() configbase.start() except Exception as ex: print( "error:", ex ) print("set ntp time", configbase.ntp ) import time while True: print( "->", time.localtime( time.time() ) ) time.sleep(1)
Installation during deployment
The python class code can be retrieved by calling:
fnam, src = MPyConfigBase.get_class_source() # get the module code cfgbootcode = MPyConfigBase.get_boot_install_code() # get the minimal autconfig code
Sample Code (deployment)
Some sample code for automatic deployment and configuration. In case of timeouts (error message: could not enter raw-repl) consider to use
with mpyc.timeout(1) as tout: code block.
The code is also available here on github
Reset the board during the deployment is required since MicroPython needs to bring in the new code before the configuration can take place. If you follow the best practice given above this dont needs to be done.
on esp8266 the combined startup with
start will probably fail.
on esp32 it will work :-)
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for mpyconfigbase-0.0.4-py3-none-any.whl