HA Architecture

hey guys, could you help me with this?

In a simple example, we have this house. It has only one room: inside it, it has four switches (in each wall) for two lights.
How do you work the architecture of the HA system in this room?
You can use one microcontroller for each switch and light/appliance, but it would cost too much. Alternatively, you could wire everything towards a single microcontroller, positioned in a convenient location. Nobody likes wires though.

What to do in this case? I know that this is a general example, and for each situation a different approach would be used - but anywhow I need some directions on how to start.

For my HA system I'm going to use some Spark Cores. I'm trying to use powerline communications (different implementation of x10 - diy) as a solution, but it seems it is just full of noises and no one recommends.

can XBEE be a solution?

The switches send their state to a central node which can make the lights go on/off.

loop()
{
state = 0;
if any switch touched state = state + 1;
if state = 4 state = 0;

if state == 0 (switch off all lights)
if state == 1 (light 1 = on, 2 = 0ff)
if state == 2 (light 1 = off, 2 = on)
if state == 3 (light 1 = on, 2 = on)
}

I have no real problem with the comm between appliances, I just wanted to know how modded your house would get by implementing. Assuming I can interface them with each other and the central core,
how would the wiring be done? I’d like to have a uC attached to each light switch so I can feedback states. Did you understand me well?

There are as many solutions to this problem as there are people doing it. In my case, I would put a radio controlled switch at each location. Many of these report the status of the switch and some of them report the power usage. Being me, I would chose something with XBee or ZigBee mesh networking so I could expand it later.

Since you have two lights and four switches, you probably have two, two way switches for each light; one to turn it on as you come in and one on the other side as you go out (so you don’t have to go back). That would mean a SPDT relay to handle the various possibilities on one of the switches. Or, you can make one of the switches actually control the lights and the other switch just send a signal to the first switch to command it.

You could bite the bullet and wire the lights to a central controller and make all the switches radios that tell the controller which light to turn on. This is the most versatile method since you can reprogram the system to do anything you want

What everyone tells you about powerline controls is absolutely correct. You have to have a really quiet electrical system to make that work reliably and every motor, computer, switching power supply in the house will work to mess you up. Those were OK forty years ago, but they don’t work worth a darn today, unless you have massive capability for retries and control packet integrity.

Everyone thinks hard wired is the way to go. Someday you’ll want something where there are no wires. What happens when you forget and drive a nail through one of them? The wire gets eaten by ravenous bats that decided to populate your attic? Sure, radios die, but they’re simple to replace; wires are tougher.

If you want to go Wifi, there are a couple of switches that use UPnP over ethernet to announce their presence and allow you to control them. If you want to go ZigBee the choices are limited, but they exist. Z-wave switches are abundant, but the controllers are all proprietary (unless you want to go to a Raspberry Pi). Xbees running a simple text protocol are cheap, but you have to build your own stuff. Perhaps hook a relay to an XBee digital pin and put the entire thing in a wiring box next to the light; you could hook a switch to a digital pin to replace the wall switch. Then put the controller (an arduino) on a shelf somewhere.

But, you say, "the radio is much cheaper and works really well. That’s true, but what happens when you expand the system and the next radio just can’t make the hop from the wall of the garage through two interior walls to the shelf where you put the arduino? With XBees, this is simple, put a repeater in between them. With other radios, have a nice time writing your own packet forwarding code. Z-wave and ZigBee handle this well also. Wires don’t handle it at all, you have to run a new wire.

See what I mean about possible solutions? You’ll have to consider the future of this one room house into your plans.

Thanks for the long and very enlightening reply. Do hou have any idea on how those digitalStrom bricks get so tiny?
I would consider PLC if it was this size (very easy to install), neverminding the noise. I wanted to do a proff of concept on the physical size of those RX and TX PLC modules. Needed some real life IC examples, can you guys help me?

Since I'm going to work with Spark - it has wireless internet connection -, expanding is a no-brainer. Besides, zigbees are pretty much expensive.

Totally understand why you want to use Spark Cores to communicate. But, don't use the 'expensive' excuse. Those things are U$40 each. And you don't get a relay, power supply or anything with them. It's actually cheaper to hack into a Wemo light switch (U$48) once you consider how much a power supply, enclosure, relay, relay driver, etc is going to mount up. XBees cost around U$17 in comparison and have the same kind of requirements.

See, I went with XBees so I could have clear comm from the house out to the barn. There's about 4 walls, a steel building and 60-70 yards of distance to deal with. WiFi just won't hack it. One XBee radio relay in the middle does the job just fine.

Don't misunderstand though, I plan on someday getting one or two of the spark cores to play with because they are just so dog gone cool. Gotta wait til the taxes are paid though, I may not be able to afford it.

I'm putting them up myself, so it's cheaper $40 -> $25 (less if CC3000 is the free sample version from TI)

Oh, they are that cheap? Where do you get them?
You need lots of modules/shields (and money) to put up a zigbee powered system online.
Arduino + Xbee Shield + Xbee, isnt it?
It's like you buy your own router to make them comm on it.
Or I'm doing it the wrong way? Is there another way to comm over zigbee that doesnt use arduino?

The Spark core is a arduino with the price of a arduino, but with internet connection. Plus you can get to program it remotely, no additional setup.
With a wifi connection, I can use the previously existing wifi router.

Anyway. Sorry to sing too much of it's praises but it's just that I really like the Spark Core.

And regardless of the noise I wanted to DIY power line communications, do you have any hints, tips, tricks?

I honestly don't think wifi is anywhere near reliable enough for home automation, particularly when you are reliant on an access point in order to connect everything. I've never seen a consumer-grade AP that didn't crash once a month and I would be really pissed if that crash prevented me from turning my lights on, especially if the wifi router is in a dark basement!

You've got a good description above of the typical wireless architecture (nodes in switches, nodes in lights, talking as a mesh over a reliable protocol like zigbee) but there's one thing missing: power is not wireless. I would be extremely unhappy about having to change batteries in my light switches too. Or if you run mains to each light switch, you suddenly have a house full of inefficient little wall-wart-scale power supplies and radio transceivers which are continuously sucking energy 24/7. With a small house fully fitted out you're looking at probably 25W of wasted power which is $90/year where I live: not really acceptable either.

The C-bus architecture is worth looking at but it's only good if you're building a house or rewiring from scratch: it runs CAT5 to every switch point, which carries power+data for all the smart switches. All those CAT5 runs go back to one big control board, which contains a DC power supply for the switches/controllers, some centralised intelligence and a big row of DIN-mount relays. There are power lines running from the central control board relays out to each individual light fitting. If you want to add a new light to your house, you need to home-run the power from that light to the control board, so adjustments to the system are also more expensive than with the traditional wiring arrangement.

Because that structure is so very different from the classic house wiring (unswitched circuit passing each light, with branches off from light fittings to their corresponding switches), C-bus refits are an expensive rip-out-and-re-do proposition.

What I'm working on at the moment is putting a tiny arduino-based PLC next to each light switch, with a relay next to it. About 10cm of DIN rail, screwed to a rafter and professionally+legally wired up to the existing fittings with mains-legal (C-tick/CE) relays. I redirect the existing switch connection to my PLC so that it can detect when someone changes the switch state, and therefore toggle the relay state at any time. The PLCs are all chained together with a multidrop serial bus (probably CAN, maybe RS-485) that carries control and DC power for the PLCs. There's also a linux single board computer hanging off the serial bus which contains all the intelligence (rules-based state changes etc) and also connects it to my home IP network, which includes wifi and therefore smartphones. The benefits of this architecture are:

  • cheap and legal retrofit without needing to add or move ANY mains wiring runs or switch runs; won't invalidate house insurance
  • reliable communications with no interference or dependence on a central device like an 802.11 AP.
  • light switches continue to work even if the whole network or HA automation goes down
  • run a single control cable in a loop around the building (in ceiling) which passes EVERY fitting, so adding new controllers later is easy
  • single efficient power supply, with opportunity for central battery backup
  • bridged to IP network at the HA controller for control via smartphone or internet
  • can integrate alarm, security and all that good stuff on the same serial bus, with the same HA controller
    Cons:
  • single PSU is single point of failure, so it'll have to be redundant (not difficult)
  • difficult to extend outside the building
  • serious cable damage will take ALL the lights down instead of just exploding one rat

Anyway, that might give you some inspiration and thoughts about legal and physical constraints that you maybe hadn't already considered.

I'm interested in your approach to automate a previously wired home. Would you mind explaining more?

...tiny arduino-based PLC next to each light switch, with a relay next to it.

PLC stands for powerline comm? Or to programmable logic controller?
Please describe this arduino module more

About 10cm of DIN rail, screwed to a rafter and professionally+legally wired up to the existing fittings with mains-legal (C-tick/CE) relays.

This DIN rail is separated from the one that already existed in your house? Since you say professionally, I'll consider you had some electrical company wire for you, right?
Also, if something is C-tick/CE ... they're like approved by a major company/government to personal/comercial use? I'm from Brazil, you see.

The PLCs are all chained together with a multidrop serial bus (probably CAN, maybe RS-485) that carries control and DC power for the PLCs. There's also a linux single board computer hanging off the serial bus

By chained together do you mean tons of cables? How are you handling cable mess?
Can you help me making a multidrop serial bus? Really interested in your ideas

gcats:
PLC stands for powerline comm? Or to programmable logic controller?
Please describe this arduino module more

Programmable Logic Controller. Basically just a little plastic box with some inputs (to observe the hardware switch state), some 24V outputs (to trigger the relays) and a communication connection (to receive remote/automation commands). Really basic stuff for an arduino. Optionally with some intelligence in the arduino for things like slaving one channel from another, introducing delays, etc - something that can allow you to customise the behaviour of each controller without needing to burn a different arduino sketch into them all. If you're feeling really fancy, a means of downloading new firmware to the controller over the bus, so that you can update your devices without needing to go into the roof; that requires a custom bootloader though.

gcats:

About 10cm of DIN rail, screwed to a rafter and professionally+legally wired up to the existing fittings with mains-legal (C-tick/CE) relays.

This DIN rail is separated from the one that already existed in your house? Since you say professionally, I'll consider you had some electrical company wire for you, right?
Also, if something is C-tick/CE ... they're like approved by a major company/government to personal/comercial use? I'm from Brazil, you see.

Yes. DIN rail is just a mechanical thing and not fundamental to the HA, but it is a widespread, legal and recognisable way of mounting mains electrical control things. Typically there will be a rail in your distribution box, and the circuit breakers/switches/etc will be mounted on it. I'm talking about adding a very short piece of rail in the ceiling space next to each light fitting, just as a neat means of holding the PLC and relay. You can buy off the shelf DIN mount boxes (to hold the PLC), and approved DIN mount relays.

C-tick is the Australian EMI standards process/marking. CE is the European equivalent. They are both expensive ($10k-$50k) to achieve, and are a legal requirement if you want to legally connect something to mains power and not invalidate your household insurance. Hence my plan to use pre-existing approved relays which will isolate my custom (unapproved) PLC from the mains power, keeping the whole setup legal. A licensed electrician will be responsible for plugging the mains wires into the relay and can therefore provide a certificate of conformance.

gcats:

The PLCs are all chained together with a multidrop serial bus (probably CAN, maybe RS-485) that carries control and DC power for the PLCs. There's also a linux single board computer hanging off the serial bus

By chained together do you mean tons of cables? How are you handling cable mess?
Can you help me making a multidrop serial bus? Really interested in your ideas

[/quote]

Just one bus cable, running in a ring around the house and passing each light fitting and any other location where you might expect to want a HA connection (doors, windows, major appliances, HVAC, solar cells/batteries, the main distribution board, etc). 4- or 6-core, about 5mm thick, e.g. the stuff that gets used for sprinkler wiring. Each controller (light module) hangs off this wire, either with a T-piece and short stub, or by the wire passing through the controller using a plug and socket. Power supply will probably be in the main distribution box.

There are lots of resources for implementing multidrop serial. Google up RS-485, modbus, CAN bus and CANopen.

gcats:
hey guys, could you help me with this?

In a simple example, we have this house. It has only one room: inside it, it has four switches (in each wall) for two lights.
How do you work the architecture of the HA system in this room?
You can use one microcontroller for each switch and light/appliance, but it would cost too much. Alternatively, you could wire everything towards a single microcontroller, positioned in a convenient location. Nobody likes wires though.

What to do in this case? I know that this is a general example, and for each situation a different approach would be used - but anywhow I need some directions on how to start.

For my HA system I’m going to use some Spark Cores. I’m trying to use powerline communications (different implementation of x10 - diy) as a solution, but it seems it is just full of noises and no one recommends.

If you don’t want to run cables from the electrical devices to be controlled to the Arduino (or other board) and want to use cheap devices, you can use the RF Sockets and control them from a microcontroller.

The picture is more clear than words:

Here there is a simple sketch to control it using Arduino and Android, based on the Souliss library
http://code.google.com/p/souliss/wiki/ss_RCSwitch

Enjoy,
Dario.

polyglot:
You've got a good description above of the typical wireless architecture (nodes in switches, nodes in lights, talking as a mesh over a reliable protocol like zigbee) but there's one thing missing: power is not wireless. I would be extremely unhappy about having to change batteries in my light switches too. Or if you run mains to each light switch, you suddenly have a house full of inefficient little wall-wart-scale power supplies and radio transceivers which are continuously sucking energy 24/7. With a small house fully fitted out you're looking at probably 25W of wasted power which is $90/year where I live: not really acceptable either.

I fully agree, efficient and thrifty home in energy consumption

polyglot:
The PLCs are all chained together with a multidrop serial bus (probably CAN, maybe RS-485) that carries control and DC power for the PLCs. There's also a linux single board computer hanging off the serial bus which contains all the intelligence (rules-based state changes etc) and also connects it to my home IP network, which includes wifi and therefore smartphones.

I pitched the same idea on the Italian forum, and searching the web I found these components that may be interested:

the SIG60 of YAMAR (LIN network)
the CY8CPLC10 of the CYPRESS (I2C)

Remains to create the shield with filter systems and couplings

Go to work!