Category Archives: Home Automation

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.

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 superbrightleds.com 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.

Effects

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 sprinkler.py 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.

Conclusion

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.

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.

RGB LED

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.

Cooling

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:

blelight_revB

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!

Power

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 amazon.com, 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!

2015-02-21