Category Archives: Home Automation

powering yourself: water heaterS – Most efficient setup with no tradeoffs

In the “Rethinking the Smart home series“, I proposed that if you have a solar PV system (or any system that generates electrical power), no one uses your own produced power better than the you. To summarize the proposition, I claim that “selling back” to the grid is environmentally less ideal than using the produced power yourself. The concept needs a nickname -something I can use to expand and apply the concept later. Towards that end, I think “Powering Yourself” works. I’m open to suggestions if you can think of something more catchy. Let’s market this idea and spread it around! The more eyes and ears on the concept, the more solutions we can come up with to make distributed smart-grids a reality and ultimately make the world a more energy efficient place.

Water heater relative efficiency

Hot water is essential for our daily lives. Hot water kills many types of bacteria that can infect our bodies. It is more effective for cleaning with as it helps loosen up bonds. In US homes, hot water is typically produced in a centralized tank. This insulated tank is mostly heated by burning natural gas (CH4/methane).

Rheem Performance Platinum 50 Gal. Medium 12 Year 5500/5500-Watt Elements Mobile Alert Compatible Electric Tank Water Heater
courtesy Rheem

Tank water heaters are generally less efficient than tankless or “on-demand” water heaters. This is because the water in the tanks is maintained at a set temperature (between 49C-60C) even when you are on vacation or shower less frequently, etc. Running a tank water heater is estimated to cost about twice as much as a tankless.

Even more cheaper to run than tankless is a type of water heater called a “hybrid water heater” or “heat pump water heater”. Some of the manufacturers claim they take “energy from the air” to heat the water. This is misleading in my opinion. These are actually using the same technology as your AC unit: it uses mechanical energy to compress and decompress a phase-changing medium from liquid and gas states. The in the decompression state, the phase change from liquid to gas will actually suck thermal energy from the air to help facilitate the phase change. You can experience the same effect if you get a can of compressed air and spray it for a while. The can gets cold fast because the phase change going on inside is sucking thermal energy from the can and your hand (and the air, etc).

On the flip-side, during the compression stage, heat energy is actually released to facilitate the phase change from gas to liquid. This energy would go back into the air or in the case of the hybrid water heater: into your water. The process isn’t even zero-sum because the compressor itself gives off some heat.

Courtesy of Stiebel Eltron

Hybrid water heaters use electrical power to turn the motor in the compressor. They use less energy than traditional electric water heaters which run at sometimes run at 5kW. Further, they use drops compared to tankless electric… which can go higher than 36kW. Yikes!

Tankless comfort

Of all these different types, tankless are the most comfortable in my opinion. Tanks fill with cold water at the same time they are being drained of hot water. This results in fluctuating temperatures at the start and end of use. If you’ve ever showered right after someone else in your household, you know this reality. Tankless heaters don’t have that problem. They have constant temperature from start to finish. So if you have or want to use a tankless heater for the comfort and savings, how do we achieve this while still following the “powering yourself” principle? Tankless heaters are gas or electricity powered. Gas is a bit more difficult to power under your own means (not impossible, maybe more on that later). For electric tankless, the electrical consumption is so high that very few solar systems can keep up (36kW or more). To power ourselves, we are left with tank solutions and really only hybrids as they require less electrical power. But to go with a tank we must sacrifice all the pro’s of tankless… or do we? Can we have our cake and eat it too?

Smarter water heating

In the last article, I wrote about an automation approach that uses smart budgeting to maximize the usage of your own energy production and reduce usage of the grid. Could we add a hybrid water heater as a device to this system? Let’s calculate and see if we can power it with solar PV. We don’t need to power it all the time since the tanks are insulated and will maintain some thermal energy. At an R-value of 20, a 50 gallon tank of 60C will cool by about 3C over 9 hours assuming a surrounding temperature of 8C.

A 50 gallon hybrid water heater stores 183 l (or 183 kg) of water. Worst case for my area, the temperature of the water will be 9C. We need to heat that up to a minimum of 49C (to meet government standards) or 60C (most manufacturer defaults). Using 60C as the worst-case target, we need to put in 40.3 MegaJoules of energy into the water to heat it up from 9C to 60C (Q = mC△T). No heater supplies that amount of power all at once, so lets divide that energy requirement over time. To get kWh we divide by 3600 (number of seconds on 1 hr). We get 11.2kWh. That’s pretty reasonable production rates for even a small solar system. With my 3kW system, I can average 11kWh a day for 8 out of 12 months or 2/3rds of the year. With a 6kW system, you can do 11 of 12 months.

We can almost power our water heating needs under the Powering Yourself concept! To cover the last little bit, we could put a tankless heater in-line after the tank water heater. The tankless water heater would only be active if the incoming water is below the setpoint. We can get the benefits of Powering Yourself and tankless comfort!

Copyright 2018

Cost savings of the Hybrid Approach

In the above diagram, we are using a fairly large tankless heater. Heaters at this price range can do 9 or more gallons per minute of hot water. For reference, a typical US shower head is 2.1 gallons per minute. This is probably overkill for what is actually needed in most situations. Even the cheapest 5 gpm tankless option will be better in the worst-case scenario than just having a tank.

For the 9gpm tankless, the time to payoff with the savings is about 9 years with a 3kW solar PV system. It’s about 7 years with a 6kW system. With a 5gpm tankless heater, you are looking at 3-4 years.

This payoff period is only for the added cost of the tankless heater in this setup. It is assumed that this is either a new install or you are replacing the existing hot water tank with a hybrid. Hybrids save about $100/year over traditional gas tank heaters. The payoff for the hybrid upgrade over traditional is around 5-8 years.


First, there is no point in even trying this if you do not have your hybrid tank optimized for solar with some sort of home automation software. It needs to essentially turn off if there is no solar power being generated. Wifi enabled versions allow setting the temperature setpoint remotely. There’s even an open source python API for talking to some Rheem models. If the hybrid heater has this capability, we don’t have to turn it off. we can just turn the set-point down appropriately to stop it from running… or run less. Another option is a wifi relay outlet like those supplied by Wemo or TP-Link Kasa. Be careful! Many of these only support 15 or 20A loads and some hybrid water heaters require a 30A outlet.

If you are able to automate the hybrid tank to only (or mostly) use solar generated power, you should save money (up to $100/year in some cases). Adding a tankless heater in-line will add the comfort, and will pay for itself eventually.

What other devices can we bring under the “Power Yourself” umbrella? If you have any ideas, leave a comment below or tweet me. Good luck and happy powering!


In Part 1 of the Rethinking the Smart Home series, we looked at how we can using batteries to offset the electrical usage of certain devices.  We did not discuss how and when that battery system is charged.  We will do that now.

Batteries are just devices

There are a lot of “devices” in our homes.  Devices are things that use power.  This includes lights, displays, HVAC systems, and even battery chargers.  Over the last few years, the market has flooded with relatively inexpensive smart light bulbs, switches and outlets.  Many of these offer power and energy consumption monitoring.  Many of them have APIs either provided by the manufacturer or reverse engineered by the community that can be used to communicate with these devices.  I decided that I could use one of the smart outlets I have to control when the battery system charges.  Obeying the Law of Using Your Own Generated Power, I will only charge the batteries when there is enough solar power available.  I realized quickly that there are many devices I have in my house that I can turn on and off in this way.  I have several grow lights for indoor food plants that are already connected to Ubiquity mFi WiFi outlets.  I have them on a schedule, but I was interested to see how much I could save if I only had them run when there was enough available solar power. 

The use-cases after that kept growing.  What if I tell my smart light switches to dim when there isn’t enough available solar power?  What if I raised the setpoint of my thermostat by a degree if there isn’t enough solar power?  What if I only charge my robot vacuum on solar power? 

To see how much money I could save, I wrote some code to help manage the devices based on a “power budget” which was set by the output of the solar PV system.  For example, if the PV system was producing 2000 Watts of power, I would turn on “managed” devices until I either reached 2000 Watts or they were all powered.  If the solar PV output dropped to 1000W, I would need to turn off some devices.  To do this, I wrote some code I call the “Device Manager”.  The Device Manager would maintain the power budget and turn on and off devices as required.  It would also run device-specific rules (more on that later).


Some devices are more important to me to have powered than others.  For example, my phone charger is more important than the robot vacuum charger.  If the power budget is exceeded, Device Manager will first turn off the lower-priority devices.

Runtime Modes

 Many utilities offer variable rates depending on the “time of use” of your power.  For example, rates are often cheaper in the night when fewer people are using lights and appliances.  Rates can also be more expensive during “peak usage” when the grid is experiencing more load for example, at noon on a hot summer day when everyone’s air conditioning is running.

The Device Manager should be smart enough to take these time of use modes into account.  If I go over my local power budget, I may want some devices to remain running if it’s during off-peak hours of the day.

A perfect example of this is my greenhouse preemptive cooling system.  I run this system at night during off-peak hours for the cheapest rates.  It also runs more efficiently at night because it’s cooler.  Double-bonus.

Rules Engine

Turning on/off devices is powerful enough for many devices.  But what about devices you don’t necessarily want completely off?  For example, I need lights at night to see.  I can’t just have them turn off if there isn’t enough power.  I can have them dim, however.  There are lots of use cases from dimming lights to adjusting thermostat settings that calls for a rules engine.  I have written rules to turn off devices, or dim lights or even check occupancy.  Devices can have many different rules so rules can be combined in interesting ways.  My lights have occupancy rules and dimming rules.  I even have a rule that “links” devices to a master devices so that the on/off state mirrors the master device.

Batteries as a buffer

In the first part of this series, I built a battery system to help optimize when I charge my laptop and other devices.  That system really cannot work to peak efficiency without the Device Manager managing when the batteries charge.  I charge the battery banks when I am under budget with medium priority.  I found this works best for my usage.  I am able to charge all phones in the house and my laptop from this simple battery system.  While it doesn’t amount to huge savings (only $5/year), it does make a good proof of concept that we can use to power additional devices later.

In practice

With the system running and managing about 8 devices ranging from grow lights, to chargers to the thermostat, we observed considerable savings.  Our power usage is about 30-50% less year over year.  That’s much more than Not all of that can be attributed to the Device Manager system, but a lot of it can.  Most of the savings is probably in the thermostat automation, but the light management probably helps a lot.  I believe it also helps us get to sleep faster since the lights are not so bright at night.

In the next part, we will look at how using AI and machine learning makes this system even better.


LED Stair Lights

Stairs are pretty boring, but they don’t have to be.  I convinced my loving wife that she needed stair lights.  I put the project off for over 6 months while I’ve been greenhousing, but now that that project is more completed, I have time to get back to house projects.  Let’s get building.


First, we will use the APA102 lights.  These are individually controllable.  They are the same lights we’ve used in our ambilight project with the minnowboard max.

I came up with a simple light protocol that supports “instructions” rather than just raw pixel data so it’s fast and light.  I’ve published the library here on github (be sure to use it with my forked Adafruit_dotstar library which has the “driver” for the LightProtocol).  I loaded that onto a particle photon, combined with an level shifter, and powered the thing with a Drok DC-DC power supply and a 24V 5A AC-DC adapter.

To install the LED strips on the stairs, I picked up several aluminum channels from and the corresponding “frosted” covers.  To stick the channels on the stairs, I used 3M automotive double-sided tape.  The aluminum can be drilled and screws can be used to mount, but I didn’t do that.  I used a simple dremel to cut the channels where I needed to.

I’m hiding the photon and the power supply in the closet which is adjacent to the stairs.  I cut a small hole in the wall on the closet side and put a 4 wire, 14AWG cable through the wall.  This is low-voltage (5V), so you don’t need an electrician or a expensive permit to install inside the wall… at least in my area.  On the other side, I combined a 2 socket “keystone” faceplate with a couple two wire speaker jacks.  This doesn’t look half bad.


Using the same python library as the minnowboard max ambilight project, and adding a “driver” that can speak our “LightProtocol” that we’ve installed on the particle photon, we are able to to complex effects and themes on the desktop and change the lights over wifi.

I have three effects coded up: “Chase”, “Random Rainbow Transforms”, and “Rainbow”.  Check out the video for how these effects look on our lights.  What other cool effects can we do?


Intel Edison + Koyo Sprinkler Controller

AKA: How to build a smart sprinkler controller in less than 100 lines of code

Sound impossible?  It isn’t.  Here’s how I did it but before we start, lets define what we mean by “smart”.  “Smart”, in a sprinkler context (yes, this will be highly subjective), to me means it waters my lawn and other things that need watering at just the right amounts at just the right time.

It must be green.  If it rains, it can’t water unnecessarily.  So it has to be able to understand the weather.  It also cannot water more than my lawn or other plant needs.  This means that it has to know what I’m watering and how much water it needs.  With those features in mind, lets begin.

First, the brains of the operation: The Intel Edison.  The Edison is a powerful and small unit with built in wifi and bluetooth.  That means it’s really easy for it to connect to both other devices and to the cloud.

The wifi feature will help us get weather data from the cloud and also evapotraspiration data (ET say whut?  More on this later).  The Edison also has USB, which we will need later on.

The Second piece of hardware we will use is the “Koyo”.  It’s a PLC.  My brother had an extra one that he was willing to donate.  I understand you can do the same thing with the Edison and a relay array, but if you have a PLC, why not use it, right?

The koyo uses UDP for control.  My brother wrote a python library to interface with the unit.  It’s pretty easy to use, the readme that comes with the library will help you find the koyo on the network and change its IP address.  The library also allows us to toggle the koyo’s relays.  The koyo python library requires a connection to the koyo.  If you can plug the koyo into your network via ethernet, awesome.  If not, you need to use something to bridge to the koyo over wifi.  The Edison has wifi, so we are good there.  But it doesn’t have ethernet.  This is where USB comes in.

I picked up a usb to ethernet adapter on digikey.  Using the Edison breakout board and a USB OTG to USB female I now have working ethernet -well almost.  Connman, the network manager, which comes installed on the Edison was a bit of trouble here.

Once we have a connection set up, we need some data from the Internet so we can make the system smart.  There are two sources we will use for data.  Weather Underground and Agrimet.  Whether Underground can tell us if it has rained and Agrimet will tell us how much to water.

Agrimet has a table that contains the evapotranspiration data for several crop types including “lawn”.  Evapotransperation (ET) is how much transpiration and evaporation of water has occurred during the day.  This number takes several variables into account including precipitation, solar irradiation, wind, and several other variables.  For more on ET and how it is calculated checkout the Wikipedia page.  Many local weather stations calculate ET for different crop types and Agrimet aggregates that data. Agrimet organizes the data per station so  we will need to find you nearest weather station to our location.  You can find your station on a map here.  Remember the station id. We will need it later.

Once you have the weather station id nearest your area, we can get an ET data table for that station.  The URL to get the table is this:

Replace {stationID} with your station and open the URL in a browser and you should see the data table.  To parse the data I used this script:

To use this class do the following:

“cropName” can be any crop that you see in the chart.  Since we are watering grass, I will use “LAWN” for my crop.  The next thing we want to do is see if it’s rained today.  Since our forecast was predicted using yesterdays numbers, if it rained today, it will not have factored in.  So we will just subtract the amount of precipitation if any from our forecast.  I use weather underground to get the current weather conditions.  Here’s my that combines the Et with weather data and turns on/off my sprinkler zones.


The zones are defined in a json file:

I got the rate for each zone by putting a cup and running the sprinkler for 10 mins then dividing by 10 to give me how much water my system produces per minute.  Type is LAWN, but it could be any crop.  No I’m not using this variable in my code.

The last thing to do is set it up on a schedule.  To do that, check out my video.


I’m almost completely happy with this setup after a few weeks of operation.  I love being able to ssh into the sprinkler and turn it on and off -even from my android phone.

Bluetooth Low Energy LED – Part 1: Hardware

LEDs should be taking the world by storm.  They are so far the most power efficient lighting source available.  Because they are more power efficient, they can save you money.

There are many smart LED lights out there.  The Philipps “Hue” is one where Philips has opened up their API (to registered developers).  This allows people to write custom software to take more control over their lighting.

However, there are concerns.  The Hue is a connected device.  It is on the Internet which brings in security concerns.  Aside from the security concern, maybe you want to just do your own lights?  Perhaps you just want to learn and discover how such systems work?  Maybe you have a killer feature in mind that isn’t supported by the other lights?  For all of these reasons, I have undergone an attempt to create my own Bluetooth Low Energy Smart LED.

DC Power and Solar possibilities

LEDs are DC powered.  Meaning, in order to use them in your AC-powered home, you need a AC-DC converter.  The AC-DC conversion may not itself be inefficient relative to a DC-DC stepdown converter, however, if your power comes from solar, which is also DC, it adds inefficiencies to go from DC to AC and back to DC.

If you have a solar setup, which someday I hope to have, you may want to try to convert your home lighting system to DC powered, in which case, off-the-shelf smart LEDs won’t work because they have built-in AC-DC converters.

Bluetooth Low Energy

Bluetooth Low Energy (BLE) is a new protocol incorporated into the Bluetooth 4.0 standard for low energy consumption.  It doesn’t have the speed that classic bluetooth has, but it allows for a lot lower power usage.  It’s range is also limited, but for a small house, it’s probably tolerable.  Other smart LEDs use bluetooth low energy.  Some use Zigbee, another low-power wireless technology.

I use BLE in some of my other projects, so it made sense to use it here as well.

One cool device that supports BLE is the RFDuino.


This device combines the programming interface of an arduino with a chip that supports BLE.  It’s API is pretty flexible allowing you to customize the UUID’s, device name and even change the transmit power the radio uses.  Best of all, in ultra low power mode it only consumes 4uA.


There are lots of LEDs to choose from.  I went with a 10W RGB LED that I found on Amazon.


10W is bright, but not too bright.  With this hardware guide, it’s also possible to use a 20W.  If you go bigger, you’ll need to find different cooling than what I talk about here.  You can also use a plain white LED of 10W or 20W.  You’ll have to calculate the resistor values yourself, but there’s help here.


LEDs can get hot.  So cooling is necessary.  I went with the passive cooling route and picked up 5 of these on amazon for pretty cheap:

They have mounting holes for 10W or 20W LEDs and come with the screws and thermal paste.

The Circuit

We want to be able to adjust the brightness on all three color channels.  To do this, we need 3 n-channel MOSFETs and some resistors.  Here’s my circuit diagram:


LEDs 1-3 represent the Red Green and Blue channels.  If you have only a single white LED, you don’t need to worry about LEDs 2 and 3 or the MOSFETs.  This circuit diagram uses the RFDuino SMD module instead of the DIP.  If you are using the DIP, you won’t need the USB programmer connections.

NOTE: All the code including the RFDuino code, android app and circuit diagrams are all open source.  I will provide links in part 2 of this guide.

NOTE 2: I’m not an electronic engineer.  I’m learning this stuff as I go and sharing what I learn.  Please feel free to correct me, my designs or even better, submit a patch!


For power I use a 12V DC power supply at 3.0A.  The LED takes 12V and the RFDuino uses 3.3V.  To supply the 3.3V for the RFDuino, I use a mini buck converter that takes 12V and converts it down to 3.3V.

The Bulb

How do we house all this hardware?  Well, I designed a “bulb” using a website called “tinkercad“.  Using this website you can design simple 3D models that you can print either using online services, or with your own printer (or in my case, a friend’s printer).

The case is round so that the round heatsink fits perfectly inside it.  I printed the case using clear resin.  My first bulb did not have holes in it to breath.  So it got kinda hot inside.  This latest revision has holes to breath.  Last but not least, it has a hole at the bottom for power input (sized to fit a standard socket adapter) and a lid that fits snugly at the top.

You can copy the design I made here.

For the power socket, I ordered these on amazon:

I used clear epoxy to cement the sockets in place.

WARNING: One flaw in this design, is that it uses a standard socket, but if you plug this LED into a standard socket, bad things could happen.  The LED expects DC current.  I modified a lamp to provide DC which I cover later in this guide.

After putting everything in the bulb, I was pretty happy with the results:
2015-02-22 (1) 2015-02-22

DC Powered Lamp

As noted above, I modified a lamp input to accept DC.  This was pretty easy.  I snagged an DC Barrel adapter from, cut some wires, attached the adapter and done!

In part 2, I’ll go over the software to get this up and running including an Android App, Linux “LED” Server and the RFDuino code.  Stay tuned!