Push buttons as input

Tags: , , , ,
Add comments

imageTo control the lights in a house or in my own apartment switches and buttons near the doors in the wall are a very useful thing.

Even if my home automation can be controlled by ethernet, mobile phone, timers, you name it, it will be most convenient to use normal switches, too. I was lucky to rewire the whole apartment and I decided to  put a separate wire for each switch to a central place where my home automation controller will be placed.

I will use push buttons instead of on/off-switches. Push buttons can be used for multiple commands. Starting with turning a light on or off, you can program it to do different actions when pressing just for a short or a longer time. Or you can do a continues action as long as the button is pressed down.

But first of all the signal from the buttons needs to be received by my micro controller. I will use 12V DC for all buttons, to avoid higher power like 110V or 220V AC. To protect the electronics and don’t get trouble with long wires at all I use optocouplers. Basically the 12V from the push button just turns on a small LED within the optocoupler from where the signal takes its way.

The schematics

The signals itself are received by a PCF8574 I/O-chip. This chip comes with 8 digital I/O ports and an I2C interface. The microcontroller can query the state of all I/O ports using the I2C interface. As a bonus the chip triggers an interrupt each time any input signal is changed.


There is nothing fancy at the schematics, just read it from right to left. At the very right you will find 8 inputs for the 12 V from my pushbuttons (and the GND used with this signal). Following by the optocouplers. To use more or less then 12 V just adjust the resistors value. The rest of the schemantics are just pull up and down resistors and some more connectors for the I2C bus.
The board will be build in a way to chain multiple of this boards together. The I2C bus goes from one to another.
By using the solder jumpers SJ1, SJ2, SJ3 you can select one out of eight addresses. Each board comes with its own interrupt on connector JP2.

The board

As above you can find the connectors to the push buttons on the right. You will see the two quad optocoupler chips in the middle and the I2C I/O chip at the left.


I have four of this boards connected with nearly 32 push buttons. They all share the I2C bus which is connected from one to another (see the small white, red, green and yellow wires at the bottom). But each provides its own interrupt signal. So for the whole installation the microcontroller only needs four IRQ ports and one I2C bus.


The code

Will be the topic of my next post. Stay tuned.

What is this all about

If you find this post interesting, have a look at the other posts in my homeautomation category within this blog. Especially the first and the second post describe what this is all about.

The schematics and boards (created with EAGLE) and all source code is or will be available on github: https://github.com/irgendwienet/homeautomation

Comments are closed.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in