README
Wi-Fi CSI Occupancy Detection
Example Summary
The WiFi CSI Occupancy Detection example detects whether a room is empty or occupied using Wi-Fi Channel State Information (CSI) on the LP-EM-CC35X1. People moving in a room distort the Wi-Fi signal between the LaunchPad and an access point (AP). The device measures this distortion, extracts features on-device, and either streams them to TI’s Edge AI Studio to build a model or runs the trained model locally.
This example provides two projects:
| Project | What it does |
|---|---|
| edgeai_wifi_csi_occupancy_detection_data_capture | Streams CSI features to Edge AI Studio so you can record and label “empty” and “presence” data for training. |
| edgeai_wifi_csi_occupancy_detection_live_preview | Runs your trained model on the device and shows the live occupancy result in Edge AI Studio. |
Workflow: run edgeai_wifi_csi_occupancy_detection_data_capture, record labeled data, train and compile a model in Edge AI Studio, then export the model into edgeai_wifi_csi_occupancy_detection_live_preview Example.
Requirements
- LP-EM-CC35X1 LaunchPad connected to the PC over USB (LP-XDS110).
- A Wi-Fi access point. You need its SSID, password, security type and MAC address.
- A serial terminal, or Python 3 with
pyserialto use the included script. - Access to TI’s Edge AI Studio.
Project Contents
| File / folder | Description |
|---|---|
serial_automation.py, serial_config.json |
Script and settings that connect the device to your AP and start CSI. |
csi_stream.c/.h |
edgeai_wifi_csi_occupancy_detection_data_capture only. CSI preprocessing and streaming to Edge AI Studio. |
csi_presence.c/.h |
edgeai_wifi_csi_occupancy_detection_live_preview only. CSI preprocessing, model inference and result reporting to Edge AI Studio. |
ai_artifacts/ |
edgeai_wifi_csi_occupancy_detection_live_preview only. The compiled model (mod.a, tvmgen_default.h, user_input_config.h). Replace these with the files generated by Edge AI Studio. |
feature_extraction/ |
edgeai_wifi_csi_occupancy_detection_live_preview only. Feature extraction (FFT, normalization) feeding the model. |
dap/ |
Device Agent Protocol, the UART link to Edge AI Studio. |
adaptation/, freertos/ |
Board support, SysConfig file and linker script. |
network_terminal.c, wlan_cmd.c, other files |
Wi-Fi console and networking from the SDK Network Terminal example. |
Peripherals & Pin Assignments
CONFIG_UART2_0- XDS110 UART, used for Edge AI Studio (DAP) at 921600 baud.- edgeai_wifi_csi_occupancy_detection_data_capture: the console and DAP share this UART, so serial / debug console input is disabled once streaming starts.
- edgeai_wifi_csi_occupancy_detection_live_preview: the console and DAP share this UART, so serial / debug console input is disabled once streaming starts.
Example Usage
1. Build and flash
Build and flash edgeai_wifi_csi_occupancy_detection_data_capture to collect training data. If you already have a trained model, use edgeai_wifi_csi_occupancy_detection_live_preview.
2. Connect to your access point and start CSI
Use the included script, or type the commands yourself.
Option A: Script (recommended)
Install the dependency:
pip install pyserialEdit
serial_config.jsonin the project folder:{ "port": "COMXY", "ssid": "MyAccessPoint", "password": "my-password", "mac_address": "aa:bb:cc:dd:ee:ff" }Key Required Default Description portyes Serial port of the LaunchPad, e.g. COM59or/dev/ttyACM0ssidyes Access point name (no double quotes) passwordunless OPEN Access point password (no double quotes) mac_addressyes MAC address of the access point, aa:bb:cc:dd:ee:ffsecurity_typeno WPA2OPEN,WPA2,WPA2_PLUS,WPA3orWPA2/WPA3connect_timeoutno 60Seconds to wait for the AP connection and IP address log_fileno none Save all device output to this file The baud rate (921600) and CSI settings are fixed by the example. Timing and retry keys are listed at the top of
serial_automation.py.Close any existing serial terminal, then reset the board, and run the following commands within a fresh terminal:
python serial_automation.pySettings can also be given on the command line:
python serial_automation.py --port /dev/ttyACM0 --ssid MyAP --password secret --mac aa:bb:cc:dd:ee:ffUse
--config <file>to load a different settings file.
When it finishes, the script prints All commands sent successfully! and releases the serial port for Edge AI Studio. It exits with 0 on success, 1 if a step failed, and 2 for a settings error.
Option B: Manual
- Open the LaunchPad’s serial port in a terminal (921600 baud, 8N1, no flow control).
Enter:
wlan_start wlan_sta_role_up wlan_connect -s "<SSID>" -t WPA2 -p "<password>" csi_enable csi_config -s 1 -p 7 csi_set_mac -a 1 -m <AP MAC address> csi_get_resultscsi_config -s 1 -p 7is required: the example processes CSI at 128 Hz, which needs solicitation enabled (-s 1) with period-p 7.
3. Connect Edge AI Studio
After successful operation of step 2, the console prints DAP streaming ready and stops accepting input. Close the terminal, then open TI’s Edge AI Studio and select the serial port with baud rate 921600.
Note: Prior to launching the Edge AI Studio, flash the appropriate example to the LaunchPad.
- edgeai_wifi_csi_occupancy_detection_data_capture: configure Data Acquisition with the CSI sensor, label each class (empty / presence) and press Start Capture. Configure the
Number of CollectionsandWait Time Between Collection (s)in Edge AI Studio.
Warning : The default value for Samples is 256 and in the current iteration no other Samples value is supported.
- edgeai_wifi_csi_occupancy_detection_live_preview: open the live inference preview to see the result.
Example datasets
Pre-collected datasets are available if you want to train without capturing your own data:
| Dataset | Sample Size | Download |
|---|---|---|
| wifi_presence_detection_dsd_4400 | 4400 | zip |
| wifi_presence_detection_dsd_2000 | 2000 | zip |
| wifi_presence_detection_dsi | 800 | zip |
wifi_presence_detection_dsi is the default dataset enabled in CCStudio™ Edge AI Studio.
4. Train and deploy your model
- Train and compile the model in Edge AI Studio. For best results, select the WiFiPresDet_4.7k_CDE model. This presence detection model is tuned for the CSI pipeline in this example and the only one validated end to end on the LaunchPad.
- After compilation, export the compiled model from Edge AI Studio and extract the .zip file. Manually copy the following files into the edgeai_wifi_csi_occupancy_detection_live_preview project’s
ai_artifacts/folder, replacing the placeholder files:
| Source directories | File |
|---|---|
golden_vectors/ |
user_input_config.h |
artifacts/ |
mod.a |
artifacts/ |
tvmgen_default.h |
To validate the live preview and trained model performance, repeat sections 1-3.
How It Works
Both projects process each 2 s window of CSI the same way:
- Decode 54 subcarriers, drops DC subcarriers sub_26, sub_53, keeps 52 amplitudes.
- Interpolate the irregular packet arrival onto a uniform 128 Hz grid (256 points).
edgeai_wifi_csi_occupancy_detection_data_capture streams the result (timestamp + 52 subcarriers) to Edge AI Studio, which computes the remaining features for training. edgeai_wifi_csi_occupancy_detection_live_preview continues on the device: decimate to 128 rows, L2 normalize, RFFT over time (64 bins) and subcarriers (26 bins), log scale, giving a 64x26 model input. A 3-window soft average of the model output (threshold 0.5) gives the final decision.
Troubleshooting
| Symptom | Likely cause |
|---|---|
| Script cannot open the port | Another program (terminal, Edge AI Studio) is using it, or the wrong port is set. The LaunchPad exposes two serial ports; use the application/user one. |
Script reports pyserial is required |
Run pip install pyserial. |
| Connecting to the AP times out | Wrong SSID, password or security_type, or the AP is out of range. |
| Device disconnects from the AP after a while | The keepalive socket needs the access point, the LaunchPad and the host PC on the same network. Connect all three to the same AP / subnet. |
| Edge AI Studio cannot connect | The serial port is still open in a terminal or the script. |
Known Issues and Limitations
Host PC must be on the same AP as the LaunchPad. The keepalive socket used for CSI requires the host, the LaunchPad and the access point to be on the same subnet. Connecting the host to a different network may cause the device to disconnect after a short idle period.
AI artifacts must be copied manually. After training and compiling a new model in Edge AI Studio, the generated files must be manually copied into the
ai_artifacts/folder of the edgeai_wifi_csi_occupancy_detection_live_preview project.