Almost half a year has passed since I last wrote anything here, terrible. Anyways, here is a description of a little hack I did some time ago:
Our bedroom has this Squeezebox radio, that I mostly use as a clock and to play from Spotify.
The Squeezebox has an ambient light sensor that dims the screen when the lights go out. Which works fine, the screen is dim enough at night not to interfere with my sleep.
Anyways, of course I had enabled SSH access to the Squeezebox just after installing it. Last year I was poking around in its filesystem to discover the ambient light sensor hanging around in /sys:
Every variable in the hessch residence needs to be graphed, this data could not be left aside. Also, as the ambient light sensor faces the window in the bedroom, I thought this might give some interesting data on the length of the days.
I hadn’t played with Cosm before, and thought this was a good occasion to give it a try. (Cosm was called Patchube before, and is now renamed to Xively, probably as I write this they’re planning on another name.) It turned out Cosm was pretty easy to use, and I quickly whipped up a piece of shell script to send values from the Squeezebox to Cosm:
1 2 3 4 5 6 7 8 9 10 11 12
Actually this is a very ugly oneliner that I’ve cleaned up a bit, it’s still ugly code, though. It fetches the current sensor value over ssh from the Squeezebox, and spits it as JSON to Cosm. It also tries to munch the raw values a bit as the output of the sensor is far from linear.
The graph above is the last 3 month of data as displayed in Cosm / Xively / whatever, one can see the days already getting shorter and darker, going towards the inevitable winter.
Zooming to a days worth of data one can nicely see the sunrise around 5:00 UTC and the sunset around 18:00 UTC, and the lamp in the room switching on around 19:00 UTC:
It might be interesting to filter out the characteristic level of the lamps in the room as the lamps mess with measuring the length of the day. In the graph above the first peak in the graph (around 22:00 UTC) is the ceiling light, which is switched off and being replaced with a bedside lamp that has three dimmer levels, of which two can be seen in the graph. When I’m writing this, as you can see the ceiling lamp is switched on again. :)
It could be fun to analyze the data to get an insight in our sleeping patterns and maybe even if (and how) the daylight affects these.
Maybe to be coninued…