micropython-websocket
适用于ESP32的MicroPython WebSocket-client模块。
安装方法
在Thonny中安装到ESP32:
- 用USB将ESP32连接到电脑
- 打开Thonny,右下角切换为 MicroPython(ESP32)
- 菜单 Tools → Manage packages
- 搜索
micropython-websocket - 点击安装
使用示例
import websocket
import network
import websocket
def do_connect():
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print("正在连接 Wi-Fi...")
wlan.connect("你的WiFi名称", "你的WiFi密码")
while not wlan.isconnected():
pass
print("已连接,IP:", wlan.ifconfig()[0])
do_connect()
# 创建连接(替换为你电脑的局域网 IP)
ws = websocket.create_connection("ws://192.168.1.109:8765")
ws.send("Hello, ESP32!") # 发送文本
reply = ws.recv() # 阻塞等待回复
print("收到回复:", reply)
ws.close() # 关闭连接
print("连接已关闭")
Metadata
Release files for micropython-websocket 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| micropython_websocket-1.0.5.tar.gz | 14.2 kB | Without provenance | Details for micropython_websocket-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| micropython_websocket-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for micropython_websocket-1.0.5-py3-none-any.whl |
Total release size: 32.8 kB
Release files / micropython_websocket-1.0.5.tar.gz
| Download URL | micropython_websocket-1.0.5.tar.gz |
|---|---|
| Size | 14.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7a6ae506a54ca440244ba04143f3661fd387601a2d0af6387d61a53101fb0c3
|
|
BLAKE2b-256 checksum How to use checksums |
e054aae7df653495b3fbbfa287cf7c6f487d7bcf4be7c889d8798bad8da95e79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.4
|
Release files / micropython_websocket-1.0.5-py3-none-any.whl
| Download URL | micropython_websocket-1.0.5-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c1d35c1727ca2c9ac2c5653a208ff7deb958cf0669cf5352568dbfb6e191710
|
|
BLAKE2b-256 checksum How to use checksums |
e7bf277cf30d7d7bb015367508d98b9554aa39b29362326e09ab72ce389c14cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.4
|
Security for micropython-websocket 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.