A minimal watchOS app that records fused motion from CMDeviceMotion on Apple Watch and saves it to CSV for later analysis.
- Adjustable sampling tick, default 50 ms, range 10 to 200 ms
- Rolling buffer with configurable max size (default ~5k rows)
- Live readout for accel, gyro, and attitude
- One tap Save CSV to the app Documents directory
I needed a simple, reliable way to capture watch motion for prototyping form tracking and model training, without wiring the phone or server yet.
- Uses
CMMotionManagerdeviceMotion stream - Captures the following per sample:
- Linear acceleration
userAcceleration.{x,y,z}in m/s² - Rotation rate
rotationRate.{x,y,z}in rad/s - Orientation
attitude.{roll,pitch,yaw}in radians
- Linear acceleration
- Keeps:
latestfor quick UI displaybufferfor the time series, capped atmaxBuffer
Header:
A minimal watchOS app that records fused motion from CMDeviceMotion on Apple Watch and saves it to CSV for later analysis.
- Adjustable sampling tick, default 50 ms, range 10 to 200 ms
- Rolling buffer with configurable max size (default ~5k rows)
- Live readout for accel, gyro, and attitude
- One tap Save CSV to the app Documents directory
I needed a simple, reliable way to capture watch motion for prototyping form tracking and model training, without wiring the phone or server yet.
- Uses
CMMotionManagerdeviceMotion stream - Captures the following per sample:
- Linear acceleration
userAcceleration.{x,y,z}in m/s² - Rotation rate
rotationRate.{x,y,z}in rad/s - Orientation
attitude.{roll,pitch,yaw}in radians
- Linear acceleration
- Keeps:
latestfor quick UI displaybufferfor the time series, capped atmaxBuffer
Header: idx,timestamp,ax,ay,az,gx,gy,gz,roll,pitch,yaw
Rows:
idxis a zero based counter within the current buffertimestampis Core Motion timestamp in seconds since the boot reference- Other columns are doubles
File name example: formfit-YYYYMMDD-HHMMSS-ms.csv
- Apple Watch paired to an iPhone
- Xcode version that matches your watchOS
- watchOS 10.6.1 pairs well with Xcode 15.4
- watchOS 11 pairs well with Xcode 16+
- Open
FormFitWatch.xcodeprojin Xcode. - Select the watch app scheme.
- Choose your real Apple Watch as the destination.
- Run. Grant Motion permission on first launch.
The watch simulator will not produce real motion values. Use a device for data.
In MotionManager.swift:
tickMs: sampling interval in millisecondsmaxBuffer: maximum number of samples to keep before trimming
You can also expose tickMs via the UI slider provided.
- Start, Stop, Clear, Save CSV
- Tick control with label that shows the current ms
- Optional live metrics block for quick sanity checks
- Add WatchConnectivity to transfer CSV to iPhone Files
- Add session metadata and calibration markers
- Build a quick visualizer notebook for CSV files
- Move to a ring buffer for O(1) trimming on long sessions
- Ensure
NSMotionUsageDescriptionexists in the target Info so the permission prompt is clear. - First install can take a moment while Xcode prepares the device.