Intro: Arduino Programmable Heater Blower Thermostat With DS18B20 Temperature Sensor
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.
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
- Solder Iron
- Wire Cutters / Strippers
- #2 Fillips Head Screw Driver
- Precision Fillips Head Screw Driver (screws in relay module).
- Nitrile gloves
- Lighter or Small Blow Torch
- Optional: 3D Printer for LED Screen / control box housing.
- 1x 3.5v 5mm Green LED
- 1x 220 ohm resistor
- 1x Songle 30A 250vac Relay (p/n: SLA-05VDC-SL-C)
- 1x Arduino Uno or compatible controller
- 1x LCD Keypad Shield (SKU: DFR0009)
- 1x DS18B20 Waterproof Digital Temperature Sensor
- 1x DS18B20-XH Adapter
- 1x Epoxy Plumbing Putty
- Heat Shrink Tubing
- Male / Female Breadboard Jumper Wires
- Wire 22ga (6vdc power for relay from Arduino)
- Wire 16ga (115vac power from house)
- 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:
- Solder a Male to Female breadboard jumper with the male end through D13 and connect to the "SIG" pin on the DS18B20-XH Adapter.
- 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.
- 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.
- 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:
- 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.
- 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.
- 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).
- 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:
- Take a 3.5v 5mm Green LED and trim the V+ (Long leg) as shown above.
- Trim a 220 ohm resistor as shown above.
- Solder the trimmed leads together.
- Solder a Male to Female breadboard jumper to the V+ side
- Solder a Male to Female breadboard jumper to the V- side
- 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:
- 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.
- 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:
- 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!
- 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:
- Take the screws out of the 6v 1a Wall-Wart style transformer / power adapter and break any glues seals to get the case apart.
- Cut the high voltage wires (yellow in picture above) from the forks that would plug into a wall outlet.
- Remove the forks from the transformer case with a pair of pliers.
- 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.
- 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).
- Tin the free ends of the length of 16ga wire.
Step 13: Transformer Case:
- Clip out a slot for the new High Voltage wires in the end of the transformers case.
- Fill the fork holes in the case with hot glue.
- Pull the new High Voltage wires through the slot and reassemble the transformer case.
- 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.
- Mmintbox 1 Enclosure
- by Vector_Mayhem
- Aug 29, 2013
Step 16: Wiring Up the Project to the House:
- Make sure all sources of AC voltage are disabled at the source such as at an electrical breaker box.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
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:
Define the LCD Button Voltage Divider (each LCD Keypad is unique):
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:
- OneWire.h - (Onewire.Zip)
- DallasTemperature.h - (Arduino-Temperature-Control-Library-master.Zip) - FIXED by Me.
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:
- Download the library and save it to a directory you can find it.
- Leave the library zipped before you import it into your Arduino IDE.
- Open the Arduino IDE and go to Sketch > Include Library > Add .ZIP Library.
- 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.
This is an entry in the
Electronics Tips & Tricks Challenge