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.
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.
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.
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?
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.
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'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.