EuroFresh Farms – Another example of using water as the heating medium

Here’s another example of a greenhouse, this time a huge commercial greenhouse, that uses water as the heating medium.

There are substantial differences between a geothermal water system and this system, namely, the temperature of water they use is very hot relative to a geothermal application and therefore they do not use the system to heat the growing medium directly.

They also use natural gas to heat the water.  Natural gas is good because it burns into primarily water vapor and CO2 which they recycle by giving it to plants.

Greenhouse solar heating

The ultimate source of heat for my greenhouse is the sun.  Even if the outside temperature is less than 10C, inside, due to the energy input from the sun, I’m seeing up to 40C on sunny days and almost 30C on overcast days.  However, my water reservoir, which I pump through a geothermal bank 6 feet under the ground and through my soil bed, is only seeing a maximum of 15C on those hot days.  As nights have been dropping below freezing (-4C), it drops about 5C to 10C when I wake up.  That’s not acceptable.

The issue is that the air in the greenhouse can only heat the water if it comes in contact with the reservoir container.  Further, waiting for the air to heat up by the sun, and then the air to heat up the water isn’t ideal.  Air is a poor conductor of heat and has relatively low energy storage capacity.  To improve this situation, we need to increase the surface area of the water system.  We could put in a bigger reservoir but space is a scarce resource inside my greenhouse.  A larger reservoir will increase the surface area, but only a little bit of that will receive direct photon penetration from the sun.  What we really need is a solar heater.

I have a 4 ft x 6 ft area above my components.  I could mount a board of some sort up there are coil some water tubes to increase the surface area.  I also have 2 old CPU radiators with fans.  This will increase the effective surface area of the water’s contact with the air.

Over a couple weekends, I took the 200 ft of black poly tubing and made two spiral loops almost 2 feet in diameter on a 8 ft by 4 ft Styrofoam board I picked up at home depot.  In between the two spiral loops, I placed the radiators in series.  To hold down the tubes, I used automotive-grade 3M double-sided tape in an “X” pattern.  On the top, I used gorilla tape, but this wasn’t effective.  Right before installing, I used 10 gauge wire to lock it down in case the 3M tape fails.


I mounted the setup at a 30 degree angle near the top of my greenhouse facing south.  This is not ideal.  In my area, a 70 degree angle would be better, but space is limited, so this will have to do.


Before I installed it, I tested it on the ground at a 70 degree angle.  Over the space of an hour or two, the water heated up from 13C to 19C.  It was a sunny day.  This is about the same as pouring two good size pots of boiling water inside the reservoir.

I’ll continue tracking the performance, but today I’m optimistic this will help.  The running cost is pretty cheap too at only 28 Watts (12V @2.4A max).  I’ve coded up an algorithm in my automation controller to only turn on the pump if the air is hotter than the reservoir.  This is good for the winter time, but this rule probably won’t work will in the summer.  In fact, I may have to add a rule to turn on the solar heating system to help cool the greenhouse.  We’ll see.

What about the cost?  Well, this addition was relatively cheap.  If you want the cheapest solution, this might be it.

Cost breakdown:

Total: $104


Bonus Total: $119

Geothermal Water Reservoir to Soil Energy Transfer

It was cold today.  It’s been cold all week.  The high for today was 7C (about 44F, yes, Tidder, I love you) and the low was 6C.   This caused my soil temperature to drop to 11C (52F).  This is bad.  In addition, it looks like it was very dark most of the day.  My artificial lighting accounted for 85% of the total light energy in my greenhouse (how my light algorithm works).  The sunlight was only able to warm the greenhouse to 15C.

In a conversation on IRC, a friend, wondered if PEX tubing was very good at thermal conduction (ability to transfer heat energy to another substance).  After a bit of searching, I found that PEX has very poor thermal conduction relative to, say, copper.  If PEX is 0.4W/(mK), copper is like 28.  Big difference.  All is not terrible, however, because water is only 0.6W/(mK).

Looking at today’s data, there was a couple degree discrepancy between the reservoir temperature and the soil temperature.  I would have thought it would be almost the same.  Could thermal conductivity explain the difference?

I conducted an experiment.  I boiled some water and poured it into the reservoir.  This brought the temperature to about 21C (from about 14C).  Over the space of a couple hours, I logged the temperatures from both over the space of 3 hours.  Here’s a scatter plot of the reservoir and soil temperatures:


The chart shows a negative correlation between dropping reservoir temperatures falling and rising soil temperatures.  We have energy transfer!  It also shows about how much pumping time is required to raise the temperature of the soil by a few degrees.  This could certainly explain how there could be a difference between the reservoir temperatures and the soil.  If the reservoir heats up quickly during peak temperature, it could be several hours before the soil will rise.

During this test, the control soil bed (unregulated) remained around 13.11C and eventually fell to 12.9C after 3hrs.  The air temperature dropped from 10.1C to 9.7C.  We lost some energy to the air, but not enough to change the air temperature upward.  We also likely lost a significant amount of energy to the geothermal bank which as about 4 or 5 time the contact area as the soil bed.

Using water as a greenhouse heat medium

I found this on YouTube.  Another greenhouse using water as the heat energy storage medium.


This greenhouse isn’t using geothermal heating, but it provides additional testimony that water makes a better medium than air and, as this man claims in the video, better than rock.

I’m not sure his claims about hydrogen are correct.  Hydro-carbons like oil have a lot more hydrogen than water does but gave lower specific heat than water.  But regardless, good technique!

Geothermal Air vs Geothermal Water – The Theory

When I started researching about building additional garden beds for food growing I came across the idea of a geothermal air greenhouse while surfing youtube.  I had heard of homes being heated/cooled with geothermal and understood it’s efficiency.  I started researching the methods used.  What struck me as odd is that geothermal homes use liquids, not air like the greenhouses I saw on youtube.  Coming from a computer background, I understood the best way to cool a computer, was liquid, not air.  Why then use air as the energy transport?  I had to do more research.

I ended up watching a thermodynamics lecture series on youtube.  This gave me a foundation for more work.  Turns out that different substances have different heat properties.  For example, to raise the temperature of water by one degree, you’d need about 4 times more energy than what you’d need to raise the temperature of air by one degree.  This makes air quicker to heat up, but also quick to cool.  Water on the other-hand takes much more energy to heat it up, but retains that energy longer.

I looked at how water is used in radiant heating applications.  They use PEX tubing in 9″-spaced serpentine loops in the flooring.  Heated water is pumped and the energy transfers bottom-up to the surrounding air.  I decided to combine these principles in my greenhouse build.  I would dig a hole, lay some PEX tubes through the earth and directly into my garden bed.  The garden bed would then “radiant” heat the rest of the greenhouse.

That was the theory then.  I was wrong.

Temperatures in my area are now getting really cold at night.  Much colder than the 15C that my tomatoes need to be happy.  The outside temperatures have gotten as low as 1C.  What about inside my greenhouse?  Inside, I’ve seen it get to as low as 6C.  The radiant heating effect is minimal.  So was my experiment a failure?  No.  Not yet at least.

What I didn’t understand then, but understand more now, is the process of transpiration.  Plants move water from the soil up to through the plant to the leaves.  I thought I’d be keeping the roots warm, but I’m actually keeping the entire plant warm as it moves the warmer water from the soil up through the plant and out the leaves.

Water vs Air - New Page

This is why when you want to cool the plant on a hot summer day, you water the soil, not the leaves!

This discovery lead me to the next: greenhouses that use geo air are actually ultimately using water.  The plant will store the heat energy in the water inside the plant.  It will get it from the soil, which is warmed by air, and it will get it from the ambient air around the plant but ultimately air is cooling/heating water.  The above image illustrates how energy is passed around in both situations.  There’s not much difference except this: water holds more energy.  That means less movement, less digging and lower cost.

There’s still a lot of work to be done before I call the experiment a success.  So far the results are positive, but I’ve got several more months of winter to go through.

Building an Internet connected irrigation system using the particle photon

The particle photon is a cool little wifi device.  It’s relatively inexpensive, it connects to the internet, and I’ve been using it for several components in my smart greenhouse project.  I needed to add a second irrigation system so I recorded how I built the controller and wrote the basic code to make it “web enabled”.

This video guide is incomplete, but it gives the basics on how to get up and running with your own web enabled internet device.


Cost breakdown:

Particle Photon – $20
2-port Relay – $7
Electric valve – $30
Case – $9.30
12V power supply – $5
12V -> 5V regulator – $1
Level shifter – $1.50

Total: $73

As a comparison, the Cyber Rain Residential Series 8 zone is $500.  It does control 8 zones, and ours can only control 2.  It also does not come with the electric valves like ours does.  To make a better apples to apples, we’d have to remove the valve from our list and add a bigger relay with more channels.  This relay supports 8 channels and is $9.  We’ll also need an additional level shifter adding another $1.50.  Here’s the new breakdown:

Particle Photon – $20
8-port Relay – $9
Case – $9.30
12V 2A power supply – $5
12V -> 5V regulator – $1
2 x Level shifter – $3

[Apples to “Apples”] Total: $47

Granted, the software of the Cyber Rain is superior.  It supports advanced timers and monitoring.  We don’t have that, but we can add all that by writing more code.  Let me know if you want me to do a walk through on how to add more smarts to the irrigation controller.  I’ve already done it for my setup.

Making Smart Grow LEDs Even Smarter

We know that full sun plants need 6+ hours of direct sunlight per day.  We also know that direct sunlight is about 30,000 to 100,000 lux.  We should be able to say that full sun plants need at least 30k * 6 lux/hrs (180 kilo-lux/hrs) of light energy per day.

I spent the last week automating the redhouse (the geothermal smart greenhouse).  Part of the automation includes giving the grow lights some smarts.  As pointed out in my last post, the grow light controller has a visible light sensor.  At the moment however, it seems my readings are inaccurate.  Full daylight on the sensor reads 1400 while it reads 919 during the night.  This is not ideal, but we can add some crude corrections to see if we are meeting the energy requirements that our plants need.

What we want to do is to make sure that our plants reach the 180klux/hrs (a total of 108megalux) per day using natural light if possible, but using the artificial grow lights if not.  Since we can control the brightness of our grow lights, we can tune the brightness to compensate for any lack of natural light.  If a cloud rolls over, we’ll ramp up our grow lights until we are producing the 30,000lux that we need.

I measured the output of the grow lights using my smart phone’s light sensor.  I don’t know how accurate it is, but at about 12″ away from the lights, it reads about 30,000lux at full brightness.  That’s perfect.

Doing a little math, we can now figure out the difference in natural light to the light we are seeing on the sensor.  We know darkness on the sensor is 919 and full sun is 1400, so we’ll compensate.  All code from this point all will be python, but should be easy enough to convert to any language you want:

directSunlight = 1400 – 919 = 481
growLightMax = 481

correctedCurrentSensorReading = currentSensorReading – 919
energyDelta = directSunlight – correctedCurrentSensorReading
growLightRate = (energyDelta / growLightMax)

growLightRate will give us the percentage of brightness we need to achieve “full sun”.

Another thing we want to do is to not use the artificial light once we reach 100% of our daily needs.  We will save energy (and cost) by turning off the light when we don’t need it.  Here’s how I did it:

totalEnergyNeeds = directSunlight * 3600 * 6

Lux is measured per second, so we will need the equivalent of 108mega-lux per day of energy.  The 3600 * 6 converts 6 hours (full day minimum requirement) to seconds.  We can adjust the number of hours according to the needs of our plants.  We can move it up to 8 for plants that need more light, or down to 4 for part-day plants.

Now that we have computed our daily needs, we need to keep a running total of how much we’ve produced:

totalEnergyProduced = correctedCurrentSensorReading + (growLightMax * growLightRate)

if totalEnergyProduced > totalEnergyNeeds:
growLightRate = 0 #turn off the lights

We should run this code every 1 second.

Using the grow light as a heat source

We will also want to turn off the lights at night time, unless we are below our total energy needs.  But there are reasons to keep the light on at night.

Certain plants not only have different light needs, but also have darkness needs.  This requirement is called “photoperodism“.  Some plants need periods of darkness to “sleep”.  During “sleep”, these plants may initiate flowering among other things.  Tomatoes, cucumbers, roses and melons do not have any darkness requirements.  We could in theory provide light to these plants 24/7 which may help them to grow faster.

I don’t need the plants to grow faster, but the LEDs from the grow light do generate some heat.  This additional heat will help regulate the temperature at night and keep the air temperature warmer than it otherwise might be.  Because these lights are over our tomatoes, we don’t need to worry about causing harm.  I don’t recommend this for plants that require periods of darkness (short-day and long-day plants).  In my greenhouse I know the soil as well as the ambient air temperature.  I’ll use the temperature to determine if it’s cool enough that we will need the extra heat from the lights.  Using a library called “astral” we can also determine if it is night time or not.  Astral doesn’t tell us if it’s night, but it does tell us when solar sunset and sunrise are.

from datetime import datetime
from astral import Location

location = Location()
location.latitude = 45.34342
location.longitude = -122.343426
location.timezone = “US/Pacific”

t =

isNightTime = (t > location.sunset().time() and t < time(23)) or (t > time(0) and t < location.sunrise().time())

if (isNightTime and totalEnergyProduced < totalEnergyNeeds) or airTemp < airSetpoint or soilTemp < soilSetpoint:
growLightRate = 1.0 #full brightness

elif totalEnergyProduced >=totalEnergyNeeds:
growLightRate = 0.0 #completely off


I’ve been fine tuning this logic for about a week.  Everything seems to be working.  I’ve only got one light at the moment over 3 of 9 tomato plants.  The plants under the light have much more growth than plants of a similar age and look healthier.  I’ve also added some variables to track how much natural vs artificial light I’m using and how close I am to my plant’s requirements.  This is my light production for today (from about 10:30am to 7:44pm)

“artificialProduction”: “58%”,
“energyGenerated”: 143407.67,
“nightTime”: true,
“productionCompleted”: “148%”,
“totalEnergyGenerated”: 15344621.17

Today has been overcast for most of the day.  Because of the clouds, 58% of my light has come from the grow lights.  Additionally, I’m 148% of my daily total right now.  My numbers reset at sunrise and the lights will be at 100% brightness for most of the night (it’s already cold enough to have the lights on).  Right before sunrise, I wouldn’t be surprised if I was over 200%.

Secure websocket server using autobahn and trollius (asyncio)

Websockets are a pretty useful way of passing information to and from clients.  But how do you make them secure?  I’m documenting how I’m figuring it out as I go.  Let’s get started.

First, let’s get a simple autobahn server and client up and running.  This is straight from the asyncio example on github.  Running it with python and python respectively.

To make things secure, first we need to create some keys and certificates.  I am creating a self-signed certificate and key for both the server and the test client:

Next we need to add a few lines to our server and client.  For the server add:

sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
sslcontext.load_cert_chain(‘server.crt’, “server.key”)
and when we create the server, we will pass in the context.  Find the “loop.create_server” line and change it to:
coro = loop.create_server(factory, ‘’, 9000, ssl=sslcontext)
The client is almost identical:
sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
sslcontext.load_cert_chain(‘client.crt’, “client.key”)
coro = loop.create_connection(factory, ‘’, 9000, ssl=sslcontext)
That’s it!

Smart Grow light

The first law of plant growth is light.  Typically this light comes from the sun at an incredible intensity of up to 100,000 lux (lm per square meter).  Different plants have different sunlight requirements.  Typically these are categorized as “full sun” or “partial sun” plants.  Full sun plants require at least 6 hours of direct sunlight per day (30,000 – 100,000lux).  Partial sun plants need about 3 – 6 hours.

Winters in the Oregon Portland area are dark.  So dark that humans suffer from the lack of light.  This condition is known as Seasonal Affective Disorder.  Most of this period is dominated by overcast clouds which reduces the light to about 1000 lux.  That’s 3% of the minimum  light required for full sun plants.  To grow food all year round, we are going to have to compensate for this lack of light.

There are many different types of artifical lighting.  The most power efficient of which are LEDs.  The problem with LEDs is that they typically have a very narrow range of light.  To make white, LED’s combine 3 diodes with some red, green and blue.  The human eye sees these three as white.  It cannot perceive the gaps in the spectrum that the LEDs do not transmit.
White LED from Cree (TM)

White LED from Cree (TM)

Other light sources cover a lot more of the light spectrum.

Example of a LED spectra

Given that lights light incandescent lights have a wider spectrum, why use anything else?  The answer is, plants don’t need all that light.  Plants use light in the blue and red spectrum and reflect the green and yellow spectra.  That means that any grow light that includes these wavelengths are wasting energy.

LEDs for growing

LEDs for growing do not have the green diodes.  This makes LEDs, which are already the most efficient artificial light source available even more efficient for growing.  While you can purchase may LED-based artificial light solutions, I set out to build my own in such a way that I can control the amount of light my plants get based on sunlight.  If there is full sun, I don’t need to activate the lights.  If there is less than full sun, I can adjust the brightness of the LEDs to compensate.

I found some grow LEDs on ebay for a decent price from the seller sungrowled.  These are 30W but I have also used the 50W variants.


To keep the LEDs cool, I picked up a 36 inch aluminum strip and mounted 6 LEDs evenly spaced on the surface.  I used thermal adhesive to mount them.


On the ends of the strip, I drilled a 3/8″ hole and attached something I could attach to some rope to hang.


I then wired up the LEDs in parallel.


The aluminum strip helps spread the heat, but probably will still get to hot.  To increase the surface area for cooling, I used the thermal adhesive to attach some aluminum heat sinks to the top of the strip opposite of the LEDs.  This unit will be passively cooled.



Six 30 Watt LEDs run at a total of 180W.  Amazon has a bunch of adjustable current/voltage power supplies from Drok.  Oddly, the power supply ratings seem to go from a few watts to 100W  and then jump to 300W and then to 600W.  Really?  No 200W?  Sigh.  I grabbed the 600W power supply version.  To supply the AC power, I picked up a 300W 24V AC to DC converter.

What’s nice about the Drok power supply, is that I can supply constant voltage AND constant current.  LEDs have an upward sloping current draw relative to the forward voltage.  This means if you oversupply voltage, it’ll draw enough current to burn out.

Typical ways to drive LEDs include supplying a constant current, so that you can safely over drive the voltage, a resistor which will also limit the current, or constant voltage.  If you never go over the volts, the current draw will be just fine.  With this Drok boost converter, I have POTs that I can dial both.  I started at 24V and slowly adjusted both the current and volt POTs until I read about 170 Watts on the kill-o-watt.  Waddayaknow!  It worked!  It’s really… really bright too!


To finish off the light power, I put both the Drok buck boost converter, the AC-DC power supply, a couple fans, and  Drok buck 12 power supply in a nice case and mounted it in the redhouse.



Light Controller

At the moment, our lights are dumb.  They turn on and off manually and do not care about sun.  We need a smart controller.  I used the Particle Photon, which is a cheap wifi-enabled MCU that’s only $20.  I’ve been using the photon a lot lately.  This is actually the third unit inside the Redhouse and I plan on using at least one more.  We also need a sensor to measure how much light we are getting from the sun.  I had an SI1145 sensor breakout from adafruit laying around so I used that.

To control the LED brightness, I use a MOSFET.  By modifying the signal’s pulse width on the MOSFET gate, I can control the voltage allowed to pass through the MOSFET.  I wired everything up, wrote a few lines of code using the Particle builder and this is what came out:


The light sensor won’t work without light, so I need a case with a clear lid.  I found a waterproof project case on amazon that had a clear lid.  Perfect.  I installed the board in the case, wired it up, and installed it in the Redhouse.



How much did this cost me?  I try not to think about it, because I’m not building to necessarily save (although, I believe I am).  Here’s a list of components and their costs:

LED Light:

  • 6 x 30W LEDs –  ebay seller sungrowled – $77
  • Aluminum strip and screws – home depot – $15
  • 24V AC-DC 350W converter – – $35
  • Drok 600W buck boost converter – – $21
  • 5 x aluminum heatsinks – – $25
  • Power enclosure – – $30
  • Grow light hanger – – $10


  • Particle Photon Wifi MCU – – $20
  • SI1145 visible light sensor – – $10
  • MOSFET n-channel – – $2

Total: $245

For comparison, you can get a nice (but dumb) 160W grow LED for about $350.  No wifi/internet control.  No smarts.

I think I saved some bucks and get more features.  Here’s the final product growing some nice Roma variety tomatoes:


Do they work?  Early indications suggest they do.  The plants under the light look more lively.  One plant NOT under the light has a livelier branch under the light where the other branches are not as lively.  So, pending future observation, I conclude, it works.  I only have 2 more of these to make :).

RedHouse – System Test 2

The RedHouse is online!

We’ve got plants, we’ve got greenhouse and we are connected.  Using the particle photon and some very simple code, I can monitor the status of the redhouse from anywhere with internet connection.  I’ve been testing it for the past week and it’s been working well.  The biggest problem is unreliable wifi in the greenhouse, but that isn’t a killer problem.  I was still able to turn on the watering system while I was on vacation for a couple days.

There is still a lot of work to do, but we are far enough along to grow some serious plants.


Update (Sept 23): Wifi problem solved in software.  Connection is great now.  I added a huge external antenna, but it’s completely unnecessary.