Arduino Solar Water Heating Pump Controller

The REUK 2013 Solar Water Heating Pump Controller (pictured above) is one of the most popular products on the REUK.co.uk website. With a temperature sensor on the solar water heating panel, and a second on the hot water tank, this controller decides when to turn the pump on to circulate solar heated water from the panel to the tank.

This controller is based around a PICAXE-08M2 microcontroller which gives a good balance of programmability and simplicity. It does however have one large disadvantage – it can only do integer arithmetic, i.e. performing operations on whole numbers only.

Therefore when we come to make modifications to the controller for particular customer requirements – e.g. frost protection and maximum temperature shut offs etc – things get unnecessarily complicated. Additionally there is limited memory on a PICAXE-08M2 which becomes a serious problem as the complexity of the desired programming increases.

For this reason we are currently porting a lot of our PICAXE based controllers to Arduino which allows floating point arithmetic and far more memory space.

Pictured below is our latest Arduino solar water heating pump controller. It is functionally identical to the standard 2013 PICAXE controller, but offers much more flexibility for modifications and added features.

Arduino pro mini based REUK solar water heating pump controller

The Arduino board used here is the Pro Mini – the smallest of the Arduino range. The red board plugged on to the blue Arduino board in the above photograph is used to connect the Arduino to a PC via USB for programming and/or so that data can be outputted to a serial monitor in real time or for later analysis as shown below where the temperature of the solar panel and of the hot water tank is outputted once every second. If monitoring is not required then this break out board can be removed.

Serial terminal output for arduino solar water heating pump controllerIf you have any particular requirements for a solar water heating pump controller which are not met by our standard controller range, email neil@reuk.co.uk with details of what you need.

If you are interested in building and programming your own solar water heating pump controller as a project, click here for our simple Arduino Solar Water Heating Pump Controller Design and Code which should help you get started.

Arduino Introduction

We have been receiving a lot of questions about Arduino lately, so in this blog post I will attempt to briefly cover the topics about which we are most often asked – how to get started and which Arduino boards to use.

NEW – We are now publishing the full Arduino source code for many of our projects and products here: Arduino Projects.

The official Arduino website describes Arduino as an open-source electronics prototyping platform, and it is designed to be used by anyone interested in creating interactive objects or environments. We for example use Arduino primarily in a wide range of timers and controllers which act upon measurements made of the surrounding environment using sensors such as light detectors, temperature sensors, and many types of switches.

Arduino Uno board

For anyone getting started with Arduino we would recommend the Arduino Uno board pictured above which retails in the UK for around £20. It can be powered from the USB cable which is connected to a computer when uploading your sketch (Arduino program code) to the board from the Arduino IDE (see below), or via an external 7-12V DC power supply.

Click here to download the Arduino IDE (integrated development environment) software to your PC (Windows or Linux) or Mac. This is where you will write your sketches, communicate with your Arduino board, and find lots of useful example code.

There are a wide selection of alternative Arduino boards offering different features, numbers and types of inputs and outputs, and different physical sizes and prices. These are detailed on the Arduino website.

There are also a selection of Arduino Shields which connect to Arduino boards to give additional advanced functionality – e.g. Wifi, GSM, and ethernet connectivity, motor control, SD card slot for datalogging, real time clocks, LCDs, or simple prototyping boards for you to use for added external components and/or sensors.

arduino nano and pro mini

Pictured above are the Arduino Nano and Arduino Pro Mini. These small boards are excellent for embedding in projects thanks to their small size. The Pro Mini for example is a tiny 0.7″ x 1.3″ small.

The Arduino Nano retails in the UK for around £20-25, but as Arduino is open-source, much cheaper clones are available with prices starting at around £6 only including a USB cable and air mail delivery!

Clones of the Arduino Pro Mini are available from around just £3 each, but as the image above shows, this board does have a USB connection. In order to programme the Pro Mini you need a breakout board such as the one pictured below.

ftdi basic breakout board for arduino pro mini

This is an FTDI Basic Breakout For Arduino USB-TTL 6 PIN 3.3/5V. When you want to programme the Pro Mini, you connect it to this breakout board and connect that via USB to the computer. These boards are available from around £5.

FTDI board connected to Arduino Pro Mini board

Here are the labels on the Pro Mini terminals which are hidden in the image above to show what connects to the FTDI breakout board.

Connections for ftdi breakout board on arduino pro mini board

When programming is complete, you disconnect the Pro Mini and use it in your project, and you still have your breakout board. Therefore if you are doing a lot of embedded projects, the Pro Mini is the most cost effective Arduino board to use.

The other option for projects is to prototype using an Arduino development board, and then make an Arduino standalone. For this you programme the microcontroller on the board, and then remove it (possible with the Arduino Uno and older Duemilanove boards) and add it to your own circuitry. We detail this option here: Standalone Arduino on a Breadboard.

It is getting harder to find the Uno and Duemilanove boards now as they have been superseded with the latest Arduino boards which have surface mounted microcontrollers. But, you only need the one board for prototyping and programming, and when you have one, it is easy to get the ATmega328 chips with the Arduino bootloader pre-installed for your projects.

Here are some useful links to help you find the above described items:

Arduino Uno – Rev 3.0 boards with USB cable supplied. £17+ for official boards, or from £6 for compatible clones. Make sure to choose a ‘development board’ (not surface mounted microcontroller) if you want to remove and embed the microcontroller chip in your projects. See image below (development) compared to the surface mounted version at the top of this posting.

arduino uno development board

Arduino Nano – from £12 for official boards, and from £6 for compatible clones (mostly available with included USB cable). Note that headers are usually not soldered onto cloned nanos (so they do not spike through the package in the post), but will be included for you to solder.

Arduino Pro Mini – from under £3. Supplied with headers for you to solder.

FTDI Breakout – for the Arduino Pro Mini – you just need one which you can reuse. Prices from around £5.

Arduino Duemilanove – from £10 for clones, and up to £20 for official boards. Not many available now compared to the Uno.

ATmega328 – chip supplied pre-loaded with duemilanove bootloader or Uno bootloader (choose the correct one for your board). Comes with the clock crystal and capacitors required for an Arduino standalone.

Analogue Inputs with Raspberry Pi

We have been doing a lot more work with Raspberry Pi over the last few months on some interesting projects which we will soon be covering on the REUK.co.uk website.

Raspberry Pi has an infinite number of uses and offers a great mixture of power, flexibility, and price, but it is lacking in one regard – its GPIO (general purpose input output) does not offer analogue input (ADC – analog digital converter) pins. Therefore it cannot be connected directly to non-digital temperature sensors, light detectors, or measure voltages etc. (This is in comparison to the similarly priced Beaglebone Black which offers seven  12-bit ADC pins for analogue inputs, or Arduino.)

mcp3008 10 bit adc analogue to digital converter 8 channelThere are however simple and relatively cheap ways around this, one of which we will cover here: the MCP3008 10-bit 8 channel ADC pictured above. This is a microchip which can take up to 8 analogue inputs, and communicate their digital equivalent values (0-1023) to the Raspberry Pi via the SPI serial interface.

mcp3008 board to connect to raspberry pi with light detector and other analogue inputs

Pictured above is a small board we have made with the MCP3008 at its centre. Coming in on the left side are six connections to the Raspberry Pi GPIO – 3.3V and GND power connections, and the four connections for the SPI interface.

male to female jumper links for raspberry pi

To make the connections to the GPIO we used male to female jumper links. The female end pushes over a GPIO pin, and the male end goes into a screw in terminal on our MCP3008 board.

raspberry pi GPIO analogue inputs

In order to set up the Raspberry Pi to use the SPI interface there are some commands which are required and you also need to install the SpiDev module. This is all detailed together with connection diagrams in the links to some external resources at the end of this post.

Python code for raspberry pi analogue light detector input

The above shows the simple Python script we used to measure the light level of a light detector connected to our MCP3008 board (making a voltage divider with the light detector and a 10K resistor and feeding the output voltage into channel 0 of the MCP3008 ADC chip. The script simply measures the light level once per second and outputs it to the terminal.

Python light detector on raspberry pi outputThe measured light level is given a digital value from 0-1023. As we wired it, higher values correspond to darker light levels, so the above screen shot shows the results as the light detector was slowly shaded.

Having got the digital value for the analog light level in the Raspberry Pi, you can do anything with it – control lights, detect dawn and dusk, control motorised curtains, log it, view it online and so on. It is also possible to use the exact same technique and MCP3008 to measure a huge range of other analogue signals including temperature sensors, voltage measurement, potentiometers, etc.

Here are links to some useful resources online to find out more information about reading analogue signals with a Raspberry Pi:

Analogue Sensors on the Raspberry Pi Using an MCP3008 – this offers comprehensive details on setting up the Raspberry Pi for SPI as well as connecting it to the MCP3008 and related Python scripts.

Analog Inputs for Raspberry Pi using MCP3008 – a guide from Adafruit.

MCP3008 Datasheet – get a better understanding of the ADC.

Target Controller for Competitive Shooting

Pictured below is a controller we have just made for use in competitive shooting. The competitor has a line of five targets to hit, each of which has a microswitch which closes when the hit target flips over. When each target is hit, an LED lights up, and when all five targets have been hit and all five lights lit, the lights flash on and off five times before the system resets for the next competitor.

Controller for competitive shooting with five targets and five lights which turn on when targets are hit.

We made this as a standalone Arduino project with the ATmega328 microcontroller. This has more than enough IO (input/output) pins to cope with the five inputs (target microswitches) and five outputs (LED lights switched by MOSFETs). The lights are 12VDC powered, so the controller was also made to be powered by 12VDC.

24V Low Voltage Disconnect with Data Display

We have just finished working on a new low voltage disconnect project for a customer who supplies batteries and power inverters to consumers. Quite often his customers make complaints that the batteries have failed after a relatively short period of time, but he had no way of knowing if there was a problem with the battery or (more likely) a problem with the way the battery has been used and cared for.

connection diagram for 24v low voltage disconnect with LCD displayPictured above is the low voltage disconnect with datalogger we made to solve this problem.  The low voltage threshold at which the connected power inverter will be turned off, and the cancellation voltage at which it will be turned back on again can be set before installing the system. A low voltage of 22-24V is likely to be used and a cancellation of voltage of 24-26V for this 24V battery system.

So that the treatment of the batteries can be assessed later, this controller has a built in datalogger. Every 12 hours it records the voltage measured on the connected batteries. Up to 200 data points can be stored in memory for a record of 100 days of activity. If more than 200 are collected then the earlier data points are over-written so that only the most recent 200 are stored.

24V low voltage disconnect with datalogger and display

If/when the system is returned, an LCD display can be connected which enables the 200 data points to be stepped through from most recent to oldest, and a summary is also generated which displays how many times each voltage (from 1V to 35V) was recorded over the last 100 days. Using this data it is possible to see if the batteries were left uncharged for an extended period of time (very harmful to battery life), and how often they were run down to low charge levels (also bad for batteries).

If you need a low voltage disconnect and/or a datalogger, contact neil@reuk.co.uk with details of your specific requirements.

Accurate Programmable Solenoid Timer

Pictured below is a timer which we made today – designed to energise a solenoid valve for a user-programmable duration after the on board button is pressed.

accurate user programmable timer

In our article Making Very Accurate Timers we looked at some ways in which accurate timers can be made – much more accurate than timer circuits based around 4060B counters and 555 ICs for example.

For this timer though since the accuracy required was +/-1 second in five minutes, we just used a microcontroller (PICAXE), making it much easier to set things up to enable user programming of the timer.

The common way to make such a timer is to have it run for a given number of seconds, and repeatedly call pause 1000 which makes the circuit wait for 1000ms (=1 second). The timing accuracy of microcontroller without external clock crystals can be quite poor, but they tend to be consistent.

Therefore to calibrate the timer we simply set it to run for 30 minutes, measured how long it actually took using a stopwatch (which turned out to be 10 seconds less than 30 minutes (so 1790 seconds instead of 1800). As it was therefore fast by 100*(1800/1790)-100 = 0.558%, we increased the 1000ms pause by 0.588% giving 1006 of the microcontroller milliseconds for 1000 real milliseconds. This slowed the timer down a fraction giving it the required accuracy.

For user programming, the button is used to set first the number of minutes the timer is to run, and then the number of seconds (in 10 second steps). The entered minutes and seconds value is then stored in memory and the timer runs for that time whenever the user subsequently pressed the button to turn on the output.

Rainwater Pump Controller – Anti-Interference Modifications

Pictured below is one of our rainwater toilet flush pump controller units which we have had to modify to overcome a problem with interference.

rainwater toilet pump controller programmed to cope with interference in long float switch cablesThe customer had a problem with the original unit we supplied due to the length of the cables running to the float switch in the header tank – more than 10 metres. This controller is designed to check the status of a float switch at the top of a header tank every two hours. If the header tank is found to not be full then the pump is turned on until it is full, pumping water from a water butt at ground level up to the header tank which gravity feeds the toilets.

The way we had programmed the original unit, the float switch had to remain high on the full water level continuously for one second before the pump would be switched off. Unfortunately during that one second of multiple measurements, at least one measurement was getting scrambled by interference resulting in the pump staying on continuously.

For the new modified unit, the controller tests the status of the float switch 10 times every half a second, and if more than seven of those readings are high, the controller will turn off the pump.

There are ways that we could have suppressed the interference problem with modifications to the hardware, but as we could not test the controller on site we chose a software method which we have found to work well previously – particularly in Eastern and Southern Europe where they seem to have more interference problems than here in the UK.

Van Lights on at Night after Alarm Activated Project

Today we worked on a project for a van owner. He has a Transit van and wanted to have the front fog lights and reversing lights turn on automatically when the alarm is activated (turned on or off) by his key fob, but only when it is dark outside. He wanted to be able to keep the lights on long enough to see when walking to and from the van in the winter.

Device to control van external lights when alarm is activated, but only when it is darkThe device we came up with is pictured above. There is a light detector (light dependent resistor – LDR) on long leads which is to be positioned in the cab of the van. When the measured light level is below a user set threshold, the controller knows it is ‘night’.

The screw in terminal at the top left of the above photograph is connected to a door servo feed wire. When the alarm is activated a high (+12V) signal is present for half a second. Our controller detects this, and if it is ‘night’ turns on the output (12V, less than 1 Amp) which is to be connected across the coil of a 40A automotive relay which switches the front fog and reversing lights. The output remains on for a user programmable duration – programmable in steps of 10 seconds, e.g. 10, 20, 30, 40..etc seconds.

Solar Water Heating Pump Controller with Frost Protection

Our 2013 Solar Water Heating Pump Controller is one of our most popular products offering user programmable automatic control a the pump in a solar water heating system.

solar water heating pump controller with frost protectionToday we finished an updated version of this controller which offer frost protection. Solar water heating collectors and the associated pipework can be damaged by freezing. One way to avoid this is to pump warm water from the hot water tank around the collector(s) when the ambient temperature outside gets close to freezing. This turns the collector into a radiator, radiating heat from the warm water through the pipes and collectors which prevents them from freezing.

In general we recommend that solar water heating systems be drained in the winter to ensure that freezing and the associated damage cannot occur, but we made this particular controller for a customer in Canberra, Australia whose solar collectors have survived for 30 winters without coming to any harm. Also, although their are frosty nights in Canberra, it does not tend to get very very cold there.

The modifications to the controller make it turn on automatically at a user programmable low solar collector temperature (e.g. +5 degrees Celcius), and then turn off when the collector temperature has increased by 2 degrees. This will have the effect of keeping the solar collector from freezing, but the side-effect is that the temperature of the water in the hot water tank will go down.

If you need a controller with frost protection, please contact neil@reuk.co.uk with details of your requirements. It is however only suitable for use in areas with occasional light frosts – otherwise we still recommend draining the system for its protection in the winter.

Project of the Day – Battery Charger Controller and Timer

Today we completed a three way battery charger time controller for use in a motor home. This motor home has been fitted with three 12V batteries which are periodically independently used and charged (via a mains powered battery charger).

In order to keep all three batteries well charged when at home or on a mains hook-up at a camp site, we made an automatic controller. This connects each of the batteries in turn to the charger, with the user able to programme in the charging duration required for each battery – e.g. 3 hours, or 5 hours etc.

To make this controller more flexible we also added in a manual override enabling the user to manually select a battery to leave connected to the charger until they cancel the override – useful if one particular battery needs a lot of charging immediately.

automatic and manual multiple battery charger timer

We fitted one red LED per battery to give a visual indication of which battery is currently being charged, and the green LED lights up when manual mode has been selected.

The low current 12V outputs from our controller/timer go to the coils of three 25A automotive relays which switch the positive output from the mains powered charger to the appropriate battery.