Shop OBEX P1 Docs P2 Docs Learn Events
Sleep detector using PIR? — Parallax Forums

Sleep detector using PIR?

bulkheadbulkhead Posts: 405
edited 2006-01-21 16:24 in General Discussion
I came up with the idea (ironically, while lying awake at night) of using a stamp to track down my average time spent in bed before actually falling asleep. I'm sure it would yield some interesting data if it worked...Anways, would the PIR work for such an application? I guess it needs to be sensitive enough to detect tossing and turning (maybe even the movement of an arm or two under the covers) but not trigger during usual breathing.

The stamp could be programmed to mark a timer after its detected no movement for a set period of time (say, 10 minutes). I can't figure out how to get the stamp to shut off after completeting its task, or a way of storing the data (time) so I can check it the next morning. Anyone try this before?

Comments

  • metron9metron9 Posts: 1,100
    edited 2006-01-19 08:03
    Typically a person moves quite a bit while asleep at various times so movement alone will not really be accurate. The type of sleep you get (stages of sleep) is more important and REM sleep is a must for good health. Some people can get very good rem sleep and they don't need much sleep. Others never get much REM sleep and they usually get sick more often.

    One of the signs of sleep apnea (breathing stops and loud snoring and gasping for air) is what many think is insomnia. They lay awake and the clock spins into the wee hours, each time they look at the clock and say gee I have not fallen asleep yet when what is really happening is they keep waking up from a stage 1 or 2 sleep and don't realize they just woke themselves up with loud snore or an apnea wakes them up.

    So, your idea would tell how active a person is as they thrash around in the first 4 stages of sleep and when they do reach REM they would be very still, actually REM sleep paralyzes you while you are in it so you can’t move. I know a guy who wakes up sometimes and he is indeed paralyzed, can’t move a muscle, then it passes and he gets up.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-01-19 12:34
    If you were to aim the PIR a bit high, it could easily observe when you were up.

    If you had a second one aimed directly at you, it could recognize and record movements while in bed.

    What I am trying to say is that PIRs are optical devices and you can mask their field of vision. You might also enhance it with additonal lens.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • steve_bsteve_b Posts: 1,563
    edited 2006-01-19 16:44
    A ECG device would probably be better suited to this task.

    Or how about a 'deadmans' switch....the person holds a switch closed while trying to fall asleep. When they fall asleep, they relax and release the switch. Of course, when you wake up again you have to be conscious enough to graph the switch to record that you're awake.

    How many stages of sleep are there? 3 or 4?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-01-19 17:40
    My gf suffers from slight apnea and is a very sound sleeper, I take much longer to fall asleep myself and have noticed the pattern of her falling asleep. The first stages are common with all people, first while awake she has shallow and slightly irregular breaths, it transitions to shallow but regular breaths, then transistions to deep, regular breaths and finally to apnea (all of this occurs before REM, in the normal sleep cycle, you go "deep" before returning to the lighter REM stage). Using a sensitive microphone with proper filtering (good application for a neural net)·you could detect these transistions and classify the transition from one state to another as the point in which someone falls asleep.

    EEG is the most foolproof way of measuring the transition, but then you have to deal with electrodes and wires which you may entangle yourself in during the night.

    Ive had the idea for a while of having an intelligent alarm clock which has the abillity of waking you within a pretermined range of time you set to wake you at a shallow point of sleep (waking you at the latest time specified if you sleep deeply throughout the interval). The benefit of the alarm clock is you feel more rested when woken and you are much less likely to hit the snooze button. I got stuck on how to design a passive EEG sensor net within a pillow, only to read a news story about 6 months ago that a team at MIT designed the exact same thing using standard EEG electrodes (My passive sensor is a better idea, but the inventive concept has been breeched, so I stopped thinking about it).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10

    Post Edited (Paul Baker) : 1/19/2006 5:43:50 PM GMT
  • John R.John R. Posts: 1,376
    edited 2006-01-19 22:16
    Paul Baker said...

    Ive had the idea for a while of having an intelligent alarm clock which has the abillity of waking you within a pretermined range of time you set to wake you at a shallow point of sleep (waking you at the latest time specified if you sleep deeply throughout the interval). The benefit of the alarm clock is you feel more rested when woken and you are much less likely to hit the snooze button. I got stuck on how to design a passive EEG sensor net within a pillow, only to read a news story about 6 months ago that a team at MIT designed the exact same thing using standard EEG electrodes (My passive sensor is a better idea, but the inventive concept has been breeched, so I stopped thinking about it).
    Paul;

    Somebody beat you to the punch.· I saw one of the snippets from the Consumer Electronics Show in 'Vegas on CNN with a wrist alarm clock that did just as you describe.· Set a range of time, and it rings at the lightest level of sleep (or the last minute...).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.

    8 + 8 = 10
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-01-19 22:58
    Interesting, I hadn't thought about using a wrist watch, very clever, they deserve the nascent market. It could be they saw the MIT article and thought of the improvement to the proof of concept approach. I am curious how they can monitor brain waves from a wrist though.

    As an aside, I thought of the idea while in grad school back in '98 when I struggled every morning to get to an 8:15 class aptly titled "Electronics and Biology: Using biology as inspiration to circuit design", one of my favorite classes taught by my graduate sponsor, it covered neural networks, coclear implants, retinal implants, neural bridges and other devices that either drew inspiration from biology or attempted to repair biological systems.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • bulkheadbulkhead Posts: 405
    edited 2006-01-20 03:20
    Well, I wasn't planning for anything really complicated to check out the different stages for sleep. All I'm wondering is how much time I spend lying awake at night thinking (about things) before falling asleep (which can be several hours). I've considered some consciously activated device (like a switch), but just sleeping in the presence of such a device would prolong the coming of sleep itself. It's kind of like trying to fall asleep, and not looking at the clock and worrying about how much you need to be asleep.

    I figure if I use the PIR, I can simply set up some IR leds and focus all of them on my bed, and every night, I could just go to sleep as I normally would. Since there is nothing actually on the bed, nothing to operate, and no noticeable change (since light source is IR), my sleep should be unaffected by it (physically, psychologically).

    Now that I consider it, it may be interesting to not only collect data on the last time there was movement before sleep, but also for every time I moved. I could assemble the data onto a graph, and figure out during which periods of time I moved the least. It would be interesting to compare the data for prolonged periods of sleep vs just a few hours, or sleeping with a good dream or a nightmare.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-20 04:08
    When I was 16 and just getting good in electronics I read an article about REM sleep and dream control.· The article told how they were able to determine when in a dream and so I actually built the device and tried it.· I think if I wasn't such as restless sleeper it may have actually worked for me.

    The concept was simple.· A pair of swimming goggles was painted black and had several holes drilled into each eyepiece.· As I recall there were about 15 holes in each one.· There were about 5 IR LEDs, 5 IR phototransistors and 5 standard Red LEDs.·

    The idea was that the controller would detect the moevment of the eyes in REM sleep by reading the phototransistors and measuring the IR light picked up.· When sufficient changes were detected it would flash a pattern on the Red LEDs which would usually manifest itself as red lights in your dreams.· This way you would always know you were in a dream.

    My problem was I always woke up with the goggles off and/or tangled up because I toss and turn all night!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • John BondJohn Bond Posts: 369
    edited 2006-01-20 14:37
    I’m replying mainly so I can keep track of any additional comments on this interesting post.
    ·
    Security against break-ins and robbery is an issue here in Africa so we’ve all been using PIRs extensively for years. They have got better as the technology has improved but they still have, in my opinion, major shortcomings. I feel that these devices are only suitable for random triggering when some “hot” object is moving in their “line of sight”.
    ·
    • Their range is variable. One time they’ll detect a person at 20 foot, the next they’ll miss one at 10.
    • They need considerable time to recover and stabilize after each time they are triggered.
    • The field of view for a particular unit changes. One time a 120Deg unit will detect at 120Deg, the next it’ll miss at 90Deg,
    • They are very dependent on temperature. Also, uneven temperature due to say an air conditioner can give you problems.
    • Direct sunlight disables them (not much problem here).
    ·
    You could do the same thing by measuring the change in the position of the body, possibly using a couple of pressure sensors under the mattress.
    You could measure the change in the distance (position) of your head or body using ultra-sonic.
    The ultimate would be to track your rate of movement with an accelerometer taped to your forehead but this means wires in the bed and I’m not sure I would want to do that.

    ·
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-01-20 15:07
    I guess what you are saying is that the physics of infrared is just too darned variable to get stable, reproducible readings. Often the environment flutuates, so there is no lock on calibration.

    Random triggering apparently means that you feel they won't get it 100% of the time.
    I am surprised about the changes in the field of view though.

    Seems like Parallax got it right by having a quite simple unit rather than try to achieve more in range or detailed motion sensing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • bulkheadbulkhead Posts: 405
    edited 2006-01-21 05:23
    Well, I looked in to the goggle idea, and it's a whole other world! There is already a pre-made one called the NovaDreamer ($699). It's the exact same concept-IR leds, IR phototransistors (I'm guessing), and red LEDs, except it also incorporates a buzzer. It's all in one nice unit though, no cords or electrical protrusions from the goggles. Still, I don't think it costs anywhere near $699 to make.

    It claims the ability to allow people to be conscious during their dreams(search "lucid dreaming"), which doesn't sound too far off. However, it also says it can let you read a whole book while you sleep (subconsciously) and communicate with the dead (in your dreams, based off your observations/experience of that person when they were alive). If it really could work miracles like that, it's a wonder more people don't use it.

    Anyways, as for my project, I'll probably just get some PIRs to experiment with (after all, that's the best way to know if it will work or not). I think making the dream goggles myself could be, well, dangerous since I'm new to this stuff (an electrical circuit over your face for 8+ hrs a day, IR light, etc). Plus, it's not exactly what I'm looking for, but if anyone else wants to look further into this, be my guest! This can really open up a whole new world...
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-21 07:47
    I think it's interesting it says this is based on this doctors 10 years of research.· But I built mine based on research from 20+ years ago.· =)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-01-21 13:56
    I thought of something last night while I was waiting for the gf's apnea to subside so I could sleep. The human body needs to dump some heat from the body in order to sleep, this is why if it is uncomfortably warm, it takes longer to fall asleep. If you're not the type to constantly fidgit with the covers, you may be able to detect the approximate time of sleep by taking the aggregate heat measurement and detecting the shift in temperature.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • steve_bsteve_b Posts: 1,563
    edited 2006-01-21 16:24
    You should see if there's a correlation between breathing patterns and pulse rates.
    I assume there is...but that it's not linear!

    As described through the stages of sleep, our breathing patterns change. This could mean a difference in pulse rate that someone could measure fairly easily compared to watching the whole body shift and such.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
Sign In or Register to comment.