16 buttons, 8 wires - Home Automation

Hello everyone

I've been playing around with Arduino for a little while and tought it would be perfect to implement in my new home as a home automation project.
I've changed all the light switches to Cat5 cables and wired everything to my arduino box (lighting, windows shutters, LED strips,...).
Now where the light switches were I made a few panels that contain 8 to 16 momentary toggle switches, the problem is that I only have a Cat5 cable (8 wires) going to the buttons.
Do you guys know any way to easly hook the buttons up to arduino with only those 8 wires? The Arduino is centralised and the distance between switches is maximum 15 meters.

I've read about the resistor method, shift registers, charlieplexing, multiplexing, ...
But with all the different ways of handeling my problem I don't have any idea anymore on what the best solution is.
For example, can a shift register be built in with my switches and still function fine after a 15 meter distance to the Arduino? Or do will there be to much noise on the signal?

Thanks in advance for the advice!

can we assume you have a single gang wall box for the switches ?

look up RS485. it offers you a way to connect both master and slave into the same bus.

Hi,

I think the question is how many Arduino inputs/outputs can you spare for the switches? If you can only spare 2 or 3 then shift registers or i2c input/output expanders are needed. If you can spare 5, then charlieplexing is a possibility. If you can spare 8 then regular multiplexing is probably the easiest.

Paul

Animeonmymind:
I've changed all the light switches to Cat5 cables and wired everything to my arduino box (lighting, windows shutters, LED strips,...).

You have a large box of relays to control lights and appliances?

You have an electrician's licence, or is it not required in your country?

Animeonmymind:
Now where the light switches were I made a few panels that contain 8 to 16 momentary toggle switches, the problem is that I only have a Cat5 cable (8 wires) going to the buttons.
Do you guys know any way to easily hook the buttons up to Arduino with only those 8 wires? The Arduino is centralised and the distance between switches is maximum 15 meters.

Actually, you only need about five wires to each position, and you can chain them.

Animeonmymind:
I've read about the resistor method, shift registers, Charlieplexing, multiplexing, ...

Only shift registers are really relevant here. The "trick" is to use buffers (74HC14) to drive the three lines (clock, strobe, data) in and out at each point, and to clock them in a well-orchestrated sequence, relatively slowly (about 1200 bits per second).

You can either chain the positions, or have them in a "star" with your central point. Two of the three control lines are common outputs to all positions, one data line coming back from each.

My system on the other hand, will involve a Pro Mini at each position. At $2.50 each, it is cheap enough.

dave-in-nj:
can we assume you have a single gang wall box for the switches ?

look up RS485. it offers you a way to connect both master and slave into the same bus.

Every wall box has a panel with 8 - 16 switches, all the wall boxes have their own Cat5 cable going straight to the arduino box.

Switch panel 1 ---- Cat5 ----------- |
Switch panel 2 ---- Cat5 ----Arduino----Cat 5----Switch panel 4
Switch panel 3 ---- Cat 5 ---------- |
etc...

Paul__B:

Animeonmymind:
I've changed all the light switches to Cat5 cables and wired everything to my arduino box (lighting, windows shutters, LED strips,...).

You have a large box of relays to control lights and appliances?

You have an electrician's licence, or is it not required in your country?

Yes I have 32 5V relays to switch 230V and 10A max.

I have a license, although it's not required here.

Paul__B:

Animeonmymind:
Now where the light switches were I made a few panels that contain 8 to 16 momentary toggle switches, the problem is that I only have a Cat5 cable (8 wires) going to the buttons.
Do you guys know any way to easily hook the buttons up to Arduino with only those 8 wires? The Arduino is centralised and the distance between switches is maximum 15 meters.

Actually, you only need about five wires to each position, and you can chain them.

So 5 wires to the 8 - 16 switches is enough to detect which switch is being pressed? What happens if you press 2 buttons simultaneously?

Paul__B:

Animeonmymind:
I've read about the resistor method, shift registers, Charlieplexing, multiplexing, ...

Only shift registers are really relevant here. The "trick" is to use buffers (74HC14) to drive the three lines (clock, strobe, data) in and out at each point, and to clock them in a well-orchestrated sequence, relatively slowly (about 1200 bits per second).

You can either chain the positions, or have them in a "star" with your central point. Two of the three control lines are common outputs to all positions, one data line coming back from each.

My system on the other hand, will involve a Pro Mini at each position. At $2.50 each, it is cheap enough.

So if I am understanding this correctly, I can use a shift register (in my wall boxes or arduino box) that have a 74HC14 chip connected to the switches and one to the arduino to amplify the signal?

Switch panel 1 --- 74HC14 --- Cat 5 --- 74HC14 --- Arduino?

Just out of curiosity, how would you make the Pro Mini talk to the main board? I looked up the price and Sparkfun is carrying them for around 9,95$.

Thanks for all the tips and advice! I hope I can come to a simple solution to solve this problem, I've even begun to consider to hookup two cat5 cable to the switch boxes so I can give each switch a separate wire going straight to the Arduino.

Animeonmymind:
I have a license, although it's not required here.

Fair enough.

Animeonmymind:
So 5 wires to the 8 - 16 switches is enough to detect which switch is being pressed? What happens if you press 2 buttons simultaneously?

This is not multiplexing, this is shift registers. Each and every switch separately corresponds to one bit in the shift register, when you clock (send a clock pulse to) the shift register, it moves the state of the bits along one step and they appear one by one at the output. You then "chain" them so that the output of one register is fed into the next one and so on. If you have eight such "stations" of 8 switches in a chain, then by clocking, you read all 256 switches one after the other, and similarly for whatever other combinations you want. The Arduino uses only three pins, a "latch" output to cause all the switch positions to be loaded into the shift registers, a "clock" pulse output to cause each shift by one bit at a time, and a data input to receive the bits, one by one.

Animeonmymind:
So if I am understanding this correctly, I can use a shift register (in my wall boxes or Arduino box) that have a 74HC14 chip connected to the switches and one to the Arduino to amplify the signal?

Switch panel 1 --- 74HC14 --- Cat 5 --- 74HC14 --- Arduino?

Well, the shift register goes between the actual switches and the gates in the 74HC14 which is simply to "clean up" at each end the signals going along the Cat 5, but that's pretty much how it is. Of course the gates in the 74HC14 are inverters, but with one at each end of the wire, the signal is inverted twice and ends up the right way up.

Note that if you really want robust (and faster) communication, instead of the 74HC14, you use RS-485 driver (and receiver) chips to send each signal to a pair of wires in the Cat 5; for three signals you would use three such pairs plus the fourth pair for power.

Animeonmymind:
Just out of curiosity, how would you make the Pro Mini talk to the main board? I looked up the price and Sparkfun is carrying them for around 9,95$.

Well, the eBay suppliers are a quarter of that price, tricky to figure out whether the quality differs.

That is where the real RS-485 comes in, if you have an actual MCU at each location, it encodes the switch combinations into a "packet" which is sent serially down a single channel (two wires). This means that all the stations are connected to the same two wire bus, and use a packet sending protocol (like the Internet) which includes such features as checking that the data received was that which was sent, making sure that it was received at all, handling "collisions" where two stations attempt to send data at the exact same time and so on.

There are three basic solutions or approaches to this multi-station problem. The packet network using a single communication channel is one; a "chain" as previously described where each station passes data on to the next which simply passes it on until it reaches the central station, is another and the third is what you originally envisaged, each station connects to the central one which then has to have a lot of connections to handle them.

Before you go to all the complexity and expense of Pro Minis, shift registers and buffer chips, why not just see if you can charlieplex the switches over a 15m length of cat5 cable, or even longer? If it works, you can connect up to 56 switches with 8 wires. No extra chips, just a diode for each switch, and you can individually detect any number of simultaneous presses. You can daisy-chain groups of switches on the same cat5 cable, although as the cable gets longer eventually you will run into problems, but you may find you will be able to get away with very long lengths indeed, especially if the cable is shielded and you use some strong pull-up resistors.

Paul

To tell the truth, I deliberately ignored Charlieplexing.

Apart from the trivial requirement for a diode on every switch, my concern would be that either you use a separate five wires to each switch position which means a lot of port pins for ten or so switch positions, or to obtain that 56 switches with 8 wires, you are connecting the same eight port pins, to every Cat 5 cable in parallel and thus loading the port pins heavily, to say nothing of concerns about transients and interference.

Buffering (and isolation of the Arduino from long antenna wiring) becomes difficult with Charlieplexing (though I can think of a way to do it, now that I put my mind to it). 74HC165 and 74HC14 are very cheap.

I think all the talk about multiplexing and shift registers may have gotten me confused, but if your concern is the number of wires to each 16 button station, why not use a simple matrix keypad library and treat all 16 buttons as one keypad?

It would allow exactly 16 buttons for each 8 wire cable (four columns/ four rows) and your distances should work. 16 buttons would use 8 pins on the MC, though. Hope that's not too many.

Of course, this would probably prevent you from using multiple buttons simultaneously (although it doesn't have to if you choose the correct library), but it would present you with the opportunity to use multiple buttons in sequence. This would make your 16 buttons able to control MANY more relays.

Just a thought.

Oh! One other thing. If there is any overlap in the functionality from one 16 switch panel to the next, you could also wire them up so they shared the pins already in use. For example, if two 16 switch panels controlled the same 16 relays, you could wire all 32 buttons with only 8 pins on the Arduino. :wink: