Introduction: Arduino Programmable Heater Blower Thermostat With DS18B20 Temperature Sensor

About: Here I am!

High Voltage Warning:

Before we begin I would like to caution that this project will involve high voltage and proper precautions should be exercised during these steps. Make sure all sources of house 115v AC voltage is disabled at the source such as an electrical breaker box. High voltage can cause SEVERE INJURY or DEATH.


A little bit of background:

I recently bought a house during the cold winter months. This house is equipped with a hot water boiler where as hot water is passed through passive radiators in each room. That being said the kitchen was absolutely the coldest room in the house and no obvious radiator was to be seen in only this one room.

Since the kitchen was to be remodeled, the cabinets were being removed and the above pictured Beacon Morris K120 TwinFlo III Hot Water Kick Space Heater was found. When found there was no power and it was not plumbed to the boiler system. After plumbing and adding it to the breaker box the unit worked.

The issue to solve:

This sucker is LOUD and only controlled by manually turning on a 3-position switch to either HIGH > OFF> LOW. This non-ideal situation involved waiting for the boiler to cycle hot water and then poking a pencil through a grate to bring the blower roaring to life.

Simpler Options:

Leaving the blower on as long as the heat was set via a solution to the thermostat was out of the question for at least these 2 reasons; I did not want to hear that blower run for any longer than necessary; I wanted this unit to be completely independent.

Solution to be covered:

A thermostat that is able to measure the water temp inside the radiator, be completely self contained, and have 2 variables that could be user controlled; water temp to cut on the blower and blower run time (make sure radiator is "cool enough" but not cold as to not waste heat.

But wait?You may be asking yourself; I have seen these before! This is a "Use a relay to control a fan based on a temp sensor" scenario, why do I want to use this specific set of instructions when there a others?

I test drove a few of these examples from both this site and in the wild on internet forums. Either the code was for really old sensors with outdated libraries or mostly what I found, the code was not exactly bullet-proof. . . . loops running off the rails, long term failures or other complications. I needed this to be a production quality solution that would meet my needs, not waste electricity or burn the house down.


With all of this said; Lets get started!

Step 1: List of Materials / Tools

Tools:

  1. Solder Iron
  2. Wire Cutters / Strippers
  3. #2 Fillips Head Screw Driver
  4. Precision Fillips Head Screw Driver (screws in relay module).
  5. Nitrile gloves
  6. Lighter or Small Blow Torch
  7. Optional: 3D Printer for LED Screen / control box housing.

Materials:

  1. 1x 3.5v 5mm Green LED
  2. 1x 220 ohm resistor
  3. 1x Songle 30A 250vac Relay (p/n: SLA-05VDC-SL-C)
  4. 1x Arduino Uno or compatible controller
  5. 1x LCD Keypad Shield (SKU: DFR0009)
  6. 1x DS18B20 Waterproof Digital Temperature Sensor
  7. 1x DS18B20-XH Adapter
  8. 1x Epoxy Plumbing Putty
  9. Heat Shrink Tubing
  10. Male / Female Breadboard Jumper Wires
  11. Wire 22ga (6vdc power for relay from Arduino)
  12. Wire 16ga (115vac power from house)
  13. Wire-nuts
  14. 6v 1a Wall-Wart style transformer / power adapter

Step 2: Introduction to LCD Keypad Shield

In this Instructable I will be using a LCD Keypad Shield that's pre-assembled, I find the costs about the same for less effort than assembling one, plus buttons and parts.

This shield uses the LiquidCrystal.h library and the following PINs from the Arduino to operate; 8, 9, 4, 5, 6, 7. The LCD shield also incorporates Six buttons that are controlled by one Analog PIN set by a 5-stage voltage divider. Please note that all of these shields are independent upon where the voltage divider will be set for your specific shield. In my code included later on, this is defined under "int read_LCD_buttons()" and instructions are commented in the code.

Be warned about a known defect with the LCD Keypad Shield and dimming the screen with PIN 10 as this could burn out your LCD Keypad Shield. This is documented on the Arduino forums (http://forum.arduino.cc/index.php?topic=96747.0).

Step 3: Temperature Sensor

The Temperature Sensor used is a DS18B20 Waterproof Digital Temperature Sensor that utilizes a Dallas Temperature IC and the DallasTemperature.h library. For convenience I have paired this with a DS18B20-XH Adapter which will be called with the OneWire.h library.

Step 4: Temperature Sensor Wiring:

  1. Solder a Male to Female breadboard jumper with the male end through D13 and connect to the "SIG" pin on the DS18B20-XH Adapter.
  2. Solder a Male to Female breadboard jumper with the male end through the Arduino's Ground and connect to the "GND" pin on the DS18B20-XH Adapter.
  3. Solder a Male to Female breadboard jumper with the male end through the Arduino's 5vdc and connect to the "VCC" pin on the DS18B20-XH Adapter.
  4. Plug in the DS18B20 Temperature Sensor header to the DS18B20-XH Adapter.

Step 5: Relay Intro:

The relay is a Songle 30A 250vac Relay (p/n: SLA-05VDC-SL-C). I chose this relay because the built-in screw shields in this model are pretty well made and the relay itself is heavy and robust. The main key of switching the blower motor on / off is hinged Safety and Dependability.

Step 6: Relay Wiring - Signal and DC:

  1. Solder a Male to Female breadboard jumper with the male end through D12 and connect to the "IN" pin on the Songle 30A 250vac Relay.
  2. Tin a length of 22ga wire on one end to be securely attached to the Songle 30A 250vac Relay's DC power screw in terminals.
  3. Solder the length of wire from the back of the Arduino's V+ barrel jack (Center) and connect to the "DC+" pin on the Songle 30A 250vac Relay. (It is critical that you use this power source and not the arduino's 5vdc connector as it's not powerful enough to make the relay reliably switch. We will be powering the Arduino with a 6vdc power source later on and thusly the relay through this connection).
  4. Solder the length of wire from the back of the Arduino's V- barrel jack (Outer) and connect to the "DC-" pin on the Songle 30A 250vac Relay.

Step 7: Preparing the Relay LED Indicator:

  1. Take a 3.5v 5mm Green LED and trim the V+ (Long leg) as shown above.
  2. Trim a 220 ohm resistor as shown above.
  3. Solder the trimmed leads together.
  4. Solder a Male to Female breadboard jumper to the V+ side
  5. Solder a Male to Female breadboard jumper to the V- side
  6. Slide a length of heat-shrink tubing per Male to Female breadboard jumper up against the bottom of the 3.5v 5mm Green LED and heat shrink them with a small torch or lighter.

Step 8: LED Wiring:

  1. Solder the Male to Female breadboard jumper from the V+ on the 3.5v 5mm Green LED with the male end through D2 on the Arduino.
  2. Solder the Male to Female breadboard jumper from the V- on the 3.5v 5mm Green LED with the male end through one of the Arduino's ground connections.

Step 9: Secure Your Wiring and Connections:

  1. After all of the connections are soldered, use hot glue to hold and support the wiring against the Arduino UNO Board.

Step 10: Connect the LCD Shield to the Arduino:

Simple as it sounds!

  1. Connect the LCD Keypad Shield to the Arduino. This should be an easy fit especially if you hot glued the previous wiring down to the Arduino PCB board.

Step 11: High Voltage Warning

!!High Voltage Warning!!

The next steps will involve high voltage and proper precautions should be exercised during these steps. Make sure all sources of AC voltage are disabled at the source such as an electrical breaker box. High voltage can cause SEVERE INJURY or DEATH.

Step 12: Hard Wiring the Transformer:

If you have an outlet near your motor / project to be controlled please skip the following steps and simply plug in the 6v 1a Wall-Wart style transformer / power adapter to the outlet and then plug the barrel jack into the Arduino.

If you want / need to hard-wire the 6v 1a Wall-Wart style transformer / power adapter:

  1. Take the screws out of the 6v 1a Wall-Wart style transformer / power adapter and break any glues seals to get the case apart.
  2. Cut the high voltage wires (yellow in picture above) from the forks that would plug into a wall outlet.
  3. Remove the forks from the transformer case with a pair of pliers.
  4. De-solder the high voltage wires (yellow in picture above) from the Transformers PCB board, being careful not to destroy the etching or through-hole.
  5. Solder a length of 16ga wire from each of the High Voltage through holes of the Transformers PCB board (most are bi-polar so Hot / Neutral in most cases will not matter).
  6. Tin the free ends of the length of 16ga wire.

Step 13: Transformer Case:

  1. Clip out a slot for the new High Voltage wires in the end of the transformers case.
  2. Fill the fork holes in the case with hot glue.
  3. Pull the new High Voltage wires through the slot and reassemble the transformer case.
  4. Plug the barrel jack into the Arduino.

Step 14: Relay Wiring - High Voltage Side:

Since we will be switching the HOT side of the power I would suggest using Black wire for both of the following connections.

  • Tin both ends of the 2 lengths on 16ga wire.
  • Attach one of the 16ga wires to the Songle 30A 250vac Relay's COM screw terminal.
  • Attach one of the 16ga wires to the Songle 30A 250vac Relay's NO screw terminal.

Step 15: Make It Presentable:

If you have access to a 3D Printer, you can make a case for the Arduino Uno / LCD Keypad Shield. I used a slightly modified case from thingiverse.com and covered it in a carbon fiber looking vinyl.

Case Used:

Step 16: Wiring Up the Project to the House:

  1. Make sure all sources of AC voltage are disabled at the source such as at an electrical breaker box.
  2. Attach the 16ga wire from the Songle 30A 250vac Relay's COM screw terminal to the houses HOT wire using a wire nut. **If hard wiring the transformer, please see below.
  3. Attach the 16ga wire from the Songle 30A 250vac Relay's NO screw terminal to the Blower / Fan's HOT wire using a wire nut.
  4. Attach the Blower / Fan's Neutral wire to the houses Neutral wire. **If hard wiring the transformer, please see below.

Hard wired transformer additional steps:

If you are hard wiring the transformer you will need to hook up one of the High Voltage Wires from the transformer to the Hot and the other High Voltage Wire to the Neutral of the house current when hooking up the above with wire nuts.

Step 17: Temperature Sensor Placement:

Since I am utilizing the blower to move heat out of the radiator and into the kitchen, but did not want to place the sensor inside of the radiator assembly, I have attached the DS18B20 temperature sensor's probe to the radiators' out pipe on the "cold side". This will help prevent the blower from kicking on with readings that are higher than the water inside of the radiator. There is some code to also prevent this that I will go over later on.

  1. Using Nitrile gloves, take a small amount of hardening Epoxy Plumbing Putty and kneed it into a ball to get the proper mixture of putty / hardener.
  2. Making sure the DS18B20 temperature sensor is flat against the out pipe, press and hold the putty against the sensor and pipe, effectively securing it in place.
  3. Allow to harden.

Step 18: Arduino Code:

The code is attached (Temp_Controller_LCD_EC7_F_DELAY.ZIP) and is thoroughly commented inline with what each part of the code is doing. I'll add some highlights here but do take a read through the code.


**WARNING**

This Code is Configured for a Hot Water Boiler system, your configuration may vary.
Set the following code to turn on the heater blower when the water is HOT; use a < under "Check Temperature is in limit". If turning on something such as an electric heater and monitoring an environment for cold use an >

I have added a pull-down command in the setup code that will keep the Relay and Led from momentarily powering up when the Arduino is reset for any reason;

  • // Initialize Relay PIN so it stays inactive at reset
  • digitalWrite(RELAY,LOW); //Turn off Relay
  • // Initialize LED PIN so it stays inactive at reset
  • digitalWrite(LED_GREEN,LOW); //Green LED Off


Code Quick-start (Find in Code):

Set the DEFAULT Temperature value for the Relay:

  • int SetPoint=75;

Define the LCD Button Voltage Divider (each LCD Keypad is unique):

  • int read_LCD_buttons()

Code from F to C:

  • Change all instances of "getTempFByIndex" to "getTempCByIndex"
  • Change all instances of " lcd.print("F "); " to " lcd.print("C "); "

Change or Remove Blower Cut-off Delay:

  • Modify or remove at end of code:

    delay (120000); // Delay 2 minutes to keep relay from recycling until temp normalizes.

Step 19: How to Install an Arduino Library:

Libraries needed for this project to work:

  1. OneWire.h - (Onewire.Zip)
  2. DallasTemperature.h - (Arduino-Temperature-Control-Library-master.Zip) - FIXED by Me.
  3. LiquidCrystal.h

Unfortunately not all versions of Arduino libraries are created equal, for instance there was a bug in the DallasTemperature.h that was throwing a wrench in this project. To make it easier, I have included a copy of each of these libraries used in this Instructable.


How to install an Arduino Library:

  1. Download the library and save it to a directory you can find it.
  2. Leave the library zipped before you import it into your Arduino IDE.
  3. Open the Arduino IDE and go to Sketch > Include Library > Add .ZIP Library.
  4. Click on the Library .ZIP file you want to import and click Open.

For a complete reference on importing libraries please refer to the Official Arduino Guide for Libraries.

Step 20: Button Controls:

Once you have setup the code for your specific project by using the quick start guide under the Arduino Code section of this Instructable, the day to day controls are simple;

Once you have set the Default Temperature;

  • int SetPoint=75;

You can make temperature detection adjustments on the fly with the up and down buttons on the LCD Keypad Shield. This makes it easier to calibrate the detection settings for your specific project that can be updated in the code as the default if needed.

Step 21: Finished Product:

I now have a programmable thermostat control for my Beacon Morris K120 TwinFlo III Hot Water Kick Space Heater. Since it's been set, I just leave the factory switch set to LOW, forget about the rest, and enjoy a warm kitchen for years to come.

As an FYI; mine is set to detect at 75 degrees F which is not detected in the summer months, so I leave this on all year long and have not had any issues in Year 1.