Skip to content

booty-chw/Data-Collection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Biosensor Data Collection System

多生物传感器数据采集系统

A complete solution for simultaneous data collection from multiple biosensors, supporting real-time data acquisition, transmission, and storage from devices suMQTT message format for all sensors:

这是一个用于同时采集多种生物传感器数据的完整解决方案,支持眼动仪、脑电图(EEG)和腕带(PPG)等设备的实时数据采集、传输和存储。

Project Structure 项目结构

.
├── source/
│   ├── common/          # Common utilities and data structures
│   ├── sensors/         # Sensor device implementations
│   │   ├── include/    # Sensor interface definitions
│   │   └── src/        # Concrete sensor implementations
│   │       ├── eye/    # Eye tracker device
│   │       ├── egg/    # EEG device
│   │       └── wristband/ # Wristband device
│   └── testCase/       # Test cases
├── script/             # Build and utility scripts
├── server/            # Server implementation
│   ├── src/           # Server source code
│   └── README.md      # Server documentation
├── thirdParty/        # Third-party dependencies
└── build/             # Build output directory

Supported Devices 支持的设备

  • Eye Tracker (眼动仪)
  • EEG Device (脑电图设备)
  • Biosensor Wristband (生物传感器腕带)

Database Structure 数据库结构

The system uses SQLite for data storage with the following schema:

-- Device registration table
CREATE TABLE devices (
    device_id INTEGER PRIMARY KEY,
    device_type TEXT,
    name TEXT,
    channels INTEGER,
    sampling_rate REAL,
    description TEXT,
    created_at DATETIME
);

-- Sensor data table
CREATE TABLE sensor_data (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    timestamp DATETIME,
    device_id INTEGER,
    channel_number INTEGER,
    value REAL,
    FOREIGN KEY(device_id) REFERENCES devices(device_id)
);

MQTT Message Format

{
    "device_id": "string",
    "timestamp": "ISO8601 string",
    "values": [ ]
}

Build Instructions 构建说明

Dependencies 依赖项

  • CMake (>= 3.10)
  • C++17 Compatible Compiler
    • Windows: Visual Studio 2019 or 2022
    • Linux: GCC 7.0 or higher
    • macOS: Clang 8.0 or higher
  • MQTT Broker (Mosquitto)
  • Python 3.7+
    • paho-mqtt
    • sqlite3

Windows Build Steps Windows 构建步骤

  1. Ensure Visual Studio 2019/2022 is installed (with C++ development tools) 确保已安装 Visual Studio 2019 或 2022(需要包含 C++ 开发工具)
  2. Install CMake (download from https://cmake.org/download/) 安装 CMake(可从 https://cmake.org/download/ 下载)
  3. Use build script: 使用构建脚本:
    # Normal build 普通构建
    script\build.bat
    
    # Clean and rebuild 清理并重新构建
    script\build.bat -c

Linux/macOS Build Steps Linux/macOS 构建步骤

  1. Using build script (recommended): 使用构建脚本(推荐):

    # Normal build 普通构建
    ./script/build.sh
    
    # Clean and rebuild 清理并重新构建
    ./script/build.sh -c
  2. Manual build: 手动构建:

    mkdir -p build
    cd build
    cmake ..
    make

Server Setup 服务器设置

  1. Install MQTT broker: 安装 MQTT 服务器:

    sudo apt-get install mosquitto mosquitto-clients
  2. Install Python dependencies: 安装 Python 依赖:

    cd server
    pip install -r requirements.txt
  3. Start the MQTT broker: 启动 MQTT 服务器:

    sudo systemctl start mosquitto
    sudo systemctl enable mosquitto
  4. Start the data collection server: 运行数据采集服务器:

    cd server
    ./script/server.sh start

Testing the System 测试系统

  1. Run comprehensive test: 运行综合测试:

    cd build/source
    ./test_all
  2. Individual sensor tests: 单个传感器测试:

    # Eye tracker test 眼动仪测试
    ./test_eye
    
    # EEG device test 脑电图测试
    ./test_egg
    
    # Wristband test 腕带测试
    ./test_wristband

Data Format 数据格式

MQTT message format for all sensors: 所有传感器的 MQTT 消息格式:

{
    "device_id": "string",
    "timestamp": "ISO8601 string",
    "values": ["", "", ""]
}

Database schema: 数据库结构:

-- Device registration table 设备注册表
CREATE TABLE devices (
    device_id INTEGER PRIMARY KEY,
    device_type TEXT,
    name TEXT,
    channels INTEGER,
    sampling_rate REAL,
    description TEXT,
    created_at DATETIME
);

-- Sensor data table 传感器数据表
CREATE TABLE sensor_data (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    timestamp DATETIME,
    device_id INTEGER,
    channel_number INTEGER,
    value REAL,
    FOREIGN KEY(device_id) REFERENCES devices(device_id)
);

Troubleshooting 故障排除

  1. MQTT Connection Issues MQTT连接问题

    • Check if the MQTT broker is running: systemctl status mosquitto
    • Verify MQTT port (default 1883) is open: netstat -an | grep 1883
    • Check MQTT logs: tail -f /var/log/mosquitto/mosquitto.log
  2. Device Connection Issues 设备连接问题

    • Check USB permissions (for eye tracker)
    • Verify Bluetooth is enabled (for EEG and wristband)
    • Check device battery level
    • Ensure correct device IDs are configured
  3. Database Issues 数据库问题

    • Verify database file exists: server/data/sensor_data.db
    • Check file permissions
    • Run integrity check: sqlite3 server/data/sensor_data.db "PRAGMA integrity_check;"
  4. Build Issues 编译问题

    • Verify CMake version: cmake --version
    • Check compiler version:
      g++ --version    # Linux
      clang++ --version # macOS
    • Ensure all dependencies are installed

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published