As part of her research at the MIT Media Lab, Anita Lillie did some investigations of her own sleep habits recording motion sensor data via Arduino –
I outfitted myself with sensors that would help me determine how my position changes over the course of a night’s sleep. I used three accelerometers as tilt sensors, placed on three different places on my body: my forehead, my forearm, and my upper leg.
All my processing and analysis was done in software I wrote in Python and Pygame, which parses the data set and creates graphs that categorize the sensor readings into sleep positions, and highlights them accordingly. The graphs show raw data, smoothed data, and color-code positions automatically.