ESP32-CSI-Tool icon indicating copy to clipboard operation
ESP32-CSI-Tool copied to clipboard

Amplitude/phase oscillates rapidly between upper and lower value

Open Yureien opened this issue 2 years ago • 3 comments

Describe the bug The amplitude and phase keeps on rapidly oscillating (often alternatively) between two values, one higher and one lower. What exactly causes this? What's the best way to mitigate?

Example: This is the amplitude for subcarrier #55:

[17.029386365926403, 12.0, 11.0, 20.223748416156685, 11.40175425099138, 11.045361017187261, 17.4928556845359, 10.770329614269007, 12.083045973594572, 11.40175425099138, 17.804493814764857, 17.4928556845359, 12.041594578792296, 18.110770276274835, 18.973665961010276, 12.165525060596439, 18.439088914585774, 10.816653826391969, 17.4928556845359, 21.400934559032695, 18.439088914585774, 10.198039027185569, 10.44030650891055, 18.110770276274835, 21.095023109728988, 17.804493814764857, 17.804493814764857, 17.804493814764857, 21.02379604162864, 20.591260281974, 17.804493814764857, 21.37755832643195, 16.278820596099706, 10.04987562112089]

Here's a graph: Figure_1

It's basically oscillating between a value around 10-12 and another around 17-21

Tool Settings

  • Baud Rate: 1552000
  • WiFi Channel per Device: The default (4?)
  • FreeRTOS > Tick rate (Hz): 1000

To Reproduce Steps to reproduce the behavior:

  1. Use active_ap along with an external device (laptop/phone etc) and record data.
  2. Observe amplitude/phase values oscillating between an upper value and a lower value.

Desktop (please complete the following information):

  • OS: Arch Linux
  • ESP-IDF Version: 3.3.1
  • ESP32-CSI-Tool Git Hash: f8f95a5edca2309fd9ac1ff57828acdc8893f05d

Yureien avatar Jul 29 '21 23:07 Yureien

Good question. Typically this CSI will go through a smoothing/denoising process which will eliminate high frequency changes like this, but I do not have any comment about why this should or should not be happening.

I think this is a very good question, and if you have any ideas of what might be causing this I would like to hear your thoughts. Can you help me and help this open source project by spending some time thinking/researching why something like this might be happening? That would be very helpful to the project. Thanks!

StevenMHernandez avatar Aug 02 '21 17:08 StevenMHernandez

As far as I know the local oscillators on the TX/RX ESP32 boards always have some level of drift against each other, this could be 20 to 100 ppm, which may result a few kHz of frequency shift on the WiFi bands. This causes certain phase shift across time frames. Also when you look at the phase of the subcarriers in the same packet, the phase of neighbour subcarriers are similar but slightly different, and the phase slowly moves towards the same direction across subcarriers.

The other dominant factor is probably the sampling clock, which is not synchronised across ESP boards. The CSI packets are probably coming at a pretty discrete rate (e.g. default 100 pkt/s, not sure what's the max rate it can get if the packets are sent back to back @StevenMHernandez have you got any information on this?), that phase gets larger and larger when the clock ticks. When the next CSI packet is received at the station, there is probably already plenty of phase offsets accumulated so the phase looks to be oscillating.

So I guess unless the phase offset can be somehow compensated, the phase values are not very useful for any applications.

yc541 avatar Sep 21 '21 14:09 yc541