ESP-CSI Framework

repository·master·Indexed 23 days ago

https://github.com/espressif/esp-csi

A framework for wireless sensing using Channel State Information (CSI) on Espressif ESP32 series microcontrollers. It enables applications such as human presence detection, motion sensing, and wireless positioning. The repository includes the esp-crab RF phase synchronization solution for ESP32-C5, ESP RainMaker integration for mobile-app based radar, and the esp-csi-tool for real-time data visualization, calibration, and machine learning data collection.

Tokens
17.7K
Snippets
15
Records
92
Agent score
80%

What's inside ESP-CSI

  1. Overview of ESP-CSI

    master

    ESP-CSI is a framework for leveraging Channel State Information (CSI) on Espressif Wi-Fi MCUs to achieve non-contact intelligent sensing. By analyzing signal amplitude, phase, and delay, developers can detect physical environmental changes such as human movement, breathing, or chewing.

    Key features include:

    • Broad Hardware Support: Compatible with the entire ESP32 series (ESP32, ESP32-S2, ESP32-C3, ESP32-S3, ESP32-C5, ESP32-C6, ESP32-C61).
    • Rich Data: Provides RSSI, RF noise floor, reception time, and antenna 'rx_ctrl' fields.
    • Edge AI Ready: Dual-core 240MHz CPUs with AI instruction support for running machine learning models locally.
    • Bluetooth Assistance: Supports BLE scanning to assist in device detection.
  2. Advantages of OFDM in wireless communication

    master

    OFDM provides several key benefits that make it suitable for Wi-Fi and mobile communications (4G/5G):

    • Resistance to Multipath Interference: By decomposing the signal into multiple sub-signals on different frequencies, multipath interference only affects a portion of the sub-signals. Receivers can use equalization to mitigate this.
    • High Spectral Efficiency: Orthogonality allows sub-signals to overlap in the spectrum without causing interference, maximizing the use of available bandwidth.
    • Flexible Subcarrier Allocation: Subcarriers can be dynamically allocated based on real-time channel conditions to optimize transmission.
  3. Applications of CSI in Wireless Communication

    master

    Channel State Information (CSI) can be applied to optimize wireless communication performance through the following methods:

    • Spectrum Sensing: Detecting and sensing channel states to perform spectrum management and optimize spectrum utilization.
    • Interference Management: Identifying and suppressing interference sources to improve communication quality and system stability.
    • Resource Allocation: Performing dynamic resource allocation based on CSI to optimize system performance and communication efficiency.
  4. Applications of CSI in Wireless Positioning

    master

    CSI provides high-precision data suitable for advanced positioning tasks:

    • Precision Positioning: Achieving centimeter-level positioning accuracy, suitable for scenarios requiring high spatial resolution.
    • Pose Estimation: Estimating the pose and orientation of devices using CSI information to improve navigation and positioning accuracy.
  5. How OFDM is implemented using IFFT and FFT

    master

    Orthogonal Frequency Division Multiplexing (OFDM) relies on the mathematical relationship between time-domain and frequency-domain signals. In modern communication systems, this is implemented using Fast Fourier Transform (FFT) and Inverse Fast Fourier Transform (IFFT) modules:

    • Transmitter (Sender): Uses an IFFT module to convert frequency-domain signals (where each subcarrier carries its own data) into a time-domain waveform. This process effectively calculates the superposition of all subcarriers in the air.
    • Receiver (Listener): Uses an FFT module to mathematically remove the orthogonal subcarriers and extract the individual signal carried by each subcarrier.

    The Process Flow (Example):

    1. Data is split into symbols (e.g., 11011000 split into 11, 01, 10, 00).
    2. Pilot symbols (pilots) are added.
    3. IDFT/IFFT is applied to the complex symbols to generate the time-domain signal.
    4. Cyclic Prefix (CPG) is added.
    5. The signal is converted to digital data and transmitted via intermediate/high frequencies.
    6. The receiver performs the inverse operations to recover the data.
  6. Understand the CSI Raw Data Format

    master

    The CSI data is emitted as a CSV-style line containing metadata and a payload array.

    Data Structure

    • Metadata Fields: Includes type, id/seq, mac, rssi, rate, channel, local_timestamp, etc.
    • CSI Data Payload: Stored in the final data field as a JSON-formatted array [...].

    Subcarrier Representation

    For each subcarrier, the array stores the imaginary part followed by the real part in sequence: [subcarrier1_imag, subcarrier1_real, subcarrier2_imag, subcarrier2_real, ...].

    LTF Order

    The Long Training Field (LTF) order is: LLTF $\rightarrow$ HT-LTF $\rightarrow$ STBC-HT-LTF. Depending on the channel and grouping information, not all three LTFs may be present.

    Refer to the ESP-WIFI-CSI Guide for detailed LTF specifications.

  7. Use CSI for High-Precision Localization and Ranging

    master

    CSI serves as a more informative 'fingerprint' than traditional RSSI (Received Signal Strength Indicator) methods. While RSSI provides only signal strength, CSI provides signal amplitude and phase information across multiple subcarriers.

    Developers can use CSI for:

    • Fingerprinting: Utilizing the complex amplitude and phase data across subcarriers for indoor localization.
    • Ranging: Relying on frequency-selective fading models to obtain more accurate distance measurements compared to RSSI-based methods.
  8. Understand how CSI utilizes OFDM and MIMO subcarriers

    master

    Channel State Information (CSI) is derived from the characteristics of Orthogonal Frequency Division Multiplexing (OFDM) and MIMO technologies.

    In an OFDM system, the spectrum is divided into multiple orthogonal subcarriers that transmit data independently with minimal interference. In an OFDM-MIMO system, multiple antennas transmit different data streams simultaneously. Because the wireless channel (affected by multipath propagation and fading) impacts different subcarriers and antennas differently, observing the differences between the transmitted and received signals allows for the inference of channel state information, such as channel fading and phase shifts.

    To obtain CSI, you leverage the signal differences across these multiple subcarriers and multiple antennas.

  9. Understand wireless ranging methods (TOA, AOA, RSS)

    master

    Wireless ranging can be achieved through several fundamental methods, each with different requirements and accuracy levels:

    • Time of Arrival (TOA): Measures the time a signal takes to travel from transmitter to receiver. It requires precise clock synchronization between devices and is used for high-precision scenarios (e.g., GPS).
    • Angle of Arrival (AOA): Measures the angle at which a signal hits the receiver, typically using an antenna array. It uses geometric relationships to calculate the source position and works best in environments with minimal multipath effects (e.g., open spaces).
    • Received Signal Strength (RSS): Estimates distance based on signal attenuation. While simple to implement, it has lower accuracy because signal decay is heavily influenced by environmental factors.
  10. Subcarrier allocation in OFDM

    master

    In an OFDM symbol cycle, not all subcarriers are used for data transmission. Subcarriers are categorized into different types to optimize performance and stability:

    • Data Transmission Subcarriers: Used for carrying user data or other primary information.
    • Protection Subcarriers: Used for sending checksums and error correction information to enhance system stability and anti-interference capabilities.
    • Idle Subcarriers: Kept idle to provide guard intervals or serve other purposes.
  11. Understand the relationship between CSI and wireless channel characteristics

    master

    Channel State Information (CSI) provides detailed information about the wireless channel, allowing developers to leverage physical layer phenomena for advanced applications. CSI captures how signals are affected by the environment, enabling the following use cases:

    1. Multipath Beamforming

    Utilizes multipath effects to enhance or suppress signals in specific directions.

    • Beam Tracking: Using CSI to track changes in multipath propagation to optimize beam shapes and maximize signal strength.
    • Interference Suppression: Analyzing CSI to spatially suppress interference sources, improving the Signal-to-Interference Ratio (SIR).

    2. Localization and Tracking

    Uses multipath effects for precise positioning and movement monitoring.

    • Multipath Imaging: Analyzing CSI data to construct images of the environment for high-resolution position estimation.
    • Attitude Estimation: Estimating the direction and attitude of mobile devices using multipath effects.

    3. Multi-User MIMO Systems

    Combines CSI with multipath effects to improve spectral efficiency.

    • Multi-User Diversity: Receiving data streams from different users on different paths.
    • Spatial Multi-User Scheduling: Using CSI to schedule multiple users spatially to maximize throughput.

    4. Dynamic Spectrum Access and Spectrum Sensing

    • Optimizing Spectrum Utilization: Evaluating spectrum resource utilization and accessing spectrum blanks.
    • Spectrum Interference Detection: Rapidly detecting and localizing interference sources.

    5. High-Speed Mobile Communications

    • Mobile Channel Modeling: Establishing accurate models for high-speed environments.
    • Mobile User Tracking: Rapidly tracking and localizing high-speed users to maintain system stability.
  12. Understand wireless location measurement methods

    master

    Wireless location can be determined using three primary measurement techniques, each with different requirements and accuracy profiles:

    • Time of Arrival (TOA): Calculates distance by measuring the signal travel time. Requires precise clock synchronization between transmitter and receiver. Best for high-precision needs (e.g., GPS).
    • Angle of Arrival (AOA): Determines location by measuring the incident angle of the signal using antenna arrays. Best for environments with low multipath effects (e.g., open spaces).
    • Received Signal Strength (RSS): Estimates distance based on signal attenuation. It is simple to implement but has relatively low accuracy due to environmental interference.