# XIAO-WEB-LED-CONTROLLER-AP

> A Wi-Fi access point with automatic redirection and a live-updating web UI that controls the onboard LED.

- Author: FlashESP
- Platform: ESP32
- Board: XIAO_ESP32S3 (`esp32:esp32:XIAO_ESP32S3`)
- SDK version: 3.3.2
- Tags: #esp32, #led-control, #web-control, #wifi-ap, #captive-portal
- Created: 2025-11-30
- Updated: 2025-11-30
- Favorites: 2, forks: 1
- Project page (view, flash from the browser, fork): https://flashesp.com/explore/OMO1I40jKgXoQxSbpmXTR
- Download all sources (zip): https://flashesp.com/api/public-projects/OMO1I40jKgXoQxSbpmXTR/download-sources/

## Source files

- [main.ino (4.0 KB)](https://flashesp.com/explore/OMO1I40jKgXoQxSbpmXTR/files/tiPk7R2I1GuJjdpw0Jn5S.md)
- readme.md (1.3 KB)

## README

## Overview

This project creates an **open Wi-Fi AP** using the XIAO ESP32S3 and provides a web interface that allows users to turn the onboard LED **ON** or **OFF**.  
The interface automatically opens due to captive portal DNS routing and shows the LED state **live** via a `/state` JSON endpoint.

Features:
- Open Wi-Fi AP with captive portal auto-redirect
- Web UI for turning LED ON/OFF
- Live LED state indicator using AJAX polling
- Minimal network traffic for responsive updates
- Fully contained in a single `.ino` sketch

---

## Hardware

- **Board:** Seeed Studio XIAO ESP32S3  
- **Onboard LED:** GPIO 21, active LOW  

No other components are needed.

---


## Wi-Fi Access Pointt

SSID: XIAO-AP-WEBLED
Password: (none)
Address: 192.168.4.1

All DNS queries are mapped to ESP32 → **captive portal behavior**.

---

## Web Interface

The interface provides:

- Current LED state (live)
- ON button
- OFF button

JavaScript polls the `/state` endpoint every 500 ms:

```json
{ "led": "OFF" }When a button is clicked, the browser sends:

/on
/off
```

The LED updates instantly.

How to Use

Upload the sketch.

Connect to AP: XIAO-AP-WEBLED.

The browser should open the controller page automatically.

Click Turn LED ON / Turn LED OFF.

Watch the live indicator update instantly.
