Home » Python
As you sleep, the motion of the heart beat and resulting surges of blood around the body cause the body and bed to shake. Just a bit, but enough to detect with a MEMs accelerometer like the orientation sensor in your phone as well as in step counting fitness trackers. A good paper on the subject is here: NIH paper
You can use this effect to detect heart rate, respiration rate, heart rate variance (a good measure of stress) as well as sleep/wake times; all while you sleep without needing to wear a device. This is key since to collect sleep data over months/years, it is important that the process be transparent to the user; just tape the sensor to the edge of the mattress and forget about it.
This approach has been studied for 100 years and has been made practical by emergence of cheap, sensitive technologies like MEMs. Joonas Paalasmaa’s (co-founder of Beddit – acquired by Apple) paper on the subject “unobtrusive online monitoring of sleep at home” is here on Pubmed
Withings Nokia have a set of connected health devices which allow you to track your activity, blood pressure, weight, fat mass, temperature, sleep etc.