StevenMHernandez / ESP32-CSI-Tool

Extract Channel State Information from WiFi-enabled ESP32 Microcontroller. Active and Passive modes available. (https://stevenmhernandez.github.io/ESP32-CSI-Tool/)
https://stevenmhernandez.github.io/ESP32-CSI-Tool/
MIT License
265 stars 72 forks source link

Amplitude/phase oscillates rapidly between upper and lower value #27

Open Yureien opened 3 years ago

Yureien commented 3 years ago

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

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):

StevenMHernandez commented 3 years ago

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!

yc541 commented 2 years ago

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.

Paco-Danes commented 11 months ago

Hello, same issue here. The extracted amplitudes are very very variable over subcarriers but also over time (considering a single subcarrier). image

Thise is a plot for a single subcarrier over ONLY 1 second (100 packets, since the rate is 100pk/s). Is it normal that it changes so rapidly every 10ms ?