I am trying to get 8 stop buttons to cause an Arduino UNO to activate a single relay!

The stop buttons have been placed 30' to 250' away from the Arduino uno board.

Q: How far can you go with 5v and still get signal back?

Q: Is there a way to boost the signal?

  • Are the buttons all on the same pair of wires? Or on 8 separate pars? Jul 3 '15 at 7:46

Q: how far can you go with 5v and still get signal back?

That depends on two main factors:

  1. The gauge of the wire
  2. The noise in the environment

Assuming a low-noise (where noise is negligible) environment, we will first look at the wire.

All wire has an inherent resistance to it. The thicker the wire, the lower the resistance. This table has good information about the resistance of different gauges of wire: http://www.powerstream.com/Wire_Size.htm

Given a typical arrangement where the internal pullup resistor of the Arduino's IO pin is used to create an "active low" arrangement (pinMode(x, INPUT_PULLUP) the equivalent circuit can be seen as this:

enter image description here

Given that the "Input Logic Low" (VIL) level of an input pin (according to the ATMega328P Datasheet (Table 30-1) is 0.3Vcc, and Vcc is 5V, the input low level would therefore be 1.5V. The voltage present at the IO pin has to be below 1.5V in order for the input to be seen as a LOW.

The circuit, when the button is pressed, can be simplified to this:

enter image description here

That is a simple voltage divider. The formula for calculating Vout is (R2/(R1+R2))*Vin. We know that the Vout limit is 1.5, and Vin is 5V. Also that R1 is approximately 50KΩ (very approximately). So we can rearrange the formula to:

R2 = R1(1/((Vin/Vout)-1))

Substituting our known values we have:

R2 = 50,000 × ( 1 / ((5 / 1.5) - 1)) = 21428.57Ω

So the total resistance of the wire permissible is around 20KΩ assuming the internal pullup resistor is 50KΩ (note: it could be as low as 10KΩ or as much as 70KΩ).

Divide that value by 2, since the wire has to run twice the distance (once there and once back again) and you get a total resistance of around 10KΩ for one leg of the journey.

Now assume a wire gauge of 24AWG. That has a resistance of 84.1976Ω/km. So we can work out that 10,000 / 84.1976 = 118.77km.

So with 24AWG wire you could theoretically have your button about 100km away from the Arduino and just about have it still register properly.

But of course that's with no noise, and there will be noise - especially over that kind of distance.

The noise will basically make the voltage seen at the input vary randomly around the theoretical value. Those wires act like great big antennae, and they pick up all sorts of stray EMI. The longer the wires the more noise there will be, and consequently the lower the voltage you will need to aim for (or higher voltage if using a pull-down arrangement - just turn the whole thing upside down) to keep the logic level below (or above) the right threshold value.

Q: is their away to boost the signal?

Yes, you can use a higher voltage. There is nothing to say that you have to interface your button directly with the Arduino. There are many ways of having your button switch a higher voltage on and off and use that to trigger the Arduino. The simplest (and also the safest) may be to use an opto-coupler. Use your button(s) to switch a 12V power supply on and off, and that then passes through a suitable resistor to power the LED in the opto-coupler. That then switches on the built-in transistor to turn on the IO pin.

enter image description here

Another option may be to use a reliable communication bus with a small microcontroller at each stop-button point (maybe something like RS-485), though that may be overkill for this kind of application.

  • 1
    I agree with Majenko. The noise over any sort of moderate length is likely to swamp the 5V in the wire. However as he suggested you could use an opto-coupler (like MIDI does). The opto-coupler is activated by current not voltage, and whilst mains and other sources may introduce quite high voltages they are unlikely to introduce high currents. The opto-coupler also lets you use a higher voltage, thus overcoming wire resistance. Its third benefit is isolating the input pins from any high voltages that might appear in the wire.
    – Nick Gammon
    Jul 3 '15 at 6:16
  • 1
    While the galvanic protection may have some advantages, note that you can make what is basically a current-mode input by using a smaller pullup resistor. Many practical systems also use differential receivers. There are also transmission line effects like reflections to consider, though a system with a mechanical switch will already need debouncing for that which may deal with the line reflections too, until the distance gets to be huge. Jul 3 '15 at 14:15

Majenko's answer is probably the safest option. There is, however, something simpler that you can try:

  • Use a strong pull-up (or pull-down). Something around 1 kΩ will make it quite difficult for the noise to pull your signal low, at the cost of increased current consumption.
  • Connect each push button to the Arduino using a twisted pair of copper wires. This will minimize the inductive pickup effect.
  • 1
    PS the increased power consumption is only while the button is being pressed.
    – Gerben
    Jul 3 '15 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.