In a previous post, I wrote about my first attempt at beehive temperature monitoring. So if one temperature probe was enough to gather some interesting data, what can twenty probes accomplish? To answer that question, I built a new and improved version of the hive temperature logger:

The Build

Because my last logger enclosure ended up collecting some unwanted water, I decided to get a nicer weatherproof enclosure from Adafruit. I immediately set about compromising the weatherproofing by drilling five holes into the sides. No worries though, after installing cable glands and waterproof cable connectors, the situation inside was as dry as ever.

I managed to find some Vktech DS18B20 temperature probes in bulk on Amazon, which went a long way to keeping this project within its budget. I soldered four temperature probes to each of the five cables connectors. All 20 lines go into a single bus on a SparkFun ProtoShield. As in the original logger, the shield sits on top of a Seeduino Stalker with an integrated SD card for logging. The solar panel is integrated into the enclosure top. Although I was pretty confident in the weatherproofing, I went ahead and tossed in some Silica gel packets to reduce the chance of moisture corroding the electronics.

Test Rig

Before deploying this in the field, I wanted to make sure it would actually work. My friend Ted (of Nova Labs makerspace fame) created a mock up of the lattice-like probe placement within a hive, so we could visualize a 3d temperature gradient:

I wrote a simple Processing sketch to monitor and visualize the temperatures in real-time. This let us use a heat gun to heat up different parts of the rig, while watching the visualization react on a laptop. Everything seems to be in order:

Deployment

The final step was to deploy the logger to the beehive. We distributed the 20 probes through-out the hive in a 3d lattice pattern, and hooked up the logger. For optimal energy capture, I once again leaned on my patent-pending Rock Method of solar panel tilt adjustment. The result is starting to look like a real cyber hive (well, minus the rocks):

The wires were individually labeled so that after the data was collected I was able to relabel everything with an descending counter-clockwise spiral. I made the SketchUp diagram above to use as a reference. In the graphs below, “T16” refers to the probe labeled “16” in this diagram.

Results

We collected data from May 2014 until March 2015, resulting in 90551 time points, each with 20 temperatures and some other metadata. That means I had something like 1.8 million temperatures to analyze! Obviously, I couldn’t load this much data into Excel. Instead, I used an iPython Notebook with Numpy, Matplotlib, Pandas, Seaborn, and PIL.

The first thing I did was graph all the data together. I assigned a color/line style combination to each probe, and then plotted the daily averages:

Uh oh! I forgot to mention that we were not logging in September, because one of the probes malfunctioned, causing the entire data bus to fail. That seems to be a real problem with the 1-Wire protocol, and the next time I use it for this many devices, I will need to do some more research into improving reliability.

Even after we discovered the problem, I couldn’t do much else besides disconnect the four probes (middle layer) which were causing the 1-Wire failures. Pulling the probes out or replacing them was not possible with the bees making their home around them. So the data after September is missing four probes (T9-T12). Unfortunately, these happened to be most critical probes because they were in the middle of the hive were the queen was living. Still, the bees presence is clearly discernible in adjacent probes (T13, T14) even into the month of November, and possibly beyond.

Let’s look at the temperatures from before the crash in detail:

In this graph, you can clearly see the four probes that the bees were clustered around (T9, T10, T13, T14), steady at around 35 degrees Celcius. In fact, you can even see how the bees started out near T9 and quickly expanded to the nearby areas. For a brief period of time in late June, the bees seem to take up residence at T15, but they abandon that area completely in mid-July.

There is also an interesting trimodal distribution of the temperatures, especially in August. They basically separate into three groups: a) the four probes tracking the brood cells containing the queen, which has very little temperature fluctuation; b) the other bees immediately surrounding the cluster, which are affected by the outside ambient temperature, but are generally warmer; and c) the probes on the outskirts, which basically track the outside temperature. You can clearly see these three groups in mid-August:

Although the daily means are informative, I wanted to take a closer look at how the temperatures looked on an hourly basis. To do this, I plotted a graph for each day, and then combined them into an animation. That version is available as an Animated GIF and on YouTube. Although less precise, the 5 day rolling average is easier to watch if you just want to get a sense of the trends:

There is also a movie version, which you can stop/start to take a closer look at any given day.

Visualization In 3D

Although analyzing the data with conventional tools provided some insight, what the real aim of this project was always to visualize the data in 3D over time. To achieve this, I used Scipy to take the 20 temperature values for each day and expand them into a much larger voxel space, using 2nd order spline interpolation. Then I fed the voxel data into the VTK library, which has some very convenient Python bindings, and plotted it using the volume ray casting technique. I generated some movies out of this that are quite interesting. Here is all the data in one long video:

To watch the positional trends, I took the mean of the temperatures from 4-5am, the usual time during which the contrast between between the hive temperatures and outside ambient temperature is highest. This results in a short movie which summarizes the data set:

If you have any ideas for how to better visualize this data, I’d love to hear them!

Code

All the code for this project is available on GitHub:

Next Steps

This project was fun and educational, and I ended up with some great tools to use in the future. I’m definitely not happy with the data loss, so I would like to repeat the experiment if only to get a complete data set. I would especially love to capture a data set where the bees live through the colder temperatures, and slowly eat their way through their stores over winter.

Of course, the next big feature on my mind is still remote real-time telemetry. Watching all this unfold in real-time every day would be thrilling, and it might give the bee keepers the data they need to intervene when necessary to save the hive!