Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

Ignore the stalker-like title.

I am thinking about creating a project with Arduino that can sense you sleep habits, when you're asleep, and how much you sleep. It would be convenient to not have to turn it on/off at night; it should know how to do this.

Some ideas that I have:

  • Motion sensor
  • Breathing patterns (if an Arduino microphone could even pick that out... I would be surprised if it could)
  • A RTC clock could assist in deciding It's midnight. Usual, Steve isn't asleep at this time on Fridays. He's probably not sleeping now. It won't always be there to help you, but you might be able to try to get more accurate results this way

How can I accomplish this? (Extra points for some sort of algorithm that can tell dozing off from a deep sleep.)

share|improve this question
    
Probably one way to detect sleeping state of someone is to measure heart pulses, and detect when pulses get below a threshold (different for each individual but that could be "guessed" by the system after a few days run). With this, you could even see if the person had some nightmares (pulse increasing) :-) That is intrusive (pulse sensor) but is also the only way to know about the sleep of ONE person when 2 are in the same room. –  jfpoilpret Mar 4 at 6:05
1  
Neurosky EEG brainwave sensor apparently works fine with Arduino. Measure frequency. Up to 4Hz --> NREM sleep. Up to 8-9Hz ---> REM sleep. Above 8-9 Hz up to 16Hz ---> awake, but eyes closed and relaxed. Above that ---> awake. –  Damon Mar 5 at 14:54

1 Answer 1

up vote 8 down vote accepted

I actually did something like this, using a PIR Motion sensor.

The motion sensor is good enough to detect a person turning in their sleep, and my simple algorithm just counts movements per minute and when its over a threshold (found by trial and error), it sounds the alarm to wake you up.

enter image description here

The image above represents my body movements during a night. The spikes represent a high movements/minute.

Here we see after about 30 minutes body motion was minimal. This suggests I was in a deeper stage of sleep during that time.

The spike at 250 minutes (around 4:30AM) is when I woke up only to realize I could sleep for couple of hours longer. I recall the time being 4:38 when I looked at my clock and I was already facing it. This means I turned around to face the clock but actually "woke up" 8 minutes later to see the time, and then turned back around (indicated by the shorter spike at 265).

The data suggests I was not able to sleep very well (compared to the time period between 30 and 240 minutes) after waking up once and finally got up at 400 minutes (7:00AM), when I shut everything down.

Here are a couple of posts from my blog that have a lot more information.

share|improve this answer
    
Thanks for the links on your blog. One question I have is how do you decide that someone isn't reading a book or watching TV while doing something while on a bed? It is some good data. Did you project need to be turned off when you got into bed? –  Annonomus Penguin Mar 4 at 0:27
    
Mine is an alarm clock so it only needs to detect movements during the half hour before the alarm goes off. So that's the only time that matters. The overnight graph is just to collect data to figure out how many movements/pin is considered "light sleep, easy to wake" –  sachleen Mar 4 at 0:39
    
do you have any suggestions on how to detect whether it's just idle or if it's sleep? I might have to do some of my own data... –  Annonomus Penguin Mar 4 at 1:00
    
I'd see how the graph looks for sleep vs various activities. Weigh that with the time of day (more likely to be sleeping 3am than reading). Hard to say without collecting lots of data. –  sachleen Mar 4 at 1:02
    
To help you with your googling, this technique is called actigraphy. Wikipedia has a decent intro. Some signal processing is apparently necessary, but nothing too difficult or beyond the capabilities of an arduino. To classify sleep stages (including awake), I would look at academic papers on the subject. One thing to decide is whether you want to put the sensors on your bed (easy, low accuracy), or on your wrist (harder, more accurate, and you can measure body temperature, ambient light, and skin conductivity). –  jjm Mar 5 at 3:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.