Home / References / ESP32 Library / WiFi API / AP
Description
The softAPIP()
method is used to retrieve the IP address of the ESP32’s soft Access Point (AP). This method is typically called after configuring the soft AP using softAP()
to obtain the assigned IPv4 address of the access point interface.
Syntax and Usage
The method can be used in two ways:
– Without arguments:
IPAddress local_ip = WiFi.softAPIP();
This method retrieves the IPv4 address of the soft AP interface.
Argument(s)
The function does not take any argument.
Return Value
The function will return the AP IP address in IPAddress format.
Example Codes
This code demonstrates how to use the ESP32 AP Class’s softAPIP()
method to retrieve the IP address of the ESP32’s Soft Access Point (AP). The ESP32 creates a WiFi network with the SSID “AvantMaker-ESP32-AP” and password “12345678”. The softAPIP()
method fetches the IPv4 address assigned to the AP, which is then printed to the Serial Monitor.
To use this code, upload it to your ESP32 and open the Serial Monitor at 115200 baud. Connect a device to the ESP32’s WiFi network using the SSID and password provided. The Serial Monitor will display the AP’s IP address, which you can use for further configuration or testing. Ensure your ESP32 is set up as an AP before running the code.
/*
* Author: Avant Maker
* Date: February 7, 2025
* Version: 1.0
* Description: This example code demostrates how to retrieve
* the IPv4 address of the AP device.
*
* License: MIT
*
* Code Source: This example code is sourced from the Comprehensive
* Guide to the ESP32 Arduino Core Library, accessible on
* AvantMaker.com. For additional code examples and in-depth
* documentation related to the ESP32 Arduino Core Library,
* please visit:
*
* https://avantmaker.com/references/esp32-arduino-core-index/
*
* AvantMaker.com, your premier destination for all things
* DIY, AI, IoT, Smart Home, and STEM projects. We are dedicated
* to empowering makers,learners, and enthusiasts with the resources
* they need to bring their innovative ideas to life.
*/
#include <WiFi.h>
void setup() {
Serial.begin(115200);
WiFi.softAP("AvantMaker-ESP32-AP", "12345678");
IPAddress apIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(apIP);
}
void loop() {
// Empty loop
}
AvantMaker Tutorial Suggestion
If you want to learn more about the ESP32’s WiFi capabilities, we’ve created a beginner-friendly guide that explains them in detail. Just click the link below, and you’ll be teleported to that page. It will clear up any confusion you may have while connecting your ESP32 to WiFi or setting it up as a WiFi access point (AP).
ESP32 Library Index
- ESP32 WiFiClient Library
- ESP32 HTTPClient Library
- ESP32 WiFiClientSecure Library
- ESP32 WebServer Library
- ESP32 WiFi Library
- Which ESP32 Boards are Recommended for Learners
- How to Copy Codes from AvantMaker.com
- What is SPIFFS and how to upload files to it?
- What is LIttleFS and how to upload files to it?
Ready to experiment and explore more about ESP32? Visit our website’s All About ESP32 Resources Hub, packed with tutorials, guides, and tools to inspire your maker journey. Experiment, explore, and elevate your skills with everything you need to master this powerful microcontroller platform!