Analyzing my sleep with Sleep Cycle

As I’ve currently hit a wall playing around with my Raspberry Pi, I’ve decided to write a post about something completely different.

Since we moved to a new apartment, I haven’t slept very well. To be honest I’ve never really slept well unless I had the chance to get 8-10 hours every night. In my attempts to rectify it, I decided to try using technology to see if I could get a better idea if there were any patterns in how I slept. After looking around the internet, I fell upon Sleep Cycle, which seemed interesting. After reading how it works, I decided to buy the app for my iPhone as I figured the cost of €1 was okay, even if I never did find out anything by using it.

How it works isn’t exactly rocket science. You simply enter when you want to get up and through analyzing your movements through the phones accelerometer it tries to wake you up within a 30 minute interval from your set time. It tries to do it when you’re already moving around, so you shouldn’t be in deep sleep.

2015-03-02 09.54.44

To actually get some useful data out of the app that you can use to analyze on, you can set Sleep Notes, that you tick off when going to bed. This can be things like ‘Drank Tea’, ‘Read a Book’ and such. Here are how I set mine, which could probably be tweaked a lot to get even more meaningful data:

2015-03-02 09.54.38

After setting the time you want to get up and then adding the applicable Sleep Notes for the night, you simply put your phone face down in the bed near your pillow and go to sleep. The app then functions as a regular alarm clock, apart from the fact that it’ll try to wake you up within a 30 minute interval (I think you might be able to change the interval to whatever you like, I haven’t tried myself). When you wake up, you get prompted on how you woke up by 3 different smiley faces and then get a statistics page for the night. Here is mine from this morning:

2015-03-02 09.43.23

As you can see I went to bed a 00.16 and got up again at 06:26, getting 6 hours and 10 minutes in my wonderful bed. According to the graph and the sleep quality at 56%, I didn’t sleep too well and had quite a few spikes of being ‘nearly awake’. As I felt pretty crap when waking up I chose the bad smiley! The statistics show I’ve been doing this for 85 nights so far and that has chalked up to 3.4 weeks in my bed, averaging at 6 hours and 37 minutes per night. You get prompted by this every single morning and not shown on the picture here, is that it also shows what night you slept best, worst, longest and shortest.

If you flip over your phone, you start to get some graphs and other statistics that go for the entire period you’ve been monitoring your sleep:

2015-03-02 09.43.57

Here is a graph over how much time I’ve spent in bed in general. As you can see it’s been dropping to less and less time, but this is more to do with the fact that I started doing to monitoring during my Christmas Holidays, than a general lack of sleep since.

2015-03-02 09.43.49

Now a graph over when I’ve went to bed and apart from a few spikes before midnight, I might have issues going to bed early which could somehow be one of the sources of why I’m not sleeping very well.

2015-03-02 09.43.30

This graph shows my calculated sleep quality, which is a number it gives in percentages. I have no idea how they actually calculate this number, but it shows pretty well that after the Christmas Holidays ended, the quality of sleep has gotten worse.

2015-03-02 09.43.45

Next graph shows how long I’ve spent in bed on different weekdays. It comes as no surprise that it’s Friday and Saturday night that I spend most time in bed, seeing as it’s the weekend and all. More interesting it is to see that the night I sleep the least is Sunday night. Apparently I have some problems adjusting to being able to stay up late Friday and Saturday and adapting to Sunday being an overall bad day to stay up late.

2015-03-02 09.43.38

Here we have the rather arbitrary sleep quality percentage spread out on the different days of the week. As most of the other graphs show Sunday night is just plain bad and the fact that I sleep more in the weekends I also tend to sleep better on Saturdays.

2015-03-02 09.43.34

Remember the sleep notes I was mentioning earlier in the post? Well here they are and here they show the effect they have on my sleep quality. For some reason it seem that I sleep really damn well when I go to bed drunk. I think it might just be a coincidence that I slept well the one night I actually went to bed drunk (and remembered to set the alarm). Else it shows that drinking one or two beers and sitting 8 hours in front of a computer has the worst effect on my sleep (actually it’s the only two who have a negative effect). Too bad that my job is sitting in front of a computer for 8 hours a day and that I usually top it up with sitting some more in front of a computer at home too. Having a cup of tea looks like it’s actually working out for me.

2015-03-02 09.43.41

The last graph it gives me, is a rather recent addition to the app. How the weather conditions affect my sleep. Honestly, I’m not really sure if this graph has any merit but according to it it could seem that I sleep best when it’s partly cloudy (so I don’t get affected by moon rays?), foggy (again shielding me from the evil moon rays!) or snowy. As I sleep in a very dark room next to my wife, where the weather outside has very little effect on anything, I’m not sure what-so-ever on this graph. What this tells me is more coincidentally if you ask me.

So, has using Sleep Cycle actually helped me improve how I sleep? Has it given me a better idea of just exactly what I can do to sleep better?
Honestly, I’m not quite sure if the app has helped me very much in any aspects. First of all, I’m not certain that it actually works as intended. It’s supposed to monitor vibrations through the accelerometer of my phone and if you do the test the app has if it actually monitors you it seems to work technically. However, I sleep in my bed next to my wife. According to the website it needs a few days to actually get accustomed to the different conditions, like being more than one person in the bed and how the other persons movements affect the monitoring.

When I look at the graphs I can see spikes every single night. If they came from just me moving around, I can’t understand why they last for quite a while. It could be because I react to my wife getting up to take care of my crying son or simply because my son is making ongoing noises while sleeping, but I’m still not sure. I think you have to take the movements and the arbitrary calculated sleep quality percentage with a grain of salt and focus a lot more on the sleep notes. Currently I have the sleep notes showed earlier in the post, but I think I could start adding a lot more. Like ‘Painkillers’, ‘No meat today’, ‘No Lunch’, ‘Exercised’ and so on and then being a lot more consistent in actually selecting sleep notes when going to bed. This way you’d get some kind of inclination towards stuff that you could do to make your sleep a lot more enjoyable.

So far I’ve come up with the following conclusion to what I can do to sleep better:

  • Go to bed earlier
  • Always drink a cup of tea an hour or so before going to bed
  • Stop using my computer and/or tablet right before bed
  • Take a shower before going to bed
  • Try reading a physical book before going to bed
  • As to the app and its usefulness, I’m not sure that it will work for everybody. For now I’ll keep on monitoring my sleep and maybe look into adding more sleep notes, to get an even better picture of how different stimuli affect my sleep. But using the app itself and not doing anything about the results you get, will mean that it just wont do anything. Anyhow, I think the idea of sleep monitoring is really interesting and that even though the results might vary there can be some merit to actually thinking about what you do before going to sleep. Not necessarily trying to take a technological view on it, but simply create a routine and stick to it.

    After this sidetrack from working on my Raspberry Pi Home Server, I’ll get back to it during the week (if work, family life etc. permits me).

    The Raspberry Pi Home Server – Part 1

    As mentioned in my post from Wednesday, I’ve been working on setting up my Raspberry Pi as a small energy-efficient home server. I’ve been working freely from the brilliant guide written by Mel Grubb found on his website, doing it in the steps that I wanted on my server.

    As I currently lack an external hard-disk case which is not only powered by USB, I wanted to use all this as a test setup and then either do a completely new installation or just doing step 6. Adding a Hard Drive at a later point. So far I’ve done the following steps meticulously following the different guides:

  • 1. Meet the Raspberry Pi
  • 2. Installing the OS (I went the Raspbian way as I’m comfortable with Debian variants of Linux.)
  • 3. Configuring the OS
  • 4. Web Administration
  • 11. OpenVPN Server
  • 7. Sharing Files With Samba
  • That is how far I am at the moment and the order that I’ve been doing it, but I’ve run into some problems with setting up the Samba share correctly. As I haven’t added a hard disk to the Pi as of yet, I just made some folders to share in my home folder at unax/home/Data. Then I followed the guide to do the Samba setup through the Webmin interface, allowing guest access and for everybody to be able to write to said folders. I have no problems in finding the wonderfully named UnaXPi on the server or in seeing the shared folders.

    However, when I try to add files from my Windows 8.1 machine, I get rejected due to not having the correct permissions. I’m not an expert on Samba in any way, but I’m starting to think that the issues stem from me trying to copy to the home folder of my Raspbian user unax, instead of a folder not placed within the realms of a user. I’m trying to troubleshoot a bit more and I might try by adding a USB pen drive and see if I can get it to work on the /mnt/ folder instead.

    samba_error

    Apart from that, I also did some customization of the Webmin interface to make it look more interesting, by installing the Authentic Theme and it looks wonderful. The installation however was a bit confusing to me, as I tried installing it as a module instead of a theme and I feel the Webmin error message of the ‘File Not Found’ ilk, wasn’t very helpful. Finding the ‘Theme’ option in the configuration however, helped me a long way.

    webmin_authentic_theme

    At first the Webmin interface didn’t work with the Authentic Theme, it was just stuck on a loading screen and I simply couldn’t understand why. After refreshing a few times, restarting the Pi and such, I did the only sensible thing and actually went to the source to see if there was some help to get. At the Github site I found the Troubleshoot section and installed Perl by doing:

    $ sudo apt-get install perl-libwww perl

    This meant that it worked, but I’m not really sure that I needed both the perl-libwww and perl packages, so there might be some redundancy present on the server now.

    If I look away from the snags I got with the Samba share, I’m very happy with what I’ve achieved so far. I can connect to the UnaXPi through Webmin from my entire network, see the shares on the network, connect via OpenVPN and the Raspbian OS and Raspberry Pi firmware is updated. Now to try and get write access to the shares and try some DNLA media sharing.

    More updates to follow.

    Setting up my Raspberry Pi as a home server

    Today it’s almost precisely two years since I bought myself a Raspberry Pi thinking I was going to change the world and make something really cool. Nothing really came of it. Apparently I didn’t have the imagination to build anything out of the ordinary, so I ended up making it into an EmulationStation using RetroPie. It worked fine with my Logitech controller and I did have fun playing one old NES game, for around 3 minutes. After that, my poor Raspberry Pi ended up in the box, you know the one with all the old wires and now useless gadgets.

    There the hardware dwelled until today, but it was still in the back of my mind. I was sure I could use the hardware for something interesting that actually added value for me. Then it struck me that I really wanted a NAS, but after scouring the market for a really long time I had to conclude that I can’t afford buying one of the quality I’d like. A very quick Google search lead me to an instructable called the Ultimate Pi Home Server and I found it very interesting that the Pi might be able to fill my needs until I can go on to something more professional like a QNAP or Synology NAS.

    Reading the comments on the instructable however showed that there were issues since it seems to be outdated a bit. This meant that I had to go back and do some Google-Fu and in the end it led me to this guide by Mel Grubb that seemed to fit my needs a lot more. Reading through the different steps I could even see that he kept updating it. I had to dig out the Raspberry Pi from the depot and get back to it!

    Currently I’m just sitting around listening to some music and waiting patiently while OpenVPN works on security stuff in the setup. At least it looks nice:
    openvpn_raspberry_pi_builddh

    I really hope that this will be a great temporary solution and will most definitely update with a status as soon as I’ve gotten everything up and running.