GRADE 9: WI-FI FIRST / 九年级：先建立 Wi-Fi 连接
Start now with SAMPLE data. Sensors can be added later.
先使用示例数据，传感器之后再接入。

1. Keep your existing project backup. Open G9WiFiDashboard/G9WiFiDashboard.ino
   with AlertLogic.h in the SAME sketch folder. Use Arduino IDE with the installed
   Espressif ESP32 board package and your teacher-approved board and port.
2. This profile is for the CLASSIC ESP32, not C3/S3. It mirrors the existing G9
   CampusLightAlert starter: LED GPIO25, future ADC1 input GPIO34, Serial115200.
   Teacher must verify the actual board and existing resistor/LED circuit before
   power. Do not blindly change wiring. Set LED_PIN=-1 for dashboard-only mode.
   -1 is clearly reported as disabled. Match LED_ACTIVE_HIGH to the checked circuit.
3. Leave USE_SENSOR=false. Set GROUP to your short class/group label. The sketch
   adds six hexadecimal digits from the device MAC to reduce same-name clashes.
   Check SSIDs are distinct; change GROUP if a collision occurs. No student names.
4. AP_PASSWORD is PUBLIC DEMO text G9-demo-2026, not a private credential.
   Teacher: replace it with a class-only 8-63 ASCII-character password before use.
   Do not reuse a personal/school password. Maximum four clients per board.
5. Upload, open Serial Monitor at 115200, press reset if needed. Join the printed
   G9-A-xxxxxx Wi-Fi network from a laptop or phone. Choose to stay connected when
   told “no internet”. Open the exact http:// address printed by the board
   (normally http://192.168.4.1). Use HTTP, not HTTPS. No school network login.
6. Check SAMPLE DATA is visible. Predict alert state before each change. Compare
   the page to the physical LED. Try two browsers: both read the same board state.
   Unplug the board: the page must show STALE, not pretend the last value is live.
7. Press LED On or LED Off. Confirm that the LED holds that state as the
   reading and automatic alert keep changing. Press Return to Auto: the LED
   immediately follows the current automatic alert. A board reset starts in Auto.
   两个手动按钮可以固定 LED 的开关；读数继续更新。点 Return to Auto 恢复自动控制。
8. Preserve your own code and actual observations. No new homework/deadline is
   assigned by this starter. Do not record sample data as sensor measurements.

课堂检查：预测 → 观察网页 → 对比真实 LED。网页是电路板状态的读数，
不是 LED 真正发光的证明。断开连接后旧数据会标为 STALE（已过期）。
本材料不布置新的家庭作业或截止日期。

TODAY'S IDEA / 今天的重点
The board owns the alert. A read-only GET /state reports a snapshot. Browser
refreshes never change the state. The LED buttons send POST /led, and all
connected browsers see the same board-wide mode. The automatic alert always
updates, even when manual mode is holding the physical LED on or off.
Every 6 seconds the sample follows 2400,1600,900,1600 then repeats.
Starting OFF, predict: OFF,OFF,ON,ON. The two middle readings differ because
previous state differs. Less than1400 turns ON; greater than1800 turns OFF;
exact equality with either limit and the middle retain the previous state.
1400/1800 are example thresholds, NOT measured calibration. Counts are NOT lux.
电路板决定自动警报状态。刷新不会改变状态。中间值保持先前的自动警报状态。

SENSORS LATER / 之后使用传感器
Only after teacher checks the actual CLASSIC ESP32 and sensor parts:
- Unplug power before wiring. Use a 3.3V LDR divider, NEVER 5V into the ADC.
- Example topology: 3.3V -- LDR -- junction -- 10k resistor -- GND.
  Junction goes to GPIO34 (ADC1). This topology normally gives lower counts
  in darkness. GPIO34 is input-only and has no internal pull-up/down; the
  external divider is necessary. Do not connect a bare floating LDR input.
- GPIO34 is NOT a universal pin choice for ESP32-C3/S3 or other variants.
  Do not substitute GPIO0 or an ADC2 pin: classic ESP32 ADC2 conflicts with Wi-Fi.
- Set USE_SENSOR=true only after checking the unpowered circuit; upload again.
  The page now labels SENSOR INPUT. 12-bit ADC raw counts are not calibrated lux.
  ADC_11db on classic ESP32 has an approximate measurable upper range 3.1V;
  a 3.3V-powered divider may saturate near the rail. Repeated/railed/overlapping
  readings require revisiting the circuit/conditions, not claiming accuracy.
- Record actual low/high ranges; choose justified ordered thresholds from those
  data. Check low/high and middle from both previous states. Keep old versions.

PRIVACY AND LIMITS
WPA2-PSK local access point only. No router join, no cloud, no remote scripts,
fonts, telemetry, or credential form. Anyone connected to this board’s Wi-Fi
can use its LED controls. HTTP is plaintext inside
this small classroom network: do not send private information. Follow classroom
wireless rules; power off boards after class. A page response is not proof of
LED wiring, physical light accuracy or student completion.

VERIFICATION
Host C++ logic tests pass (boundaries, retained middle state and sample cycle).
Dashboard JavaScript syntax and simulated control flows checked. Arduino CLI/core compiler is unavailable
in this cloud workspace: full ESP32 compilation, upload, RF and physical board
checks are NOT TESTED. Teacher should verify one board before distributing.

PRIMARY SOURCES (checked 2026-11-18)
Espressif Arduino Wi-Fi: https://docs.espressif.com/projects/arduino-esp32/en/latest/api/wifi.html
Espressif ADC API: https://docs.espressif.com/projects/arduino-esp32/en/latest/api/adc.html
Espressif WebServer example: https://github.com/espressif/arduino-esp32/tree/master/libraries/WebServer/examples/WebServer
Classic ESP32 ADC/pins: https://docs.espressif.com/projects/esp-idf/en/v5.2/esp32/api-reference/peripherals/adc_oneshot.html
