Skip to content

Using multiple ESP32 devices communicating with each other using ESP-NOW to collect and log Channel State Information (CSI) data

License

Notifications You must be signed in to change notification settings

nipunchamikara/csi-data-collection-firmware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32 CSI Data Collection Project

This project involves multiple ESP32 devices that communicate with each other using ESP-NOW to collect and log Channel State Information (CSI) data. Each device is flashed with the same program, with the default device ID changing the first time. The device ID is persisted, allowing the same program to be flashed to all devices. Device 0 logs all sent and received payloads, which contain CSI data. The system uses a timeout mechanism and follows a round-robin protocol where each device sends a packet once the previous device has sent a packet.

How It Works

  1. Flashing the Devices: Each ESP32 device is flashed with the same program. The default device ID is set during the first run and is persisted for subsequent runs.
  2. Device 0: Device 0 logs all sent and received payloads, which contain CSI data.
  3. Timeout System: The system uses a timeout mechanism where each device waits for a certain number of iterations before sending a packet. The number of iterations is based on how many devices away the device is from the previous device.
  4. Round-Robin Protocol: The devices follow a round-robin protocol where each device sends a packet once the previous device has sent a packet.
  5. Piggybacking CSI Data: The devices piggyback CSI data on the ESP-NOW packets they send to the broadcast address.

Building and Flashing

To build and flash the firmware to the ESP32 devices, you need to have the ESP-IDF installed. If you haven't already installed the ESP-IDF, follow the instructions in the ESP-IDF Programming Guide. The Makefile assumes that the ESP-IDF is installed in the ~/esp/esp-idf directory. If it is installed in a different directory, update the IDF_PATH variable in the Makefile.

Next, add the ports for the ESP32 devices to the Makefile:

PORTS = /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3

These ports can be found by running the following in the terminal:

ls /dev/tty*

First, install and configure ESP-IDF:

make install

Before building and flashing, configure the project:

make configure

The following configuration options are available specific to the project under the Project Configuration menu:

  • Total Devices: The total number of ESP32 devices in the network.
  • Set Device ID?: Boolean value whether to set the device ID or not. If checked, the device ID can be set.
  • Device ID: The device ID of the ESP32 device. This is only available if Set Device ID? is checked.
  • Less Interference Channel: The channel with less interference. This is the channel that the ESP32 devices will use for communication.
  • Send Frequency: The frequency at which the ESP32 devices send packets to each other.
  • Timeout: The number of frequency cycles before the next device sends a packet again.

To build and flash the firmware to the ESP32 devices, use the following commands:

make build
make flash DEVICE=<device_id>
make monitor DEVICE=<device_id>

Replace <device_id> with the device ID of the ESP32 device you want to flash. The device ID should be an integer. If the device ID is not specified, the default device ID is 0.

To flash the firmware and then monitor the serial output, use:

make flash-monitor DEVICE=<device_id>

To clean the build directory, use:

make clean

Logging

The first device (device 0) logs all sent and received payloads to the console in the form of comma-separated value. The header of the log is as follows:

type,time_index,device_id,recv_device_id,mac,rssi,rate,sig_mode,mcs,cwb,smoothing,not_sounding,aggregation,stbc,fec_coding,sgi,noise_floor,ampdu_cnt,channel,secondary_channel,timestamp,ant,sig_len,rx_state,len,csi_data

The following columns have been added to the log:

  • time_index: This is used to determine which iteration the data was sent or received. It is also used to identify the packets that were sent and received at the same time.
  • device_id: The device ID of the device that sent the packet.
  • recv_device_id: The device ID of the device that received the packet.

Contributing

Contributions are welcome! For feature requests, bug reports, or questions, please open an issue.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Appendix

Obtaining payload data from callback function wifi_csi_rx_cb

Vendor Specific Action Frame

MAC Header Category Code Organization Identifier Random Values Vendor Specific Content FCS
24 bytes 1 byte 3 bytes 4 bytes 7-1532 bytes 4 bytes

Vendor Specific Element Frame

Element ID Length Organization Identifier Type Reserved More data Version Body
1 byte 1 byte 3 bytes 1 byte 7-5 bits 1 bit 3-0 bits 0-1490 bytes

The payload data of the Wi-Fi packet is obtained from the wifi_csi_info_t structure using the payload field. It starts with the Category Code of the Vendor Specific Action frame. This means, the payload of the ESP-NOW packet begins at index 15.

About

Using multiple ESP32 devices communicating with each other using ESP-NOW to collect and log Channel State Information (CSI) data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published