Atmosphere Demo 1 Documentation (beta5 · Algorithm v2, first archive)

1. Project Overview

Atmosphere is a smart flash-flood & debris-flow monitoring and early-warning system for outdoor streams / drifting sites.

beta5 is the first archive of Algorithm v2: built on beta4, it adds an on-site LCD display, upgrades the model to v2 (sensor-calibrated + fast sliding baseline + hysteresis hold + soil-saturation rule), and integrates wind data over the network.

2. Hardware Wiring

Controller: Arduino Nano (ATmega328P, new bootloader)

3. Software Implementation

Two files (both included in this folder):

FlowSensor.ino — Arduino firmware (serial 115200, one JSON line per second):

server.py — Python web service (port 8080):

4. Warning Model (Algorithm v2)

Level system (larger number = more severe): 0 = Normal / 1 = Level 1 / 2 = Level 2 / 3 = Level 3 (highest)

Final level = max(Debris flow D, Flash flood F, Wind, Flow spike, Surge, Soil saturation)   ← 0~3

Debris-flow path:

D = 0.30·S̄ + 0.35·Q̄ + 0.20·dQ̄ + 0.15·ΔS̄

Flash-flood path (independent index):

F = 0.60·Q̄ + 0.40·dQ̄

Wind path: ≥25 km/h → Level 1; ≥40 km/h → Level 2; ≥60 km/h → Level 3

Flow-spike path: per-second change rate above local historical P95 → Level 2; normalized ≥ 0.8 → Level 1 (fallback when baseline insufficient: rate ≥ 0.5 L/min/s = full scale)

Surge path (second-level response): soil rises ≥ 20% within 5 s / wind rises ≥ 12 km/h within 60 s → Level 1 immediately

Soil-saturation path (new in v2): soil ≥ 85% or above local P90 → at least Level 1 (saturated soil is itself a hazard, independent of flow)

Hysteresis hold (new in v2): level upgrades take effect immediately and are held; downgrades only after the hold time — Level 1: 10 s / Level 2: 15 s / Level 3: 20 s (debounce)

Sliding baseline: 24 h window sampled once per minute; current value mapped onto the local [P10, P95] → 0~1; cold start 15 minutes; fallback to absolute values when insufficient (Qn=flow/3, dQn=rate/0.5)

5. How to Run

  1. Compile and upload FlowSensor.ino to the Arduino Nano (serial monitor at 115200)
  2. Run python3 -u server.py
  3. Open http://localhost:8080 in a browser; drag the slider to control pump speed
  4. Keep the wind service http://192.168.1.200:8001/wind online

6. Version Status

beta5 is the first archive of Algorithm v2: after Demo 1 ended, development moved to the algorithm-iteration phase (warning model v1→v2; docs under demo1/algorithm-iterations/). The ultrasonic water-level plan is dropped (overlaps with the flow sensor; no Manning 70%).

7. Known Issues