Stock tank control

Keeping water tanks for livestock free of ice is an expensive job in our cold Wisconsin winters. A 1500 watt electric tank heater is left on all the time could cost $120 a month. We have two tanks to keep warm and had three last winter. Most heaters have a thermostat control but they don't always work or may turn on more than needed. This last summer I built a solar horse tank and insulated goat tank. This has helped a lot but on really cold days or prolonged cloudy days the tanks still ice up. With only a single 15 amp circuit to the barn we can't plug in both heaters without popping a breaker. Our first attempt at keeping the water ice free without heating the water was to add a fish tank bubbler. This seemed to help but it ran all the time even when the temperatures were above freezing. I decided to automate the process.

This Arduino project has a waterproof temperature sensor for each tank and another to measure air temperature. The air bubbler is turned on if the air temperature drops below 34 degrees F and off when it is above 38 degrees F. The heaters for the tanks are turned on at 34 and off at 36. These temperatures may need to be adjusted as they are measuring the temperature in the tank and not at the point where water meets the cold air. Only one tank heater is turned on at a time and priority is set to heat the coldest tank first. When that tank raises above the temperature of the other tank the first is turned off and the second one started. An LCD displays the three temperatures and which devices are on. The temperature is checked every 4 minutes.

The bubbler is controlled with a 5 amp relay. The heaters are controlled with solid state relays that can handle 380 volts and 25 amps. This is overkill for the 120 volt, 12.5 amp heaters but way beyond the capacity of the small relays.

Installed controller

This is a picture of the unit on the wall in the goat barn. The stock tanks are just outside the door just to the right of the light switch. The components are housed in a Sterilite food container which is about 7" by 11" by 3". They are not made for electrical use. They are better than having the parts exposed but not all that safe for kids or dumb adults. The temperature sensors are attached with a 1/8" stereo plug and jack. Power is supplied to the unit through the end of an extension cord plugged into the nearby outlet. Power out to the bubbler and two heaters are through appropriately sized extension cords cut to the proper length to reach the heaters. The entire unit can be slipped out of the metal straps holding it up moved to make repairs or upload revised sketches.

The tanks

On this below zero day the goat tank is covered with snow even with the internal water temperature being 46 degrees. There is even ice on the inside of the cover. The two hoses on the top are the bubbler hose and the temperature sensor tube. The cord to the heater is there just under the bubbler hose.

Hand made waterproof temperature sensors

There are waterproof one-wire DS18B20 temperature sensors but they only come in a 3 foot length and I needed 15 feet for one and 5 feet for the other. I also wanted something that would be goat and horse resistant. I used a regular temperature sensor, soldered it to a length of 4 conductor in the wall telephone wire. This was feed through a length of 5/16" OD by 3/16 ID poly tube. The exposed wires by the sensor and the sensor were covered with silicone caulk and pulled into the tube so just the end of the sensor was showing. The end of the tube was fitted with a used 22 shell which fit very tightly in the end of the tube. The shell was also filled with silicone. Before putting the sensor in place I did expand the end of the tube slightly pushing a #2 phillips screwdriver in the end. So far so good.

Possible additions to the sketch could include the following;

Recording of maximum and minimum temperatures

Recording of amount of on time for the bubbler, and each heater.

Charting of all temperatures on Open Energy Monitor

Use the PMW feature of the Arduino to turn the heaters on partially instead of full on.

Button controls to

1. Turn on LCD backlighting

2. Display current temperatures

3. Display the maximum temperatures for the current day and previous day.

4. Display the minimum temperatures for the current day and previous day.

5. Display on times or percentages

6. Display the time until the next temperature reading or force a new read now.

7. Turn off the LCD backlighting

Changes to the tanks might be to

Add insulation to the top of the goat tank. It currently is just a 1/4" piece of Lexan plastic.

Add a night time insulated cover for the solar panel on the horse tank to reduce heat loss.

Start using the insulated float in the horse tank bucket to minimize the surface area exposed to the cold.

Make and use an insulated float in the goat tank.


There was a small error in the placement of an if statement that could allow a tank heater to keep running even if the tank was warm enough. This has been fixed in the HorseTankControl2.pde

This file also changes the LCD display quite a bit. Here is a list of the changes.

Turns the LCD off after 60 seconds.

Sets up six modes for the display.

Adds code for a button to control the LCD display modes

Added a button just under the plastic cover that can be clicked by pressing on the cover above the button.

Adds TimeAlarms to handle button clicks and to time the temperature readings.

Added a recording of maximum and minimum temperatures for the two stock tanks and air temperature.

Add modes to display current temperatures, What is on, maximum and minimum for horse tank, maximum and minimum for goat tank, maximum and minimum for air temperature and a reset all maximum and minimum temperatures.

The turn on and turn off temperatures were adjusted up 2 degrees.

So far it is working well. We will see how it works when we get some really frigid temperatures.

Pictures of the LCD screens and new button will be posted soon.

Files download