Maximum distance from Arduino ports to sensors

I'am want to connect long-distance sensors with the Arduino, about 50 meters.
I have two options (sceneries): "A" and "B" to choose, especially the "B"

-> Scenario "A":
Arduino Uno connected to an on-off switch via digital port, diagram below:

The blue wire in the figure extends for about 50m.
Some questions:

  • Would a 2.5mm2 electrical conductor work well? Would it have to be a Cat5 cable?
  • In the Schematic I use PullDown, a 10K resistor would be suitable?
  • Would switching to PullUp make any difference?

-> Scenario "B":
Arduino Uno connected to an Ultrasonic sensor (SR04 or similar) via digital port, diagram below:

In this case, would a Cat5 cable work?

Thanks.

Schematic:

Hi, welcome to the forum.

You say "sensors", more than one.
You can not put sensors at a distance of 50 meters. You need a second Arduino board near the sensors.

For the switch in scenario "A", I would use a few mA via a optocoupler. The cable does not matter.
For safety and for noise, it is better if one wire is the GND wire.
Without optocoupler, a electric pulse from electrical equipment nearby, could destroy the Arduino board.

The scenario "B" is not possible. Normal digital signals can not go that far.

Koepel is correct for simple wiring.

However, you can easily get 50 meters or more from specialized shielded cables provided you understand how electrical interference (hum, noise, EMP) creates problems.

If you are insistent on doing this switching, refer to XLR (analog) low-signal "balanced" cabling and take notes on shield wiring.

https://stampsound.com/how-long-can-xlr-cables-be/

The current being switched is low, so inductance will be no problem but capacitance will force an upper limit on how quickly the switch can cycle.

Honestly, opto-isolators are the ideal way to be safe in this scenario.

Hi Koepel, thank you for the welcome.
Yes, I said "sensors", but it was in the context of both scenarios.
I had already thought about the solution to use 2 Arduinos and communicate them via ethernet, but I was hesitating. I thought there might be a simple and cost-effective way to increase the distance from the sensor to the port. Yep, I'm going to explore the optocoupler idea, also using a GND wire is a good tip. As scenario "B" is my main goal, it needs 2 devices anyway.

I would suggest scenario "A" with the following details:

  • use twisted wire. Could use Cat 5 and ground all the other wires at the arduino.
  • Add an opto isolator at the Arduino end.
  • heavily filter the input at the board.
  • use a lower resistance for R1, like 500 ohms.
  • put the switch to switch to ground not high

The opto may not be too useful if you must power the switch from the same Vin.

Hi mrburnette.
This type of cable is an option, it implements techniques like cancellation , I guess. It will probably should be a little expensive for 50m. I will need to evaluate the cost-benefit, but it is an effective solution, cool.

Hi JohnRob.
Using cat5 cable is a cheaper option and grounding the remaining wires in the cable will help.
I'm not electronics savvy, but the Vin question can be an issue. I believe that in this case another question would be the protection of the Arduino port.
If I use the optocoupler, I believe I need to provide another power source for the switch. Could using 24V be a better choice due to the distance?

2 ESP32's using ESPNOW wirelessly exchanging data.

I think the Vin can be protected going out to the switch.

I'm no the fence about the opto. I know it won't hurt but I'm not sure it will be of much help.

The key is to keep the resistances low to reduce pickup. I would consider using a SPDT switch and have the signal switch from Vin to ground. This would leave no open wires. Of course the protection resistors (and capacitors) would have to allow all three wires to be shorted together and not hurt anything.

Would the 24V be a 2nd source?
No I don't think there is a need for 24 unless it was isolated from the Vin.

Keep in mind you have a "slow" signal. Its not like an I2C or RS232 signal.

Hi Idahowalker.
Yep, this approach would replace the choice of the Ethernet. Its seem that the ESP-NOW range reach near 500m with internal antenna. Do you know if that's right?

It is definitely possible, but it is probably simpler and may be cheaper to use WiFi. This may apply even if you have to run a power supply to the sensors. The ESP-01 is made for this sort of thing and costs about $5 at most. If you go this route, you would be better off retiring the Uno in favour of a Node-MCU or the like.

I used the words "espnow range" in an internet search thingy to get a result set which relates to your question.

I'm sure the ESP route will be more interesting to work on. However assuming you don't have power at your 50M location you would still need to run a cable. At that point a switch is more cost effective and I would guess more reliable. I will admit however my NodeMCU was pretty solid when connected to my WiFi.

Oh.. You will still need a switch at the 50M location.

That's right. If the connection is adequate using ESP/Node will be presumably the best choice.

I have power on both sides, so make it easier. Then, I think it must be the best way in this case, since the cable could bend the distance (turns, contours).

Sounds good. Pls let us know how you make out.