MUMANDALAY UNIVERSITYDEPARTMENT OF PHYSICS · GROUP 2
PROJECT SUPERVISOR

U Lin

Lecturer · Department of Physics, Mandalay University

04 ELECTRONIC · GROUP 2 PROJECT

Automatic Fan
Speed Controller

An ESP32-based room temperature controller. The LM35 measures the temperature, and the 9V DC fan responds automatically or through manual control.

ESP32LM35I²C LCD9V DC FAN
ROOM STATUSOFFLINE
Temperature--.-°C
FAN OUTPUT--%
CONTROL MODE—

DEVICE LINK

ESP32 Wi-Fi Connection

The ESP32 joins your room Wi-Fi at startup. Connect your phone or computer to that same network, then enter the ESP32 address shown in Arduino IDE Serial Monitor.

Not connected

Best setup: open this page from the ESP32 web server at its local address. A GitHub Pages HTTPS page may be blocked from calling the ESP32's local HTTP API.

FAN SETTINGS

Control Panel

0%
0% · STOP100% · MAX
Connect to the ESP32 to enable controls.
i

Simple Connection Setup

1. Put the room's 2.4 GHz Wi-Fi name and password in the ESP32 sketch. 2. Power on the board and read its local IP in Serial Monitor. 3. Keep the phone and ESP32 on the same Wi-Fi and open the web app from the ESP32 address. Press Connect to claim the controls. One user can control the fan at a time; other visitors see when it is in use.

ESP32 firmware connection requirements

This page expects the ESP32 web server and API to be on the same origin. The device must enforce the single-controller lock; a page-only lock is not enough.

  • GET /api/status returns JSON such as {"temperature":28.6,"fanSpeed":62,"mode":"auto","fanOff":false,"occupied":false,"controlGranted":false}.
  • POST /api/connect with {"clientId":"…"} claims control. Return a token on success, or HTTP 423 with {"code":"in_use"} if another user holds the lock.
  • POST /api/status with {"token":"…"} returns status to the controlling client. POST /api/heartbeat and POST /api/disconnect also use the token. Renew the control lease every 6 seconds and expire it after about 20 seconds without a heartbeat.
  • POST /api/control accepts {"token":"…","mode":"manual"}, {"token":"…","mode":"auto"}, {"token":"…","speed":65}, or {"token":"…","off":true}. Each returns JSON such as {"ok":true}.

A GitHub Pages HTTPS page may be blocked from calling a local ESP32 HTTP API. For reliable control, open the copy served by the ESP32 at its local address.