Go Down

Topic: Micro-switch buttons fire themselves in Arduino home automation system - Ideas? (Read 212 times) previous topic - next topic


I've setup Arduino to control part of my home automation system. I have set things up so that Arduino controls 24 VDC relays with transistors and flyback diode.  This part is working well.

I have micro-switch buttons on the walls that I've set up as Arduino inputs. Cable to buttons is 10 pair MHS (0.5 mm diameter each wire), where I've used each cable for different micro-switch / led with common ground for all buttons. Cable length varies between 5 and 15 meters.

Buttons are used with Arduino's internal pull-up resistor. Arduino is run from a wall-wart power supply 5 V / USB-with external power source, tried both. Relays are powered with separate external power supply. I'm also using button library that includes de-bouce option (github.com/JChristensen/Button).

I've had a problem that sometimes the buttons 'fire themselves' i.e. Arduino thinks that someone pushed a button. Time varies, it could take few hours between such events. As buttons are used with internal pull-up Arduino sees 5VDC until button is pushed, I reasoned that possible induction interference to the wire should not cause the error, or could it?

Do you guys have any ideas or similar experiences what might cause buttons to 'fire themselves' from Arduino's point of view?

I've tried following solutions:
1)   Run Arduino from battery > Did not help, still interference.
2)   Run Arduino from wall-wart power supply 5VDC > Did not help, still interference.
3)   Run Arduino from USB power supply 5VDC > Did not help, still interference.
4)   Grounded the wire that goes to the buttons > reduced problems a bit(?)
5)   Added 220k - 680k Ohm resistance between ground and button negative wire - Idea was to remove possible inductance from the wire > Still the same problem.
6)   Added diode in series with the above resistance (to remove interference?) > Still the same problem.

Schematics and little more details about relays and buttons below if someone is interested.

Relay specs:
FINDER - 46 Series; Coil voltage and current: 24 VDC and 20 mA; Coil resistance: 1.2kohm. More details of the relay can be found from here: http://uk.farnell.com/finder/46-61-9-024-0074/relay-spco-16a-24vdc/dp/1329676

Button specs:
ABB 5-25 VDC/VAC; Load capacity: 10m A ac/17mA dc. More details: http://installationmaterials.com/catalog/19727/product/25390/FAP1204_ENG1.html

I would certainly go for the interference possibilities here. I have a automation project myself which I had major issues in the first versions causing inputs firing themselves. I solved this by making it an power circuit instead of a voltage circuit (which you also have now). I also raised the voltage level to and from the buttons isolating and isolating the Arduino with opto isolators.


Thanks for the reply!

Could you elaborate a bit how you changed it to power circuit? Did you run into any problems with current delivery as Arduino has about 20 mA max current supply?

How were you able to raise the voltage level with buttons? Do you have any blog / forums posts about your setup?

Earlier I ran into current delivery problems when I had too low resistance between Arduino and the transistor (only 220 Ohm). The symptoms were slow reaction / lagging when button was pushed. This was solved by raising the resistance to 6.8 k Ohm, I guess it could be even higher and still fire the transistor.


For those new to opto-isolators... wonderful devices... there's help at...


For the application this thread is about: The the opto-isolator would installed NEAR the Arduino (shorter wires=fewer problems with induced voltages) and the LED in it would be "run" by the microswitch.


Have you tried shielded twisted pair for the micro-switch wiring?


The cable is basically twisted pair, 5 pairs of cables. Currently I'm using only single wire from the pair. It also has metallic sheet surrounding all the pairs + one extra unshielded cable. Tried connecting the unshileded cable to earth ground (yellow-green wire).

Should I be using both pairs of the twisted cable together between button and Arduino input pin?

If you look at this image you will see how it is connected to a input of an Arduino.

The left side is completely isolated from the right side and the GNDs are NOT connected together. This way the Arduino input/output current limitation is not a problem. If you use a different optoisolator than the one in the schematic or change the voltage level from the button you need to recalculate the R2 value to suit the optoisolator.

Go Up