Tools: Reading The Undocumented Mems Accelerometer On Apple Silicon...

Tools: Reading The Undocumented Mems Accelerometer On Apple Silicon...

reading the undocumented mems accelerometer on apple silicon macbooks via iokit hid

reading the undocumented mems accelerometer on apple silicon macbooks via iokit hid

apple silicon chips (M1/M2/M3/M4) have a hard to find mems accelerometer managed by the sensor processing unit (SPU). it's not exposed through any public api or framework. this project reads raw 3-axis acceleration data at ~800hz via iokit hid callbacks.

only tested on macbook pro m3 pro so far - might work on other apple silicon macs but no guarantees

the sensor lives under AppleSPUHIDDevice in the iokit registry, on vendor usage page 0xFF00, usage 3. the driver is AppleSPUHIDDriver which is part of the sensor processing unit. we open it with IOHIDDeviceCreate and register an asynchronous callback via IOHIDDeviceRegisterInputReportCallback. data comes as 22-byte hid reports with x/y/z as int32 little-endian at byte offsets 6, 10, 14. divide by 65536 to get the value in g. callback rate is ~100hz

you can verify the device exists on your machine with:

requires root because iokit hid device access on apple silicon needs elevated privileges

the sensor reading logic is isolated in spu_sensor.py so you can reuse it independently

place your wrists on the laptop near the trackpad and wait 10-20 seconds for the signal to stabilize. this uses ballistocardiography - the mechanical vibrations from your heartbeat transmitted through your arms into the chassis. experimental, not reliable, just a fun use-case to show what the sensor can pick up. the bcg bandpass is 0.8-3hz and bpm is estimated via autocorrelation on the filtered signal

reading the undocumented mems accelerometer on apple silicon macbooks via iokit hid

Source: HackerNews