Skip to content

abbas-dm/Smart-Occupancy-Based-Automation-using-Wi-Fi-CSI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📡 CSI-Based Wireless Sensing Using ESP32

🧠 Project Overview

This project demonstrates how Channel State Information (CSI) from Wi-Fi signals can be used to sense environmental changes.
A Wi-Fi router acts as the transmitter, and an ESP32 acts as the receiver, collecting CSI data in real time.
The variance of CSI values is analyzed to detect changes in the wireless channel, such as movement or interference.
When significant variation is detected, the ESP32 controls an LED via a GPIO pin to indicate the change.


🎯 Objectives

  • To extract CSI data from Wi-Fi packets using ESP32.
  • To analyze CSI variance for detecting environmental changes.
  • To demonstrate real-time physical response using GPIO control (LED).
  • To visualize CSI data and behavior through serial or Python script (optional).

⚙️ System Architecture

Wi-Fi Router (Transmitter) │ ▼ ESP32 Receiver ├── Captures CSI packets ├── Calculates CSI variance ├── Controls LED via GPIO └── Sends data to serial (optional Python visualization)


🧩 Hardware Requirements

  • ESP32 Development Board
  • Wi-Fi Router / Access Point (for packet transmission)
  • LED + Resistor (connected to GPIO pin)
  • Jumper wires and breadboard
  • (Optional) Laptop/PC for real-time data visualization via Python

🧠 Working Principle

  1. The Wi-Fi router periodically transmits packets on a fixed channel.
  2. The ESP32 receiver captures CSI data for each incoming Wi-Fi packet.
  3. CSI samples are processed in firmware to calculate variance over time.
  4. If the variance exceeds a threshold (due to movement or disturbance),
    the ESP32 activates the LED.
  5. The LED acts as a physical indicator of CSI variation, representing environmental change.

📜 Firmware Implementation (ESP32)

  • Framework: ESP-IDF

  • Key APIs:

    • esp_wifi_set_csi_rx_cb() – register CSI receive callback
    • esp_wifi_set_csi_config() – configure CSI collection parameters
    • esp_wifi_set_csi(true) – enable CSI reporting
  • Processing Steps:

    1. Connect ESP32 to Wi-Fi network (same as router).
    2. In the CSI callback, extract CSI amplitude values.
    3. Compute rolling variance of CSI samples.
    4. Control LED based on variance threshold.

🖥️ Optional Python Visualization

If visualization is needed:

  • The ESP32 sends CSI variance values over serial.
  • A Python script reads serial data and plots it in real time using matplotlib or pyqtgraph.

Example output: CSI Variance < threshold → LED OFF CSI Variance > threshold → LED ON


🧪 Demonstration Flow (for 1-minute video)

  1. Start with LED OFF in a stable environment.
  2. Move your hand or an object between the router and ESP32.
  3. Observe LED turning ON when CSI variance increases.
  4. Move away → LED turns OFF as channel stabilizes.

Result:
ESP32 successfully detects environment changes using Wi-Fi CSI data without any external sensors.


📈 Applications

  • Human motion detection
  • Indoor localization
  • Wireless sensing for smart environments
  • Gesture recognition
  • IoT-based anomaly detection

🧩 Future Scope

  • Implement multi-device CSI collection for spatial awareness.
  • Apply machine learning to classify motion or gestures.
  • Extend system for real-time visualization dashboards.
  • Integrate with cloud platforms for IoT analytics.

About

CSI-powered sensing with ESP32! Detect Wi-Fi signal changes, process CSI data, and trigger LED responses for real-time wireless environment awareness.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors