# esp32-24ghz-waveshare

> ESP32 project that creates an open Wi-Fi Access Point with a captive portal and a live web dashboard showing mmWave radar sensor data read over UART (last frame + basic presence status).

- Author: Mikrobot.pl
- Platform: ESP32
- Board: ESP32 Dev Module (`esp32:esp32:esp32`)
- SDK version: 3.3.6
- Tags: #esp32, #captive-portal, #waveshare, #home-assistant, #mmwave, #uart
- Created: 2026-03-05
- Updated: 2026-03-05
- Favorites: 4, forks: 0
- Project page (view, flash from the browser, fork): https://flashesp.com/explore/9FAR0yxEKUOPnsRa9jxC5
- Download all sources (zip): https://flashesp.com/api/public-projects/9FAR0yxEKUOPnsRa9jxC5/download-sources/

## Source files

- [main.ino (6.2 KB)](https://flashesp.com/explore/9FAR0yxEKUOPnsRa9jxC5/files/dxO9ZkmwCe5t89oLLoP3h.md)
- readme.md (2.4 KB)

## README

# ESP32 mmWave Captive Portal (UART)

This project turns an ESP32 into an **open Wi-Fi Access Point** with a **captive portal** (no login page) and a simple web UI that displays live data from a **24GHz mmWave presence sensor** connected over **UART**.

When a phone/laptop connects to the AP, the device is redirected to the portal automatically (DNS wildcard), where it can view:
- last raw UART message received from the sensor
- last update age (ms)
- a basic presence flag (simple keyword-based detection, easy to replace with a real parser)

## Features
- Open Wi-Fi AP (no password) for quick setup
- Captive portal using DNS wildcard (redirects any domain to ESP32)
- Web dashboard (`/`) + JSON endpoint (`/data`)
- UART reader using `HardwareSerial(2)` (ESP32 Serial2)
- Minimal HTML UI with 1s auto-refresh

## Hardware
- ESP32 (any common dev board)
- 24GHz mmWave radar presence sensor module with UART (3.3V logic)

## Wiring (UART)
> UART is cross-wired: TX -> RX, RX -> TX

| Sensor Pin | ESP32 Pin |
|----------:|:----------|
| 3V3       | 3V3       |
| GND       | GND       |
| TX        | GPIO16 (RX2) |
| RX        | GPIO17 (TX2) |

### Notes
- Power and UART levels should be **3.3V**.
- If your sensor uses a different baud rate, update `SENSOR_BAUD` in the code.

## Software Requirements
- Arduino IDE (or PlatformIO)
- ESP32 board support: **“ESP32 by Espressif Systems”**

### Libraries
No external libraries required (these are included with the ESP32 Arduino core):
- `WiFi.h`
- `WebServer.h`
- `DNSServer.h`

## How to Use
1. Flash the firmware to your ESP32.
2. Power the ESP32 and connect your phone/PC to the Wi-Fi network:
   - **SSID:** `mmWave-Portal`
3. The captive portal should open automatically.
   - If it doesn’t, open a browser and go to: `http://192.168.4.1/`
4. Watch the live sensor updates on the web page.

## Configuration
Edit these constants in the sketch:
- `AP_SSID` / `AP_PASS` (leave empty for open AP)
- `SENSOR_RX_PIN` / `SENSOR_TX_PIN`
- `SENSOR_BAUD`

## Sensor Data Parsing
Different mmWave modules output different protocols (ASCII lines or binary frames).
This example shows:
- raw UART line (best-effort line reader)
- a simple presence detector based on keywords

To make it accurate for your module, replace `updatePresenceFromLine()` with a parser that matches your sensor’s documentation.

## Endpoints
- `GET /` – web UI
- `GET /data` – JSON status:
  - `presence` (bool)
  - `age_ms` (number)
  - `last_raw` (string)

## License
MIT
