Detecting Motion via WIFI Channel State Information using a RPI4 with patched firmware. Use case: Detect motion through walls using Wi-Fi signals and a Raspberry Pi by capturing Channel State Information (CSI) from 802.11 beacons.
- Introduction
- Hardware Requirements
- Setup
- Run the Wi-Fi Sensing Script
- Interpretation of Data Display
- Credits
This project demonstrates how Wi-Fi signals—specifically, CSI extracted from on-board Raspberry Pi Wi-Fi—can be used for detecting motion, even through walls, by analyzing reflections/absorption caused by the human body or moving objects.
Notes:
- CSI comes from OFDM-based 802.11 beacons; this works best in the 5 GHz band.
- On many routers, 2.4 GHz uses DSSS (not OFDM), which is less suitable.
- Use channels like 36/80 or 157/80, which are commonly supported by default patches.
- This setup disables on-board Wi-Fi communication; make sure to use an Ethernet connection to access the Pi, alternatively use a second USB wifi dongle on WLAN1 to access the Pi.
- Raspberry Pi 4 Model B (or similar Pi with onboard Wi-Fi).
- USB Wifi Adaptor
-
Flash 32 Bit Raspberry Pi - Legacy OS onto your SD card. This is important as we need to patch the firmware of the Raspbery Pi.
-
Update and upgrade packages:
sudo apt update -y && sudo apt upgrade -y sudo reboot -
Install picsi on a Raspberry Pi, which is a Python tool for installing and managing Nexmon CSI on Raspberry Pi: Ensure Python 3 and pip are installed: picsi requires Python 3.7 or newer. Raspberry Pi OS usually comes with Python 3 pre-installed. You'll also need pip for Python
sudo apt install python3-pip pip3 install picsi
Update your PATH (optional but recommended): To ensure the picsi command is readily available in your terminal, update your shell's PATH variable:
source ~/.profile
Install Nexmon CSI firmware/binaries: picsi handles the installation of Nexmon CSI, which involves downloading or compiling the necessary firmware and binaries for your specific Raspberry Pi model. Execute the following command:
picsi installEnable picsi
picsi enableThis enables Nexmon CSI and starts CSI collection. You can view the status using picsi status or stop it with picsi down.
-
Set Raspberry Pi Firmware for Channel State Information:
#/bin/bash # run at start up #Run this script to setup your CSI parameters and bring up Mon0 - the monitoring interface on wlan0 makecsiparams -c 157/80 -C 1 -N 1 -b 0x80 # bring wlan0 up sudo ifconfig wlan0 up # nexutil -Iwlan0 -s500 -b -l34 -v m+IBEQGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== # create interface mon0 sudo iw dev wlan0 interface add mon0 type monitor # set mon0 up sudo ip link set mon0 up
-
Create the python scripts, wifi_sensing.py & matrix.py
located in the github repository -
Create the script start.sh
#/bin/bash python3 -u wifi_sensing.py | python3 matrix.py
-
Run the script
sudo chmod +x ./start.sh ./start.sh
I am yet to figure out how to interpret the data on the Console GUI display. Let me know if you have any ideas.
This is a variation on code found in this guide:
Credit: Mikhail Zakharov, published December 20, 2021
License: GPL-3.0+ (https://www.hackster.io/mzakharo/wifi-sensing-via-raspberry-pi-ff1087)
