如何使用 MicroPython 在 ESP32 板上自动连接 Wifi
在这篇文章中,我们将研究如何在启动时连接到无线网络
首先,安装 ampy - 一个通过串口连接修改 MicroPython 文件系统的工具。
install_ampy.sh
pip install -U adafruit-ampy现在下载 main.py 并将其保存在当前工作目录中并插入你的 wifi 凭据:
main.py
import network
station = network.WLAN(network.STA_IF)
station.active(True)
station.connect("YourWifiName", "EnterYourWifiPasswordHere")将文件上传到板子:
ampy_put_example.sh
ampy -p /dev/ttyUSB* put main.py如果 ampy 在 5 秒内没有显示输出,尝试重置板子,等待 5-10 秒并使用 ampy 重试上传
注意:你可以使用以下命令列出板子文件系统上的文件
ampy_ls_example.py
ampy -p /dev/ttyUSB0 ls你可以使用以下命令验证 main.py 的内容
ampy_get_main.sh
ampy -p /dev/ttyUSB0 get main.pyCheck out similar posts by category:
Embedded, MicroPython, Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow