admin管理员组文章数量:1530914
1、简介
Wi-Fi
设备有两种模式:
1.Access Point(AP
) 模式,此为无线接入点,家里的光猫就是结合WiFi和internet路由功能的AP。
2.Station(STA
)模式,此为 无线终端,连接到AP的装置,手机,电脑等需要联网的设备都是工作在STA模式。
2、官方文档
Quick reference for the ESP32 — MicroPython latest documentation
3、micropython实战
import network
import time
from socket import *
wlan = network.WLAN(network.STA_IF) //创建一个网络对象,并将其设置在STA模式
wlan.active(True) //激活wlan
if not wlan.isconnected():
print('connecting to network...')
wlan.connect('lig', '15601') //这里写你自己的WIFI名称 密码
while not wlan.isconnected():
pass
print('network config:', wlan.ifconfig())
udp_socket=socket(AF_INET,SOCK_DGRAM)
dest_addr=('192.168.8.116',8080) //这里写你自己网络调试助手上显示的IP地址和端口
send_data='hello_world'
udp_socket.sendto(send_data.encode('utf-8'),dest_addr)
使用的网络调试助手下载链接:http://free.cmsoft/download/cmsoft/assistant/netassist5.0.2.zip
截图如下:
打开端口,运行上面的程序 ,如果能在网络调试助手上面观察到发送的字符。
则说明通信ok!本节试验成功!
参考:ESP32学习(3)——连接WIFI_esp32连接wifi-CSDN博客
本文标签: wifi
版权声明:本文标题:esp32连接wifi 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1726808326a1085255.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论