In Bed With An Arduino, Fighting Sleep Apnea

Marc with cannula and brain monitor

Sometimes the journey is as interesting as the destination, and that’s certainly the case with [Marc]’s pursuit of measuring his sleep apnea (PDF, talk slides. Video embedded below.). Sleep apnea involves periods of time when you don’t breathe or breathe shallowly for as long as a few minutes and affects 5-10% of middle-aged men (half that for women.) [Marc]’s efforts are still a work-in-progress but along the way he’s tried a multitude of things, all involving different technology and bugs to work out. It’s surprising how many ways there are to monitor breathing.

Debugging the Eeonyx conductive fabric approach
Debugging the Eeonyx conductive fabric approach

His attempts started out using a MobSenDat Kit, which includes an Arduino compatible board, and an accelerometer to see just what his sleeping positions were. That was followed by measuring blood O2 saturation using a cheap SPO2 sensor that didn’t work out, and one with Bluetooth that did work but gave results as a graph and not raw data.

Next came measuring breathing by detecting airflow from his nose using a Wind Sensor, but the tubes for getting the “wind” from his nose to the sensor were problematic, though the approach was workable. In parallel with the Wind Sensor he also tried the Zeo bedside sleep manager which involves wearing a headband that uses electrical signals from your brain to tell you what sleep state you’re in. He particularly liked this one as it gave access to the data and even offered some code.

And his last approach we know of was to monitor breathing by putting some form of band around his chest/belly to measure expansion and contraction. He tried a few bands and an Eeonyx conductive textile/yarn turned out to be the best. He did run into noise issues with the Xbee, as well as voltage regulator problems, and a diode that had to be bypassed.

But while [Marc]’s list of approaches to monitor sleep is long, he hasn’t exhausted all approaches. For example there’s monitoring a baby using lasers to detect whether or not the child is still breathing.

[Via Adafruit]

24 thoughts on “In Bed With An Arduino, Fighting Sleep Apnea

  1. Try a CO2 sensor to track effective respiration. If the sleeper is in a “tent” with an known rate of air transfer (duct and fan) 2 sensors, on the inlet and the outlet, should tell you all you need to know. Add a methane sensor for the LOLz if you like.

    1. Last time I was messing with this, you could get a fingertip pulse-ox sensor for $29 on Amazon/eBay/etc. Those only show immediate values (the connectorized kind are much more expensive), but they’re probably not hard to hack.

      I found the Zeo really useful for tracking my sleep, but unfortunately the original sensor pads have worn out (which they do every few months), and the company’s out of business so they’re not selling any more. Has anyone found a source of replacements?

      1. Looks like there are similar products for even cheaper these days, plus sensors for about $15-20 that plug into expensive proprietary devices (easy for hackers if you’ve got documentation or can figure it out) that’ll let you do continuous monitoring, and one sensor that uses an audio headset jack to plug into an iPhone.

  2. I’m wondering if some sort of ultrasonic sensor attached just below the sternum would work. With an output proportional to chest cavity volume. If it were small enough it wouldn’t be too intrusive (unless you sleep on your stomach), and should have better noise immunity than a chest strap design.

      1. The pulse and breathing motion amplification demos, as described in the original paper, takes some time to start and stop responding. For example, had the baby suddenly stopped breathing, the amplified motion wouldn’t have stopped – but rather continued at the same frequency, with the amplitude tapering off after some tens of seconds.

        Not sure if that would pose an impediment for detecting sleep apnea. This video also contains some new material suggesting they may have improved response time.

  3. I had terrible sleep apnea awhile back.

    I figured out that if I’m lying face up, my tongue would relax and slide back to clog my throat. I would be unable to breathe for awhile, then have to wake up to regain control and move the tongue forward.

    This would happen several times a night, wouldn’t wake me completely, and resulted in very little deep sleep.

    I trained myself to sleep with my head facing left or right, and I carved a special mattress with a channel crosswise that would fit my arm while sleeping on my side.

    It’s helped a lot, I don’t have apnea any more, and I don’t get dreams of choking and drowning.

    1. Sleeping on your back face up may be very bad for your brain in the long term too. Recently discovered lymphatic drainage ducts in the brain operate much better if you sleep on your side and change position regularly, failing to do this is suspected to cause a build up of waste products in the brain that may be associated with an earlier onset of neurodegenerative diseases.

      1. Thanks – that’s an interesting point.

        I figure that stopping breathing long enough to cause a physiological response due to low oxygenation, over and over each night, over long periods, wasn’t particularly healthy for my brain.

        Also, there’s a correlation between depression (as in – low energy) and poor deep-sleep. They don’t know if A causes B or vice-versa, but it may well be that lack of deep sleep caused by Apnea is one cause of depression.

        It’s interesting to note that if you look at beds from about a century ago backwards in time, they are built differently. People used to sleep with their upper body more “upright” than we do today. (Not completely upright, but much more so than lying flat.)

        The legend was that sleeping upright helped to prevent dying in one’s sleep.

        Most medieval pictures of beds show the person in bed propped up at an angle.

        1. I’d suspect the case is that apnea causes the depression myself. I actually suffer from both central and objstructive apnea, and found that there’s a gigantic difference for myself once i started using a BiPAP machine. I also discovered that with as low as my O2 was going (<85% for about 60% of the time while asleep, and never rising above 90%, and 0 minutes of REM sleep in a typical night), i actually suffered some not-insignificant memory problems (I can't remember the story most of my life before diagnosis, but can recall some emotional content when given cues and such).

          Those things played a huge psychological mind-***k on me when discovering that after i was more lucid during the day. I can't imagine that during the time i was not conscious of the problem but very frustrated by the effects of it that it didn't contribute to my long term depression of the time. I still suffer from depression sometimes but no where near as constantly or as deeply as I was during that time.

    2. That’s the real classic obstructive sleep apnea. I’ve always been a side-sleeper, and had snoring problems even when I was young and skinny, though I didn’t have the apnea snore back then, but if side-sleeping’s enough to control yours, great! Some people find mouth appliances help, by keeping their jaws in a position that the tongue doesn’t slide far enough to block the airway. CPAP works really well for me, enough to make up for the annoying hoses.

  4. When using bands around the body to monitor respiration, you typically use two of them: one around the chest and one lower near the stomach. You can breath by expanding/contracting one or the other or both. You can also have significant motion in both but in opposite directions which indicates a lot of work with virtually no air intake/exhaust.
    Without both bands you can’t really understand the net breathing.

  5. Um..time to get out of the 1990’s….CPAP machines now do this and you can plot graphs from data they’ve recorded on SD cards.

    So, go cure cancer with an Arduino, instead

    1. What do they cost, $1000? That is a months wages for the average worker in the poorest 100 nations on Earth, so a significant number of humans. Having something to offer for under $100 would make a big difference to many people’s lives.

    1. Look like you got a nice range. I wonder how much of the change was due to actual stretching in addition to the changing contact area from turn to turn. In any case, good result.

  6. The idea is to look for cessation (long pauses) of breathing isn’t it? It should be easy to monitor respiration timing/rate using a very small microphone placed below the nostrils so that air passes over it. Ever notice how just a little breath on a microphone (think of a headset mic) causes a loud noise to be picked-up? Wouldn’t a mic right under the nose pick up breathing easily? Run it into Audacity or something to see the breathing pattern. You could pair that with a simple recording O2 saturation sensor that allows downloading (cheap) and see if any pauses correlate to low O2 saturation.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.