Ever wondered whether WiFi could be used for more than just communication? This project demonstrates that WiFi signals that can be absorbed and reflected by human body can be used for detection of motion using just Raspberry Pi's on-board WiFi
CSI stands for Channel State information and is extracted from OFDM signals. We will be capturing 802.11 beacons because they are ubiquitous in 5GHz and easy to control on most routers. Note: On many routers still supporting 802.11b, 2.4GHz Beacons use DSSS instead of OFDM. OpenWRT based routers have the option to disable DSSS on 2.4GHz, while most OEM's don't offer such option. Moving forward, we will be working with 5Ghz band, specifically 36/80 or 157/80 channels, as supported by default patches.
NOTE: this procedure disables communication via on-board WiFi. Use Ethernet to access your Pi.
Setup- Use official 32 bit raspbian image and update it to latest
apt get update && apg-get dist-upgrade
reboot. - Enable CSI on Raspberry Pi by following this tutorial: seemoo-lab/nexmon_csi. If you encounter some challenges, you can also consult nexmonster where additional helpful setup scripts can be found. (Note: As of 20 Dec 2021, nexmonster was not updated for Raspberry Pi Kernel 5.10, which is supported by the official nexmon_csi project).
- Build makecsiparams and copy the resulting binary somewhere on your $PATH for ease of use.
After the last step of building and patching firmware, you should see something similar to:
COPYING brcmfmac43455-sdio.bin => /lib/firmware/brcm/brcmfmac43455-sdio.bin
UNLOADING brcmfmac
RELOADING brcmfmac
Then, configure the CSI extractor. (You may wish to add MAC filtering if you live in a busy area)
makecsiparams -c 157/80 -C 1 -N 1 -b 0x80
m+IBEQGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
ifconfig wlan0 up
#157/80
nexutil -Iwlan0 -s500 -b -l34 -v m+IBEQGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
#36/80
#nexutil -Iwlan0 -s500 -b -l34 -vKuABEQGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
iw dev wlan0 interface add mon0 type monitor
ip link set mon0 up
Prepare your Python environment
sudo apt install libatlas-base-dev
pip3 install numpy influxdb-client
To store our motion data we will use InfluxDB. You can get a free account with 30 day storage here: https://cloud2.influxdata.com/signup
In the attached code, fill INFLUXDB_URL/TOKEN/ORG/BUCKET variables in the atached wifi_sensing.py file.
If all goes well, you should see the following output:
root@raspberrypi:~# python3 csi_proxy.py
cnt 10
cnt 9
cnt 10
cnt 10
And motion on InfluxDB Data Explorer:
Comments