Activity: Wi-Fi CSI Presence Detection

Activity: Wi-Fi CSI Presence Detection

animation
sensors
infrastructure

Activity: Wi-Fi CSI Presence Detection

This compact example demonstrates the core idea behind Wi-Fi Channel State Information (CSI) occupancy sensing. When a person moves through a Wi-Fi signal path, the CSI amplitude fluctuates more than in an empty room. Real deployments process many subcarriers, the separate frequency components within a Wi-Fi channel, over time. Variance measures how widely values spread around their average; comparing it with an empty-room baseline gives a simple occupancy clue:

TipTry the Decision Logic Without Code

Start by Observe CSI amplitude for an empty room and treat it as the baseline. Then Observe CSI amplitude while a person walks through the signal path. Next Compare how much the values fluctuate in each case. Finally Mark the room as occupied only when the current fluctuation is much larger than the empty-room baseline.

NoteOptional Python Pattern

This example illustrates how a program can process an infrastructure signal while keeping its proxy limits in view.

def variance(values):
    mean = sum(values) / len(values)
    errors = [
        (x - mean) ** 2
        for x in values
    ]
    return sum(errors) / len(values)

empty_room = [
    0.50, 0.51,
    0.49, 0.50,
]

person_moving = [
    0.20, 0.82,
    0.35, 0.75,
]

baseline = variance(empty_room)
current = variance(person_moving)
ratio = current / baseline

occupied = ratio > 2.0
print(f"variance ratio = {ratio:.1f}")
print(f"occupied = {occupied}")

Key design decisions:

Decision Choice Rationale
Window size 5 seconds Smooths transient noise while detecting walking pace movement
Assumed variance-ratio threshold 2.0× baseline Illustrative design target; compare with 1.5× under actual HVAC airflow
Subcarrier count 52 Standard for 802.11n 20 MHz channels
Calibration Empty-room baseline Accounts for room geometry and furniture reflections

Back to the chapter