yahboom
HomeTutorialsProduct
Solution
Blog
Online Store
About Us
EN/中文
Store
ESP32 Core Board📖
1. ESP32 Introduction
  • 1. ESP32S3 Overview
  • 2. Environment Setup Introduction
  • 3. Dev Board Introduction
2. ESP-IDF Development Tutorial
1. Before Development
  • 1. Environment Setup (Windows)
  • 2. Environment Setup (Linux)
  • 3. Build and Flash
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. ESP_TIMER
  • 5. GPTIMER
  • 6. Watchdog Timer
  • 7. DMA
  • 8. ADC
  • 9. PWM Breathing LED
  • 10. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication Experiment
  • 2. I2C_OLED Display Experiment
  • 3. SPI Bus Communication Experiment
  • 4. PSRAM External Memory Experiment
  • 5. Flash Read and Write Experiment
  • 6. USB Emulated Mass Storage Experiment
4. FreeRTOS operating system
  • 1.FreeRTOS Core Concepts Theory
  • 2.Task Creation and Management
  • 3.Queue
  • 4.Binary Semaphore
  • 5.Mutex
  • 6.Event Groups
  • 7.Software Timer
  • 8.Task Scheduler
  • 9.Low Power Mode
  • 10.Deadlock
  • 11.Priority Inversion
5. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Client Experiment
  • 5. UDP Server Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. Socket Programming Basics
  • 9. HTTP Client Experiment
  • 10. HTTP Server Experiment
  • 11. MQTT IoT Communication Protocol
  • 12. WIFI OTA Upgrade
  • 13. Bluetooth Fundamentals
  • 14. Bluetooth Slave Mode
  • 15. Bluetooth Master Mode
6. Audio Applications
  • 1.I2S Microphone Recording and U-Disk Playback
  • 2.I2S Audio Playback Experiment
  • 3.Repeater Experiment
7. Xiaozhi AI Voice
  • 1. Burn Xiaozhi Firmware
  • 2. Network and Configuration
  • 3. AI Agent Settings
  • 4. Program Analysis
  • 5. Free Chat
3. Arduino Development Course
1. Before Development
  • 1. Environment Setup
  • 2. Build and Flash
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. ESP_TIMER
  • 5. GPTIMER
  • 6. Watchdog Timer
  • 7. ADC
  • 8. PWM Breathing LED
  • 9. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication
  • 2. I2C OLED Display
  • 3. SPI Bus Communication
  • 4. Flash Read and Write
  • 5. USB Emulated Mass Storage
4. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Server Experiment
  • 5. UDP Client Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. HTTP Client Experiment
  • 9. HTTP Server Experiment
  • 10. MQTT IoT Communication Protocol
  • 11. WIFI OTA Upgrade
  • 12. Bluetooth Fundamentals
  • 13. Bluetooth Slave Mode
  • 14. Bluetooth Master Mode
5. Audio Applications
  • 1.I2S Microphone Recording and U-Disk Playback
  • 2.I2S Audio Playback Experiment
  • 3.Repeater Experiment
4. MicroPython Development Course
1. Before Development
  • 1. Environment Setup
  • 2. Build and Flash
  • 3. Thonny IDE
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. TIMER_IT
  • 5. Watchdog Timer
  • 6. ADC
  • 7. PWM Breathing LED
  • 8. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication Experiment
  • 2. I2C_OLED Display Experiment
  • 3. SPI Bus Communication Experiment
  • 4. Flash Read and Write Experiment
  • 5. Print Storage
4. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Client Experiment
  • 5. UDP Server Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. HTTP Client Experiment
  • 9. HTTP Server Experiment
  • 10. MQTT
  • 11. Bluetooth Fundamentals
  • 12. Bluetooth Slave Mode
  • 13. Bluetooth Master Mode
5. Audio Applications
  • 1. I2S Audio Playback Experiment
  • 2. Repeater Experiment
Download
  • Code
  • Hardware_Info
  • 3D_Model_File
  • Software_Tools
  • VMware
  • VM_File
Download ZIP

Welcome to ESP32 Core Board repository

2. WIFI STA Mode

WIFI STA Mode Experiment


WIFI STA Mode Experiment1. WIFI STA Mode Overview2. Core Concepts2.1 How STA Mode Works2.2 Network Configuration Parameters2.3 Core API3. Hardware Dependencies3.1 ESP32-S3 WiFi Hardware Features4. Project Architecture and Flow5. Source Code Explained5.1 Configuration Parameters5.2 STA Connection (No Retry Limit, Loop Until Success)5.3 Printing Network Information5.4 Main Program Entry6. Operating Procedures6.1 Flashing and Running6.2 Expected Results6.3 Serial Output Example6.4 Verification Methods7. Common Problems


1. WIFI STA Mode Overview

STA (Station, client mode) is the most common way for the ESP32-S3 to go online — just like a phone connecting to WiFi, it actively connects to an existing wireless router or hotspot, obtains an IP address, and then can access the Internet or other devices on the LAN.

This experiment configures the ESP32-S3 in STA mode; after connecting to a specified WiFi network, it prints the network status information (IP, mask, gateway, DNS, signal strength).

Typical application scenarios:

Application TypeExample
IoT devicesSmart home sensors report data to the cloud
Data acquisitionTemperature/humidity nodes send data to a server via WiFi
OTA upgradeDownload firmware updates from a server
Time synchronizationConnect to an NTP server to obtain network time

In STA mode the ESP32-S3 is a "client" and needs an existing router/hotspot to access. If you need the ESP32-S3 to create its own hotspot, refer to the WIFI AP Mode experiment.


2. Core Concepts

2.1 How STA Mode Works

+---------+                  +----------+
| Router  | <-- WiFi -->     | ESP32-S3 |
|(hotspot)|     2.4GHz       |  (STA)   |
+----+----+                  +----------+
     |
     |-- Internet
     |-- other devices on the LAN

In STA mode, the ESP32-S3 actively scans for and connects to a router; the router assigns the IP address, subnet mask, gateway, and DNS via DHCP.

2.2 Network Configuration Parameters

ParameterDescriptionValue Used in This Experiment
SSIDWiFi name"Yahboom2" (modifiable in code)
PasswordWiFi password"yahboom890729"
Retry mechanismNo upper limit; wait 3s and reconnect on failure until successwhile True loop
Retry intervalWait after a failed connection3s

2.3 Core API

​x
import network
​
wlan = network.WLAN(network.STA_IF)     # create STA interface
wlan.active(True)                        # activate
wlan.connect("SSID", "password")        # connect to AP
wlan.isconnected()                      # check if connected
ip, mask, gw, dns = wlan.ifconfig()    # get network config
wlan.config('ssid')                     # read config
wlan.status('rssi')                     # read RSSI
wlan.disconnect()                       # disconnect
wlan.active(False)                      # deactivate

3. Hardware Dependencies

The ESP32-S3 has a built-in 2.4 GHz WiFi module, no external hardware needed. A 2.4 GHz WiFi hotspot (router or phone hotspot) must be available nearby.

3.1 ESP32-S3 WiFi Hardware Features

FeatureParameter
WiFi standardIEEE 802.11 b/g/n
Operating band2.4 GHz
Max transmit power+21 dBm (11b)
Max receive sensitivity-97 dBm (11b)
Supported protocolsWPA/WPA2/WPA3 personal/enterprise
AntennaOn-board ceramic antenna / IPEX external antenna
Operating modesSTA / AP / STA+AP / Sniffer
Channel range1 ~ 14

4. Project Architecture and Flow

xxxxxxxxxx
Script execution (single-file .py)
  |
  |- wifi_connect(): connect in a loop with no retry limit; print IP after connecting
  |- wifi_info(): print IP/mask/gateway/DNS/signal strength
  |
  |- main():
       |- connect to WiFi (while True until connected)
       |- print network info (IP/mask/gateway/DNS/RSSI)

5. Source Code Explained

Full source code: Source Code -> MicroPython -> 4.Network Protocols -> WiFi_STA -> WiFi_STA.py

5.1 Configuration Parameters

The SSID and password can be modified according to the actual environment; RETRY_WAIT controls the retry interval after a connection failure.

xxxxxxxxxx
WIFI_SSID   = "Your Wi-Fi SSID"      # Wi-Fi SSID
WIFI_PASS   = "Your Wi-Fi password"  # Wi-Fi password
RETRY_WAIT  = 3                      # retry interval (s)

5.2 STA Connection (No Retry Limit, Loop Until Success)

The while True loop runs until connected; each round checks the connection for 15s, and on failure it waits RETRY_WAIT seconds before retrying, with no limit on the number of attempts.

xxxxxxxxxx
def wifi_connect():
    """Connect WiFi, loop until connected"""
    wlan = network.WLAN(network.STA_IF)  # create STA interface
​
    print(f"[STA] Connecting to '{WIFI_SSID}' ...")
    while True:
        try:
            wlan.active(False)
            time.sleep_ms(500)
            wlan.active(True)
            time.sleep_ms(200)
​
            if wlan.isconnected():
                print(f"[STA] Already connected. IP: {wlan.ifconfig()[0]}")
                return wlan
​
            wlan.connect(WIFI_SSID, WIFI_PASS)
            for _ in range(15):                     # 15s timeout
                if wlan.isconnected():
                    print(f"[STA] Connected! IP: {wlan.ifconfig()[0]}")
                    return wlan
                time.sleep(1)
        except OSError as e:
            print(f"[STA] OSError: {e}")
        print(f"[STA] Retrying in {RETRY_WAIT}s...")
        time.sleep(RETRY_WAIT)

The retry count is no longer limited — the while True loop runs until connected. Each round checks the connection status within 15s, and after failure it waits 3s and retries automatically.

5.3 Printing Network Information

ifconfig() returns (IP, subnet mask, gateway, DNS), and status('rssi') returns the signal strength in dBm.

xxxxxxxxxx
def wifi_info(wlan):
    cfg = wlan.ifconfig()
    print(f"  IP      : {cfg[0]}")
    print(f"  Mask    : {cfg[1]}")
    print(f"  Gateway : {cfg[2]}")
    print(f"  DNS     : {cfg[3]}")
    print(f"  RSSI    : {wlan.status('rssi')} dBm")

ifconfig() returns a (IP, subnet mask, gateway, DNS) quadruple, and status('rssi') returns the signal strength; the closer to 0, the stronger the signal (e.g. -40 dBm is good, -80 dBm is weak).

5.4 Main Program Entry

Calls wifi_connect() which blocks until connected, then prints the IP/mask/gateway/DNS and signal strength.

xxxxxxxxxx
def main():
    wlan = wifi_connect()                        # connect to WiFi
    wifi_info(wlan)                              # print network info

6. Operating Procedures

6.1 Flashing and Running

Thonny IDE steps: See MicroPython -> 1. Before Development -> 3.Thonny IDE.

  1. Modify the WIFI_SSID and WIFI_PASS in the code to an actually available WiFi network
  2. Open WiFi_STA.py in Thonny IDE and click Run

6.2 Expected Results

After a successful connection, the IP address and network parameters are printed; you can ping the IP to verify network reachability.

6.3 Serial Output Example

xxxxxxxxxx
[STA] Already connected. IP: 192.168.11.229
  IP      : 192.168.11.229
  Mask    : 255.255.255.0
  Gateway : 192.168.11.1
  DNS     : 192.168.11.1
  RSSI    : -9 dBm

串口打印

6.4 Verification Methods

OperationExpected Result
Enter correct SSID/passwordConnection succeeds, IP is printed
Enter a wrong passwordRetries every 3s until connected
After successful connection, ping <IP> (on PC)Can ping the ESP32-S3

7. Common Problems

SymptomCauseSolution
Keeps printing retriesWrong SSID/password or too weak signalConfirm the WiFi is 2.4 GHz (the ESP32-S3 does not support 5 GHz), check the password
IP obtained as 0.0.0.0DHCP did not assign an IPCheck whether the router's DHCP service is working properly
WIFI Network Basics
WIFI AP Mode

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文