DIY: SleepTrack – Sleep Apnea measuring and prevention machine

UPDATE: 25/2/2014 – Fritzing file is now available for Breadboard, Schematic, and PCB views.

2014-02-25 23_16_37-2014-02-25 23_05_20-SleepTrackv1.fzz_ - Fritzing - [Breadboard View].jpg - Paint
Above image is a screen grab of the Breadboard view in Fritzing. This is v1 hardware and will work on all v1.x versions of code (see GitHub link below for the code). [Note that the first number in the hardware and software versions must match for things to work. Currently there is no v2.x for hardware or software, but there may be in the future].

https://www.dropbox.com/s/3ogygr2f1p771h1/SleepTrackv1.fzz

The above file is the Fritzing file itself. Please note that the Arduino Pro Mini part in Fritzing is incomplete for the PCB view only, it doesn’t show the A4 and A5 connections. Chances are if you are advanced enough to use the PCB view for creating your own circuit board you would modify it to make the tracks route better anyway. The Fritzing file was only really made for the Breadboard view so that you know which components connect where.
The Accelerometer used is MMA7361L from Pololu (Pololu #1246).

Parts used (all available from SparkFun/Pololu):

  • Arduino Pro Mini 3.3v
  • MMA7361L 3-Axis Accelerometer
  • 3.7v 110mAh LiPo battery (rechargeable)
  • “LiPo CHarger Basic” from SparkFun (used separately to reduce bulk on the actual device)
  • Generic momentary switch
  • /UPDATE (25/2/2014).

    Have you been diagnosed with sleep apnea? Are you frustrated at the lack of options available for treating it? Would you be interested in a DIY project to prevent sleep apnea?
    Well look no further! If you have some programming and electronics know-how you may be able to make your own SleepTrack device to help you learn more about your sleeping behaviour. If you are purely a consumer then please feel free to take any information shared within this blog.

    I finally created a GitHub account, so I will upload my code there and paste the link here once a publicly consumable version is available.
    Code is now available on GitHub, here: https://github.com/JayAristocles/SleepTrack/

    Want to be a contributor? Excellent! I thought you would never ask. Let’s collaborate on GitHub or comment on this blog.

    OK, first of all, let me clarify. This machine does not measure any apnea events. Not yet, anyway. There are potential plans to build a version which does, see below for more information.
    So what does this device do? Well, before I can answer that I need to explain how I got to where I am now in relation to my sleep apnea.

    For a few years now I have been feeling constantly tired during the day. I’ve been to the doctors and had a slew of tests done, including a sleep study. In the past you would need to go to a sleep centre for the test, but these days you can have the DIY option where you go home with machine which measures:

      1) time
      2) movement (your sleeping position. Left, Right, Supine or Prone)
      3) pulse (sensor on your finger)
      4) oxygen (pipe places inside nostrils)
      5) breathing (two stretch sensors around your torso which measure the chest rising and falling as you breathe)
      6) ECG (sensors stuck to your chest)
      7) EEG (sensors stuck to your scalp)

    They send you home with this machine along with instructions on how to hook it up. It’s not the most comfortable of things to sleep with, but it beats sleeping at a sleep centre.
    After a single night they take the machine back to process the recorded data. I think sample rate of just one night is too short to get proper data across time, but it is what it is.
    The results said that I stop breathing for more than 10 seconds 19 times per hour. This is considered ‘moderate sleep apnea‘.

      Solution?


    Well, there isn’t much to choose from here. You can have a dental plate or an operation but I wont be going in to either of those here (google is your friend) as I don’t know much about them nor have I tried them.
    There is a thing called a CPAP (Continuous Positive Air Pressure) machine which, as the name says, pushes air down your throat while you sleep to keep the airways open. Its actually much more uncomfortable than it sounds as the ‘positive air pressure’ gives you the sort of feeling you get when you stick your head out the car window while someone is driving and you try to breathe. You can get used to it though as I did when I had the machine for a month trial.

    But this machine is not a cure, it is simply a prevention which you must use for the rest of your life! I consider myself still a young man and it pissed me off when I was told that to treat this condition I will need to become Darth Vader every night for the foreseeable future.

    An interesting piece of information from the sleep study showed that my apnea events seems to occur mostly when I am lying in the supine position (on the back). The reason for this is that the throat is able to close up easier when on your back than on your side or when prone (on the stomach). A little trick to prevent you going on your back while you’re asleep is to place a tennis ball under your shirt between your shoulder blades (using a rubber band to keep it in place), this makes it too uncomfortable to shift on to your back while you sleep.

    During my month trial with the CPAP machine I would take video recordings (using an IR Webcam) of me sleeping and noting my positions with/without CPAP and with/without the tennis ball. I find the CPAP is definitely helping but I rip it off during the night (usually subconsciously at around 4am) so the benefits are only while I am wearing it. The tennis ball is actually really good as I find I rarely turn on my back when using it, and when I do turn on my back it isn’t for more than a few seconds. I wake up feeling better.

    So this is where SleepTrack comes in. The purpose of the device is to record while I sleep which position my body is in. Using this information I can then adjust sleeping behaviours to try and minimise the amount of time I spend sleeping on my back.

      So how does it work?

    SleepTrack is an Arduino-based device built to be as small as possible (unobtrusive during sleep).
    It has an Accelerometer which measures and reports the devices position, this position is then stored in the onboard EEPROM for later retrieval.
    The data is for informational purposes only. The tennis ball trick is still needed to prevent myself from sleeping on my back. I hope to eventually remove the need for the ball altogether.

    Future plans include:

      1) A mechanism to detect apnea events. Using an elastic band around the chest (with a copper wire going through it, this is similar to what was used during the sleep study) which registers if the rise and fall of the chest during a normal breath is not detected.
      2) A docking station to sync date/time, pull data from the device, store data on an SD card and charge the battery.
      3) An array of small form-factor vibrating motors which will vibrate when the user is on his back too long, hopefully this may convince the wearer to turn to their side while asleep.
      4) I need to figure out how to plot the data in to visually consumable chunks (perhaps using something like GNU Plot?).

    I have attached pictures of what the device looks like. There isn’t much available in way of technical explanations yet as the project is still in its infancy stages. Once I can confirm that it is working as expected I will post instructions for those interested.

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s