12. Wi-Fi
The ESP32-S3 supports the 2.4 GHz Wi-Fi 4 (802.11n) standard, providing data transmission rates up to 150 Mbps. It supports STA (Station) mode, AP (Access Point) mode, and Wi-Fi Direct mode, and can flexibly connect to other devices or create its own network.
The ESP32-S3 also supports hardware-accelerated Wi-Fi encryption algorithms, including WPA/WPA2-PSK and WPA3-SAE encryption. This makes encrypting and decrypting data faster, improving the overall performance and security of the system.
The Wi-Fi library supports configuring and monitoring the ESP32 Wi-Fi networking function.
It has three modes:
Station mode(i.e., STA mode or Wi-Fi client mode), where the ESP32 connects to an access point (AP).AP mode(i.e., Soft-AP mode or Access Point mode), where stations connect to the ESP32.AP-STA coexistence mode(the ESP32 acts as an access point while also connecting to another access point as a station at the same time).
Official MicroPython reference link: http://www.86x.org/en/latet/library/network.WLAN.html
python
# AP mode allows the user to configure the ESP32 as a hotspot,
# which makes wireless connections between multiple ESP32 chips possible
# without the help of an external router network.
import network
ap = network.WLAN(network.AP_IF) # Create a hotspot
ap.active(True) # Activate the hotspot
# Configure the hotspot name, channel, encryption method, and password
ap.config(essid='LCKFB', channel=5, authmode=3, password="12345678")
# Connect the ESP32 to a WiFi network
"""
import time
import network
# Set the router WiFi account and password
ssid = 'qwer'
password = '12345678'
# Create a WIFI connection object
wlan = network.WLAN(network.STA_IF)
# Activate the wlan interface
wlan.active(True)
# Scan accessible WiFi networks
print('Scanning surrounding signals:', wlan.scan())
print("Connecting to WiFi", end="")
#
wlan.connect(ssid, password)
# If the connection is not successful, print a '.' in the console every 0.1s
while not wlan.isconnected():
print(".", end="")
time.sleep(0.1)
# After the connection is successful, print the IP, netmask, gateway (gw), and DNS address
print(f"\n{wlan.ifconfig()}")
"""1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42