XLoBorg - Motion and direction sensor for your Raspberry Pi

XLoBorg - Accelerometer and Magnetometer (which can provide compass functionality) board for your Raspberry Pi

Accelerometer - Freescale MMA8452Q 3-Axis, 12-bit/8-bit Digital Accelerometer datasheet here

Magnetometer - Freescale MAG3110 3-Axis magnetometer

XLoBorg accelerometer and magnetometer schematic