yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
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

3. WIFI AP Mode

WIFI-AP Mode Experiment


WIFI-AP Mode Experiment1. WIFI-AP Mode Overview2. Core Concepts2.1 SoftAP Workflow2.2 Connection Detection Methods3. Hardware Dependencies4. Project Architecture and Flow5. Source Code Details5.1 Configuration and Global Variables5.2 setup() — Start AP5.3 loop() — Connection Status Monitoring6. Operation Flow6.1 Build and Flash6.2 Normal Phenomena6.3 Verification Methods7. Common Issues


1. WIFI-AP Mode Overview

WiFi AP (Access Point, Hotspot Mode) allows ESP32-S3 to act as a Wi-Fi hotspot. Other devices (phones/computers) can connect to it. ESP32-S3 internally starts a DHCP server to assign IP addresses, with the default subnet 192.168.4.x and the AP's own IP at 192.168.4.1. This experiment monitors connected station count changes in real-time and prints logs.

AP mode has irreplaceable application value in the IoT field. First, it is the foundation of network configuration technology - when a device is first deployed and no WiFi network is available, the device runs in AP mode first. The user's phone connects to the hotspot, then sends the router password to the device through a webpage or app, and the device switches to STA mode to connect to the network (this is the first step of the SmartConfig / Web Provisioning flow). Second, in scenarios without a router (field operations, construction site inspection, temporary exhibitions), AP mode allows users to directly connect to the device point-to-point for parameter configuration, status viewing, and firmware upgrades, without relying on any network infrastructure. Additionally, AP mode is widely used in local area network multi-person collaboration scenarios - multiple phones or computers connected to the same ESP32-S3 hotspot to achieve local chat, file sharing, multiplayer games, and other LAN applications.

Typical Application Scenarios:

Application TypeExample
Device ProvisioningPhone connects to ESP32 hotspot → Configure router password via webpage
Direct ControlPhone connects directly to ESP32, control peripherals via HTTP/TCP
Ad-Hoc LANMultiple ESP32s form a centerless self-organizing network

2. Core Concepts

2.1 SoftAP Workflow

WiFi.softAP(ssid, pass) creates an independent BSS (Basic Service Set), with internal automatic completion of: selecting the most free channel (1-13) → starting WPA2-PSK encryption → starting DHCP server → periodically sending Beacon frames to announce network presence.

2.2 Connection Detection Methods

Two ways to detect device connection/disconnection:

  • Polling (this experiment): Regularly call WiFi.softAPgetStationNum() to compare value changes

  • Event callback: WiFi.onEvent() listens for ARDUINO_EVENT_WIFI_AP_STACONNECTED/STADISCONNECTED events


3. Hardware Dependencies

Pure software experiment. ESP32-S3 has a built-in 2.4GHz Wi-Fi transceiver, and the default maximum number of SoftAP connections is 4.


4. Project Architecture and Flow

​x
setup()
  ├─ Serial.begin(115200)
  ├─ WiFi.mode(WIFI_AP)              // Pure AP mode
  └─ WiFi.softAP(SSID, PASS)         // Start SoftAP + DHCP

loop()
  ├─ now = WiFi.softAPgetStationNum() // Get current connection count
  ├─ if (now != last)                 // Count changed → Device joined/left
  │    ├─ Print "New device connected" or "Device disconnected"
  │    └─ Print current connection count
  └─ delay(500)

5. Source Code Details

Source code: Source code → Arduino → 3.Network Communication → WIFI_AP → WIFI_AP.ino

5.1 Configuration and Global Variables

xxxxxxxxxx
#include <WiFi.h>
const char* AP_SSID = "ESP32-S3-AP";
const char* AP_PASS = "12345678";       // WPA2 requires at least 8 characters
int current_stations = 0;

5.2 setup() — Start AP

xxxxxxxxxx
void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_AP);
  WiFi.softAP(AP_SSID, AP_PASS);

  Serial.printf("Hotspot Name: %s\n", AP_SSID);
  Serial.printf("ESP32 AP IP: %s\n", WiFi.softAPIP().toString().c_str());
}

WiFi.softAPIP() returns 192.168.4.1 (default), which can be customized via WiFi.softAPConfig(). DHCP automatically assigns 192.168.4.x addresses to connected devices.

5.3 loop() — Connection Status Monitoring

xxxxxxxxxx
void loop() {
  int now_stations = WiFi.softAPgetStationNum();

  if (now_stations != current_stations) {
    if (now_stations > current_stations)
      Serial.println("New device has connected to the AP!");
    else
      Serial.println("Device disconnected from the AP!");

    Serial.printf("Number of currently connected devices: %d\n", now_stations);
    current_stations = now_stations;
  }
  delay(500);
}

Polling is simple but has a maximum delay of 500ms. For scenarios requiring high real-time performance, it is recommended to use the WiFi.onEvent() event-driven approach.


6. Operation Flow

6.1 Build and Flash

Arduino flashing process: See Arduino → 1. Before Development → 2. Build and Flash.

  1. Build and flash

  2. Search for "ESP32-S3-AP" on phone/computer Wi-Fi, connect with password 12345678

6.2 Normal Phenomena

Serial output:

xxxxxxxxxx
==================================
 WiFi AP Started successfully
 Hotspot Name: ESP32-S3-AP
 Hotspot Password: 12345678
 ESP32 AP IP: 192.168.4.1
==================================
New device has connected to the AP!
Number of currently connected devices: 1

Connection success:

Connection Success

Disconnection:

Disconnection

6.3 Verification Methods

OperationExpected Result
Phone connects to hotspotSerial prints "New device connected", count +1
Phone disconnects from hotspotSerial prints "Device disconnected", count -1
Multiple devices connected simultaneouslyCount increases cumulatively

7. Common Issues

PhenomenonCauseSolution
Phone cannot find hotspot2.4GHz channel conflict with routerESP32 only supports 2.4GHz, confirm phone support
Cannot access internet after connectionAP mode does not include WAN exitNormal phenomenon - AP does not provide internet access
Cannot connect more than 4 devicesDefault maximum 4 STAsWiFi.softAPConfig() can modify, maximum 10
WIFI STA Mode
UDP Server Experiment

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
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文