machinegurning.blog

Measuring light with a Raspberry Pi

I’ve been working through a year’s worth of sensor data that I collected using Raspberry Pis. In the last post on this subject I compared my temperature records with records from a local weather station. In this post I’m going to look at the light measurements. I have two main questions I would like to answer:

What are the light measurements?

The light measurements are not strictly measurements of light at all; they are measurements of time taken for a capacitor to fill and discharge. Since the capacitor is attached to a light dependent resistor, longer times indicate a higher resistance (and a darker room), whilst shorter times indicate the inverse.

The data consist of 765977 individual measurements and run from 2015-01-02 to 2015-12-01, with measurements taken at 180 second intervals. These values need to be transformed to make interpretation more intuitive. I’ve played with a few transformations, but my current thinking is to use the normalised inverse of the natural log:

\[ y=f \Big( \frac{1}{\ln{x}} \Big) \]

Where \( f \) is the normalisation function:

\[ f(x)=\frac{x - \max x}{\max x - \min x} \]

This transformation has three benefits:

After applying this transformation, 5 further values were highlighted as outliers that were not removed in the initial cleaning described in a previous post, so any light value \( <50 \) was removed.

With these transformations applied, the year long time series looks like this:

plot of chunk 2016-02-22-full-light-sequence

The very simple local regression (loess) highlights some seasonal changes. Part of this is almost certainly due to me moving the sensor early in the year, but the reason for the step towards the end of the year is not clear, but is probably due to a change in the position of the sensor (it is prone to falling on its side!).

Daily light patterns

Here I replicate the same daily plots from my previous post, also showing values between the \( q_{0.25} \) and \( q_{0.75} \) as the darker ribbon, and the \( q_{0.1} \) and \( q_{0.9} \) as the more transparent ribbon outside of this. The trend line is again a locally weighted regression.

plot of chunk 2016-02-22-daily-light-ribbon-plot

So there are some immediate things that become apparent based on this plot. Firstly, the shortness of the days in the winter months is evident from the narrowness of the first peak in the winter months. The lower light intensity is also clear in the winter months. The second peak in the winter months is caused by artificial lighting.

In March to September, the natural light distribution is bi-modal. These peaks occur at about 09:00 and 15:00, and correspond to the peaks in temperature recorded in my last post, so it looks like solar heating of the front of the house is responsible.

Whilst this plot gives a good sense of the daily patterns over a year, we also lose a lot of information; for instance the steep changes from natural to artificial light. The next plot shows a more ‘raw’ representation where each trace is a day. We can glean a lot more granular information from it:

plot of chunk 2016-02-22-daily-light-traces

These data are pretty messy, but it should be relatively simple to pick out the differences between natural and artificial light, and I will attempt this in one of my next couple of posts. Two methods for doing this come to mind:

Perhaps a combination of the two?