Saving energy with a netduino

Bamboo leaf

Our home is equipped with a relatively old gas heater, built in 1996. It still works great, has been serviced regularly since it was installed and there is no good reason to replace it yet. However, it isn’t as energy efficient as more recent models.

The other aspect of this gas water heater is that it keeps the water hot 24/7, 365 days a year whether we need it or not. In my home, we generally only need hot water in the morning between 7 and 9 AM and in the evening, from 5 to 9 PM. On weekends, our schedule is a bit whacky and we need hot water from 8 AM to 9PM.

So, 30 hours for week days + 26 hours for weekends, that’s 56 hours / week where hot water is actually needed, as opposed to 168 hours / week when the heater is just left alone. In order words, in our house, we only really need a third of the water heater energy that we normally consume.

To make matters worse, the water heater was installed in the garage by the builder and it gets pretty cold during the winter time.

Considering that ~25% of our heating bill goes into heating water, I felt compelled to stop this senseless waste.

The idea that I came up with was to design a scheduler, configured to follow our weekly hot water usage pattern and capable of lowering the water heater temperature down to a minimum during off-hours.

I wanted it to be cheap to build with easy-to-find parts and very reliable as my wife does not appreciate cold showers: I decided to use a netduino-mini micro-controller, an AdaFruit DS1307 real-time clock and a servo to adjust the temperature of the water heater.

Here’s what the end result looks like in action:

Startup Sequence

Manual Override

The slow moving speed of the servo is intentional in the application in order to minimize wear and tear on the servo’s gears and the overall assembly.

The configuration of the clock and the schedule is done over a serial interface. Here’s a sample output:

[02/19/2011 19:29:40]
Water Heater Controller v1.0

[02/19/2011 19:29:40] Initializing...
[02/19/2011 19:29:40] Loading schedule
[02/19/2011 19:29:40] Centering servo
[02/19/2011 19:29:41] Setting heater on high heat by default
[02/19/2011 19:29:51] Running...
Time: Saturday, 19 February 2011 19:29:51
Heater Schedule Today: Sat [8-21] [0-0] [0-0] [0-0]
Heater Status: ON [scheduled]

Main Menu:
1 : Show Schedule
2 : Set Schedule
3 : Set Clock
4 : Swith Heater ON / Resume Schedule
X : Shutdown

[02/19/2011 19:29:52] Heater state change
[02/19/2011 19:29:52] Setting heater on high
Heater Weekly Schedule:

Sun [8-21] [0-0] [0-0] [0-0]
Mon [6-9] [17-21] [0-0] [0-0]
Tue [6-9] [17-21] [0-0] [0-0]
Wed [6-9] [17-21] [0-0] [0-0]
Thu [6-9] [17-21] [0-0] [0-0]
Fri [6-9] [17-21] [0-0] [0-0]
Sat [8-21] [0-0] [0-0] [0-0]

You can find the C# code for this project at
Look for the “/Samples/WaterHeaterController (netduino)” folder.

The rest of this post documents the implementation details of the system you should be inclined to build your own.

Actuating the water temperature knob

Our gas water heater is equipped with a thermostat control like this one The knob has a large dial, with a fairly flat hand-grip surface.

I needed to figure out how much torque was required to turn the dial in order to buy an appropriate servo. The method I used was simple: mount a lever on the knob, attach a light container to the lever, pour water into the container until the knob turns, measure the amount of water poured and derive the appromixate amount of torque based on the length of the lever and the amount of water.

Using various Internet resources to calculate torque, I determined that I needed an absolute minimum of 12 oz-inch of torque to get the knob to turn. To be on the safe side, I selected a servo with nearly 6 times as much torque and purchased a HiTech HS-6635HB servo for about $30.

Why de-rate the servo requirements so much? A few reasons:

    The servo needs to be robust and reliable for many years and must not strain moving the load.
    Having too much torque is better than not enough and it is easy to control in software.
    High-torque servos have better ball bearing systems and stronger gears made of metal or heavy duty resin.

Mounting the servo on the water heater

I chose to anchor the servo to the gas pipe of the water heater, using the section of the pipe to the left of the gas valve. To do so, I cut a piece of wood from left-over hardwood flooring material to fit the lower left area of the pipe. I drilled holes on the top and left sides of the board so that it could be secured to the gas pipe using zip ties. I also drilled 4 holes to secure the servo to the board with long thin screws and locking nuts.

Connecting the servo to the control knob

The parts for this phase are easy to come by at hardware stores and craft stores:


    2 popsicle sticks
    A spool of thin metal wire
    A thin but sturdy brass rod
    A section of rubber gasket long enough to fit around the circumference of the water heater knob. Make sure that the width of the rubber gasket doesn’t exceed the width of the knob’s hand-grip
    An adjustable metal ring
    Hand-craft a bracket the length of the popsicle stick from a thin strip of brass


    Drill two holes near the end of the popsicle sticks.
    Make sure that the thin brass rod fits easily through the holes but doesn’t have wiggle room either.
    Secure one of the popsicle sticks to the brass bracket with some tape then with the metal wire wrapped tightly around it.
    Insert the brass bracket between the rubber gasket strip and the metal ring
    Tighten the metal ring around the water heater knob.

The final assembly should feel tight and strong while turning the knob.

To secure the other popsicle stick to the arm of the servo, drill a few holes into the stick, matching the holes in the servo’s arm. Then weave the thin metal wire through the holes, then wrap the metal wire tightly around the stick and the servo’s arm. The final assembly should also be tight and strong while turning the servo’s arm.

Connect the popsicle sticks together with the brass rod and secure it by bending it carefully around the ends of the sticks. It’s easier to do this while the servo’s arm is not attached to the servo.

Finally, re-attach the arm to the servo and test the assembly by moving the servo’s arm slowly.

The knob should turn in sync with the servo with ease.

Building the Water Heater Controller board

This controller board is built around a netduino-mini, a DS1307 real-time clock by AdaFruit Industries and a few other components:

    2 1N4001 rectifier diodes
    4 LEDs of different colors
    4 ~220 Ohm resistors (for the LEDs)
    1 2N2222 transistor
    1 300 Ohm resistor
    1 momentary switch
    1 100 Ohm resistor (to be used with the switch)
    1 10K resistor (to be used with the switch)
    1 9 volt / 1A power wall-wart supply
    1 generic proto board
    straight and angled pin headers
    1 barrel jack connector for the power supply

Simple Wiring diagram

To further increase the life of the servo, I decided to control the power supply to the servo through a 2N2222A transistor. It works well because the servo doesn’t need to hold the water heater knob into place all the time: once positioned, the knob stays where it is and the servo no longer needs power to maintain its position.

The base of the transistor is connected to the ‘Servo Power Enable’ (pin 16 of the netduino mini) through a 300 Ohm resistor in series with a 1N4001 rectifier diode. The diode is there to eliminate 0.7 volts present on the pin even when it is turned off.

Here’s the thread on the netduino forums discussing the 0.7 volts issue which seems specific to the netduino mini.

To be on the safe side, I also added a 1N4001 rectifier diode on pin 23 (power ground) of the netduino mini to prevent any potential damage to the micro-controller if the power were connected backwards. I did not see such protection on the schematics of the mini.

Building the board:

The final board:


Connect a dumb-terminal to COM2 on the netduino mini (or to COM1 on the regular netduino).

Using the serial interface:

Set the clock’s date and time and define a schedule when the heater should turn ON.

The schedule tracks 7 days, with 4 timeslots for each day. Each timeslot has a begin time defining when the heater should turn itself ON and an end time, defining when the heater should turn itself OFF.

Setting a timeslot to 0 resets the timeslot and the heater stays OFF.

Keep in mind that the heater timeslots and the clock expect to work on a 24 hour schedule.

Heater Weekly Schedule:

Sun [8-21] [0-0] [0-0] [0-0]
Mon [6-9] [17-21] [0-0] [0-0]
Tue [6-9] [17-21] [0-0] [0-0]
Wed [6-9] [17-21] [0-0] [0-0]
Thu [6-9] [17-21] [0-0] [0-0]
Fri [6-9] [17-21] [0-0] [0-0]
Sat [8-21] [0-0] [0-0] [0-0]

The schedule data takes 56 bytes, which happens to fit perfectly into the 56 bytes of battery-backed user-memory in the DS1307 clock. Funny how this worked out 😉

The push button (High heat override) on the board forces the water heater into high heat, overriding the pre-defined schedule settings.

Meaning of the LEDs

    High heat LED: ON indicates that the water heater is set to high heat.
    Low heat LED: ON indicates that the water heater is set to low heat.
    Servo Active LED: ON indicates that the servo is changing position.
    High heat override LED: ON indicates that the push button was used to override the schedule.

Starting the water heater controller the first time

Before you apply power to the board, make sure that the arm of the servo is centered (vertical position). This will ensure that the startup sequence is smooth. From there, the controller will slowly set the water heater knob on high heat before tracking to the schedule.

I’ve been running the controller on the gas water heater for a few weeks now and I’m anxious to see what our next water heating bill will look like 🙂

Happy Hacking!

PS: a number of readers have mentioned the potential risk of Legionellae bacteria development in the water. While this bacteria is more of a concern with cooling systems, to be on the safe side make sure that you tune the system so that the water temperature reaches at least ~130 degrees Fahrenheit when the system is ON.



  1. Pingback: Saving energy with a netduino « Interesting Tech
  2. Scott · February 22, 2011

    You must live in the tropics. This will work in places with warm weather. In places where it is cold, you need the hot water even when you are not home to avoid pipes freezing.

    • Fabien Royer · February 22, 2011

      Hi Scott,

      I live in Seattle, so it’s far from tropical 😉
      Freezing pipes is not a real concern in this case: the pipes are inside the house and the water heater temperature never drops so low that they could freeze.


      • Joe · February 25, 2011

        umm, just out of curiosity, why don’t you have a thermal blanket around the water heater to help insulate it. Especially if its in the garage ?

      • Fabien Royer · February 26, 2011

        Hey Joe,

        I wrapped the heater in insulation right after completing this hack.


    • Jasmine · February 22, 2011

      That makes no sense at all. The cold water pipes can’t freeze either, and they NEVER have hot water running through them. What keeps water pipes from freezing in the winter is adequate insulation.

    • Ryland · February 25, 2011

      No, you don’t need hot water to keep your pipes from freezing! cold water lines run the same routes as hot water lines only spaced about a foot away on average and the water in the pipes cools off to ambient temp in an hour or less, if your house has water freeze in the pipes when it hits 20F below zero then you will find out in the first year that you are in your house and you will have to fix it properly!
      I have my electric water heater on a timer and it’s cut my water heating costs almost by half, paid for the cost of the timer in the first 6 months.

  3. Robert · February 22, 2011

    Very nice!

    Have you thought of using a Netduino plus and allow control of the item through the internet (or your local network)? Obviously you won’t have such a nice small package, but it will allow you to control it from anywhere (set it to high just before you go home, to be able to take a hot shower as soon as you arrive home).

    I don’t have this kind of heater, but this does give me some ideas for my next netduino-based project, once I finish the current one (a water level indicator for the water-tank on the roof), but it will be a while, as this project is moving VERY slowly.


    • Fabien Royer · February 22, 2011

      Hi Robert,

      I will eventually connect the controller to the rest of my home network but my goal was to make this as autonomous as possible so that I don’t have to worry about turning it ON or OFF: it just tracks the schedule that I configured and I can forget about it 🙂


  4. Pingback: Gas Water Heater controller built around a netduino-mini, a DS1307 clock and a HiTech HS-6635HB servo « adafruit industries blog
  5. AntonioCS · February 22, 2011

    Wow. Amazing work. I wish I knew how to do stuff like this 🙂

  6. Lisa Johansson · February 22, 2011

    Google for tankless or continuous flow hot water heaters. Quite common in the non-US, and offer two advantages over a water cylinder: only the water you actually use gets heated, and the hot water will never run out even if the Brady Bunch is visiting.

    • Fabien Royer · February 22, 2011

      Hi Lisa,

      Yep, that’s what I plan on replacing our current water heater with when the time comes.


  7. Jeff · February 22, 2011

    A couple comments….

    1) Tankless water heaters aren’t always a better idea. Talk to a reputable dealer and do some research first.

    2) I do like your idea. I have manually adjusted my water heater to try to save gas, so your automatic method looks very interesting to me. However, I’ve heard from several sources that the thermostat on water heaters isn’t made to be adjusted frequently, implying that it will wear out or fail faster if adjusted frequently. I’d be interested in hearing about your long-term experience.

    Best wishes on your project!

  8. Another Jeff · February 22, 2011

    I am curious as to the actual savings with this device, because of the net heat required to raise the water temperature back up if it falls much… if it doesn’t fall that much then your not saving much anyway.
    The reason I mention this is that from personal experience, my hot tub was cheaper to keep warm than to let it cool off any more than a few degrees. It cost more money in the long run to switch it off when not in use. It seems weird, but it all comes down to how often you heat it back up. If it is only once a week, then yes it would save to be off, but if it was heated back up nightly from a complete off cycle all day… then it cost more to do the cycle.

    How well insulated is your water heater? An insulating blanket around it would stop or at least help to limit heat loss. I have a feeling you would be surprised how rarely it would run if it insulated better. The inefficiency in the unit comes from two places. One is the type of insulation, the other is the heating element. Since you are still using the same element, the same inefficiencies are there. If you add blanket insulation, you can fix the other.
    If you add a little heat all day, or just a whole bunch when you need it, (besides what is lost through the insulation) in most cases it just comes out in the wash… no pun intended.

    I am curious if you do notice a savings. It is certainly not a bad idea if it does save enough to make it worth it,… besides it’s a cool Arduino learning project.

    Oh yeah, you could likely get another type of thermostat, more appropriate for this frequent changing, still cheaper than a new water heater, if the one you have wears out.

    Thanks and keep us posted!

    • Fabien Royer · February 22, 2011

      Hey Jeff,

      Thanks for sharing your experience and your thoughts on this.

      I am as curious as you are about the savings realized with this hack and I plan on tracking and measuring the results of this experiment closely and I intend on writing a report based on this experiment within a few months or a year.

      I agree with you that improving the insulation of the water heater would be a Good Thing(tm) to improve as a next step: I have reasons to believe that the layer of fiber glass insulation within the heater is doing an average job at best.


  9. Pingback: Blog » Blog Archive » Gas Water Heater controller built around a netduino-mini, a DS1307 clock and a servo
  10. Pingback: Self-regulating water heater - Hack a Day
  11. Ash · February 23, 2011

    I’d also be curious about the actual energy savings. In addition, you may also want to add some data logging and record the temperature of the tank over time. While rare, there are some diseases the are more likely to occur if the hot water tank doesn’t maintain an appropriate temperature. Legionnaires’ disease specifically comes to mind.

  12. tesla · February 23, 2011

    I’m coming over from HackADay, I wanted to make an important comment made there: If your water is dropping below 114* F, you’re creating an ideal environment in which to grow Legionellosis. Danger, serious business!

    • Fabien Royer · February 23, 2011

      Hi tesla,

      Thanks for the warning 🙂 When the heater is on hot setting, it reaches ~130 degrees Fahrenheit and it stays there for long enough to kill that bacteria should it develop. This bacteria is a real concern in cooling systems though.


      • Denis · February 23, 2011

        How long does it take your water heater to get to its top temperature?

      • Fabien Royer · February 23, 2011

        It depends on the temperature in the garage, where the water heater was installed. With the cold weather, it takes over an hour.

  13. Pingback: Self-regulating water heater | Boomeroo Web Resources
  14. Mr. Chubbins · February 23, 2011

    Nice work, but you need to take a look at the thermostat and figure out if it is rated for 4 operations a day for the average of 10 years the heaters last. I am fairly sure the thermostats are not designed for that type of use. You don’t want that thing to fail and leak.

    • Fabien Royer · February 23, 2011

      Thanks. That’s good to know and I’ll look into it.


  15. Scott · February 24, 2011

    This is a great build, but as others have mentioned I’d be concerned about cycling the adjustment so often that the valve failed. On thing to look into might be to put a solenoid gas valve in line with the main burner line (NOT the pilot light) so that the main burners wouldn’t light unless “authorized” by the intervening netduino.

    The fail-safe version of this would be the reverse – have a normally-open valve that closes via the netduino to save energy, so that in a power-loss situation you’d have hot water.

  16. Pingback: Remote control for a gas water heater - EcoRenovator
  17. Dave · March 3, 2011

    I mentioned this to my girlfriend (before reading the comments) and her first thought was the Legionellosis as well. Do you turn the heat off completely during off hours? If so, according to the wiki article the other fellow mentioned, it takes 5 hours to kill the bacteria at 130 degrees — can you set yours to 151 or higher (to kill them by the time you are home)?

    A very interesting project — thanks for sharing!

    • Fabien Royer · March 3, 2011

      Hi Dave,

      The water temperature is lowered but never totally off, so it does not take that long for the temperature to go back up to ~140 degrees.
      Also, the period of time during which the heat is fully ON is long enough to kill any potential bacteria.
      Finally, the risk of such bacterial development is low in a water heater and is more of a concern in cooling systems.


  18. Pingback: Windows Client Developer Roundup 062 for 3/7/2011 - Pete Brown's
  19. Marco · May 9, 2011

    Very good project!! Tnx for sharing.

  20. Pingback: Saving energy with a netduino – results « Fabien's Bit Bucket
  21. P Deneys · July 31, 2011

    Your Simple Wiring Diagram is illegible to me – are you able to publish a larger diagram, this would be greatly appreciated, thanks.

    • Fabien Royer · July 31, 2011

      If you click on the diagram, you will get a larger view which should be legible.


  22. bobb · September 2, 2011

    So… after six months, what’s the verdict? Saving$???

  23. anvaralizadeh · April 15, 2012

    hi fabian,
    great idea. i have been searching for a timer automation system like this. i am new to duino technology. can an arduino be used instead of netduino-mini? if so will your code work on arduino. googled but couldn’t find what is the difference between arduino and netduino-mini. apart from the size, is it the programming language?

    • Fabien Royer · April 15, 2012

      Hi Anvar,

      These a great questions.
      To understand the differences and similarities between the two systems, check out and
      The two platforms aren’t interchangeable as far as code compatibility goes but it’s generally possible to adapt one to the other with some effort. You will need to be familiar with C/C++ on the Arduino and C# or VB.Net on the Netduino.

      Hope this helps.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s