【得捷电子Follow me第2期】+任务2:网络功能使用
[复制链接]
一.创建WiFi热点
Circuitpython创建和连接wifi都只需要一行代码,非常方便。
##开启热点 --------------------------------------------------------------------------------------
# SPDX-FileCopyrightText: 2020 Brent Rubell for Adafruit Industries
# SPDX-License-Identifier: MIT
import os
import wifi
print("ESP32-S3 Station Test")
wifi.radio.start_ap('zz', '12138888')
## end开启热点 --------------------------------------------------------------------------------------
二.连接WiFi
连接wifi并显示其ip
import board, os, wifi
from adafruit_display_text import bitmap_label
import terminalio
from adafruit_bitmap_font import bitmap_font
font = bitmap_font.load_font("fonts\wenquanyi_10pt.pcf")
color = 0x11FF11
wifi.radio.connect('ZZ', '12138888')
print(f"My IP address: {wifi.radio.ipv4_address}")
text2 = "IP地址: " + str(wifi.radio.ipv4_address)
scale = 1
text_area2 = bitmap_label.Label(font, text=text2, scale=scale)
text_area2.x = 10
text_area2.y = 30
board.DISPLAY.show(text_area2)
while True:
pass
2.rar
(456.9 KB, 下载次数: 0)
|