I’ve seen a number of discussions as to whether putting a waterbutt filled with water in the polytunnel would help to avoid frosts and (possibly) encourage earlier growth by raising the average temperature in the polytunnel.
Whilst there was a general opinion that it would help, I had a feeling that any improvement would be negligible.
The only way to satisfy my thoughts was to accurately measure the temperature of the water in a waterbutt and the atmosphere within the polytunnel. So, I set out to do this. My supposition being that the heat given out by the waterbutt would be small to infinitesimal and so have no impact upon the temperature in the polytunnel, but that if the water temperature rose and fell it was doing something (even if not much).
Building the Temperature Sensor Hardware
Around the web, there are many sets of instructions on how to build a temperature sensor using the DS18B20 and I don’t intend to duplicate them here. Suffice it to say that the waterproof DS18B20 has three leads (Black, Red & Yellow) which should be connected to Ground, 3.3v and GPIO4 respectively with a pull up resistor of about 4.6k ohms between the Red and Yellow leads to make the data reliable. You can, in theory, connect as many DS18B20 together as you want with just a single pull-up resistor. (My max has been four but I have no reason to expect that there is a sensible upper limit but for the purposes of this experiment, I connected two).
Its best to solder all the DS18B20s together with no power to the Raspberry Pi and to solder a flying lead with a female connector to the setup so that you can easily connect and disconnect the sensors to the Raspberry Pi. Again, my suggestion is to connect everything to the Raspberry Pi with the power turned off and only power-up the Raspberry Pi when everything is connected.
Preparing the Raspberry Pi
The DS18B20 uses one-wire connectivity so you’ll need to add the line:
The simplest way that I found was to edit the file using the text editor nano but you’ll need to do this with superuser enabled (sudo nano /boot/config.txt) otherwise you won’t have the privileges to change the file. Then reboot the Raspberry Pi and you’re ready to go.
Checking that its working
Before starting to run your code, its worthwhile making sure that its working by initiating the sensors from the screen.
Each sensor will create a file /sys/bus/w1/devices/28-xxxx where xxxx is the unique number of the individual sensor. So by initiating the 1-wire system you will be able to examine the directory and make sure the necessary files exist and that they contain data.
To initiate the 1-wire system type:
sudo mod probe w1-gpio
sudo mod probe w1-therm
then check that there is one 28-xxxx file in /sys/bus/w1/devices for each of the DS18B20s you have connected.
If there are no files, check your connections. My most common mistake has been to connect the data line to the wrong GPIO pin, but obviously you have to make sure that the power and ground connections are also sturdy.
If there aren’t as many files as you’ve got DS18B20s, check the soldering of the connections as the wires to the sensor are quite delicate.
Programming the sensor
I’ve written a total of three different programmes in Python to read and store the temperatures. The first two ran permanently recording the temperature every minute to a file. I found a some bugs with Python (the Float command doesn’t work when the value is exactly zero for example), and having it running permanently meant that the Raspberry Pi could’t be used for anything else.
So my final (and so far most successful version) is run from a cronjob (so I had to learn how to do that) and this means that the file is closed when the programme isn’t running and you can choose how often to run the programme (I decided that once every 10 minutes would give me an accurate enough set of readings).
The code can be found here and it seems to work, creating a .csv file which a spreadsheet programme can read and plot.
To set up the cronjob edit the cronjob file (crontab -e) and set up one (or more) commands to run the job as often as you like (I’ve got it running every 10 minutes).
Results (so far)
The graph of the results so far can be seen here. Its only been running reliably for a few days and we’re at the start of winter. The results are somewhat ambiguous. The temperature of the air in the polytunnel changes rapidly, especially when the sun shines on the tunnel (which is what one would expect). The temperature of the water tracks the temperature in the polytunnel with a delay. This means that the water absorbs heat when the polytunnel is enough warmer than the water and gives it out when the polytunnel is enough cooler than the water.
However, the temperature difference is never very large and the water seems to stop decreasing in temperature if the difference is less than 0.3C (in other words if the polytunnel is 0.3C colder than the water the temperature of the water does not decrease and if the temperature in the polytunnel is less than 0.3C warmer than the water, the water does not increase in temperature.
This means that, with this volume of water, the impact would be minimal. The amount of heat given out by the water as the temperature goes down probably doesn’t influence the temperature in the polytunnel and, if the temperature goes down and stays down, the water will quickly lose any effect.
Update (Mid January 2018)
I modified the hardware set-up to include an extra coupe of sensors (one would have been better but I added two). So now I have one sensor in the water, two in the tunnel (one above the water and another just in the atmosphere) and a fourth outside the tunnel in the shade. The resulting graphs are still ambiguous. Yes, the temperature in the water lags behind the rise and fall of the other sensors (and -0.3C is the minimum that it gets to) and the temperature in the tunnel peaks higher than the temperature outside (in the shade) but other than that its difficult to draw conclusions, the only thing to see (here) is that its cold even at the hottest. It’ll be interesting to see how the temperature behaves as the days get longer.