Emontx based solar hot water controller
Overview
In many solar hot water systems (systems that don't thermo-syphon) a pump is needed to circulate the water in between the solar hot water collector (evacuated tube or flat plate) and the solar hot water cylinder resulting in the transfer of heat from the collector to the water in the hot water cylinder.
The pump must only turn on when the water in the collector is hotter than the water in the cylinder and so to control the pump a solar hot water controller is needed. The controller measures the temperature at the collector and the bottom of the solar hot water cylinder and when the temperature difference is more than a set amount (say 7-10°C) it turns the circulating pump on transferring heat from the collector to the cylinder, when the temperature difference then drops to around (3°C-5°C) it turns the pump off.
Left: the solar hot water collector, the temperature sensor is in the manifold.
Right: the solar hot water cylinder, the temperature sensor at the bottom is used to calculate the temperature difference with the collector.
Safety
Another important task of a solar hot water controller is to ensure the safe operation of the system.
Vented or un-vented hot water cylinder?
As heat is added to water it expands and if the water has nowhere to expand to, as in an un-vented system (a sealed system), the pressure will increase. As the pressure increases, so does the boiling point. If an un-vented hot water cylinder is heated to dangerous levels above 100°C and then the pressure in the cylinder is released such as by opening a tap, the water in the tank will vaporize and expand rapidly causing an explosion that could cause significant damage.
It is possible to add a check in the solar hot water controller software to make sure that if the cylinder reaches a maximum temperature - let's say 80°C so that we are well under the 100°C boiling point, the circulation pump is turned off to stop the solar collector from continuously adding more heat. I'm not sure if this will be enough to prevent the danger completely as there could be a situation where the controller could crash with the pump stuck on and so fail to cut off.
Due to this danger I would advise against the use of this system for un-vented hot water cylinders and don't really have the expertise to comment further. I have only tested this with a vented cylinder.
Cold temperatures, freezing
If you don't have antifreeze in your system, you will need the pump to turn on to stop the water from freezing. If the water freezes it could damage the manifold and pipework.
It's worth keeping a watchful eye on your system temperatures to make sure they stay within safe limits.
Hardware
The core of the system is the emontx, to which 3 one-wire temperature sensors are connected to measure collector temperature, cylinder top and bottom temperature. The Solar Pump is controlled via a simple 5V relay + driver circuit connected to the pulse input/output port on the emontx, which is essentially a digital input/output.

Start by following the EmonTX build guide and connect up 3 one-wire temperature sensors (with the 3 temperature sensors stacked on the one-wire bus).
For the pump control there are many different relays available, I used a OMRON G5LA-1 5DC which can be driven from the 5V supply that is available on the emontx. The Atmega digital output by itself cannot supply enough current to drive the relay, so we can use the digital output to switch a 2N2222 which will then deliver the full current needed. A diode is needed in parallel with the relay (called a flywheel diode) to circulate current as the magnetic field in the relay coil collapses, preventing a damaging negative voltage appearing across the transistor. Here is a circuit diagram:

It it worth noting that you need at least 3mm of air gap between the mains end of the relay and the low voltage side, or more if it's on a PCB.
On version emonTx V 2.1+ there is a little jumper that can be soldered to provide the port with 5V, see here.
Software
Here is the core measurement and control code that covers the main control functionality of the solar hot water controller. You may then want to extend this with RF code for sending to an emonbase and then to the web for visualisation:
#include <OneWire.h> #include <DallasTemperature.h> #define ONE_WIRE_BUS 4 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); // Addresses where found manually using temperature_search (emontx firmware) DeviceAddress address_col = { 0x28, 0x22, 0x70, 0xEE, 0x02, 0x00, 0x00, 0xB8 }; DeviceAddress address_cylb = { 0x28, 0x85, 0x7A, 0xEE, 0x02, 0x00, 0x00, 0xDC }; DeviceAddress address_cylt = { 0x28, 0x95, 0x51, 0xEE, 0x02, 0x00, 0x00, 0x0F }; int pump = 0; void setup() { Serial.begin(9600); sensors.begin(); // Relay control digital output pinMode(3,OUTPUT); } void loop() { sensors.requestTemperatures(); double COL = sensors.getTempC(address_col); double CYLB = sensors.getTempC(address_cylb); double CYLT = sensors.getTempC(address_cylt); double diff = COL - CYLB; // If Collector is 10C above the bottom of the cylinder turn pump on if (diff > 10.0) pump = 1; // If Collector is less than 5C above the bottom of the cylinder turn pump off and // only if collector temperature is above 2C to allow for freeze protection hysteresis. if (diff < 5.0 && COL > 2.0) pump = 0; // Check to stop overheating of cylinder if (CYLT > 80) pump = 0; // Stop water in pipework from freezing if // temperature drops below 0C and no antifreeze if (COL < 1.0) pump = 1; if (pump) digitalWrite(3,HIGH); else digitalWrite(3,LOW); }
Emoncms example
Click to view live:
Further development
Hot water cylinder analysis
