repository of pip installable package for the cbt study and ecg study integration for the interaction lab fall 2025
Collects ECG signals from AD8232 heart rate sensor via ADS1115 ADC on Raspberry Pi.
- Raspberry Pi (tested on Pi 4)
- AD8232 ECG sensor module
- ADS1115 16-bit ADC
- I2C connection on bus 0
- Clone the repository:
git clone https://github.com/interaction-lab/cbt_ecg_integration.git
cd cbt_ecg_integration- Install in editable mode:
pip install -e . --break-system-packagesThis installs the package and all dependencies, and lets you edit the code. We need --break-system-packages for the RPI 4.
- Run the collector:
# Collect for 60 seconds at 250 Hz
ecg-collect -d 60 -r 250 -o test_data.csv
# Or continuous collection (Ctrl+C to stop)
ecg-collectecg-collect -d 60 -r 250 -o mydata.csvOptions:
-d, --duration: Collection duration in seconds (omit for continuous)-r, --rate: Sample rate in Hz (default: 250)-o, --output: Output CSV filename (default: auto-generated)
from ecgcollector import ECGCollector
collector = ECGCollector(sample_rate=250, output_filename="data.csv")
collector.collect_data(duration=60)CSV file with columns:
timestamp: Relative time in secondsvoltage: ADC voltage readingraw_value: Raw ADC value
I2C not enabled:
sudo raspi-config
# Interface Options -> I2C -> EnablePermission denied:
sudo usermod -a -G i2c $USER
# Log out and back inMIT License - see LICENSE file