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.
Problem
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:
Run Arduino from battery > Did not help, still interference.
Run Arduino from wall-wart power supply 5VDC > Did not help, still interference.
Run Arduino from USB power supply 5VDC > Did not help, still interference.
Grounded the wire that goes to the buttons > reduced problems a bit(?)
Added 220k – 680k Ohm resistance between ground and button negative wire – Idea was to remove possible inductance from the wire > Still the same problem.
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.
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.
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.
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.