Product III – Embodied Resonance – Data Logging via Serial Communication

A custom Python script was developed to record ECG and GSR data streamed from the Arduino via the serial interface. The Arduino transmits raw sensor values as comma-separated integers (ECG, GSR) at a fixed baud rate. On the computer side, the Python script establishes a serial connection, continuously reads incoming data, and stores it in a structured CSV file together with precise timing information. 

Serial connection and configuration

PORT = “/dev/tty.usbmodem1101”

BAUD = 115200

ser = serial.Serial(PORT, BAUD)

This section defines the serial port and baud rate used by the Arduino. The baud rate must match the value specified in the Arduino sketch to ensure correct data transmission.

Automatic file creation and session-based storage

start_stamp = datetime.now().strftime(“%Y%m%d_%H%M%S”)

csv_filename = f”{start_stamp}_ecg_gsr.csv”

Each recording session generates a new CSV file whose name includes a timestamp. This prevents accidental overwriting and allows recordings to be clearly associated with specific experimental sessions.

CSV structure and timing

writer.writerow([“timestamp”, “time_ms”, “ECG”, “GSR”])

start_time = time.time()

The CSV file contains both an absolute timestamp and a relative time counter in milliseconds. This dual timing system supports synchronization with experimental events while also enabling precise signal processing.

Parsing and writing incoming data

line = ser.readline().decode(errors=”ignore”).strip()

ecg_str, gsr_str = line.split(“,”)

ecg = int(ecg_str)

gsr = int(gsr_str)

Each line received from the serial port is expected to contain two comma-separated values. Basic validation ensures that malformed or incomplete lines are ignored.

Writing samples to CSV

time_ms = int((time.time() – start_time) * 1000)

timestamp = datetime.now().strftime(“%Y-%m-%d %H:%M:%S.%f”)[:-3]

writer.writerow([timestamp, time_ms, ecg, gsr])

For each valid sample, the script writes one row containing the current timestamp, elapsed time since the start of recording, and raw ECG and GSR values. Data is flushed to disk continuously to prevent loss during longer sessions.

Alina Volkova - a Ukrainian singer, sound producer, and DJ, performing under name Nina Eba. Her musical journey was shaped by her education at a music school, playing in rock bands, composing music for audio stocks, and working in television. In August 2024, she released her debut multi-genre mini-album MORPHO, followed by a remix compilation RE:MORPHIX, created in collaboration with 10 producers from different countries. Now she is master student at FH Joanneum/ KUG Sound Design Program and works on project Embodied Echoes.
Leave a Reply

Your email address will not be published. Required fields are marked *