Connecting REALLY long(80‌‌~100 feet) input wires to arduino

Hey guys.

Short story, i have to connect 4 float switches with arduino that are on average 100 feet apart from the arduino.
I have to use common electric wire to connect the distance. I cant change the type of wire, i would've preferred cat-6 cable, but i cant get them now for various reasons. Anyways,
The wires are guided by a thick water pipe that is fairly far from power lines, but that doesn't eliminate the surge problem. I will include
"if input is high/low for 10 seconds, read active or inactive, otherwise disregard input." in code.( the switches are float switch, so 10 sec is not a problem)

Problems..

  1. How should i connect the long,long wires to arduino input? Directly connecting them to arduino pins is a circuit for disaster. I was thinking of something like

+12v -> float switch wire 1 -> float switch wire 2 -> optocoupler input 1 -> 12v ground.
I really cant tell the resistance of the wire before setting everything up, so resistors might be included so the opto Doesn't burn.

But what if? What if a surge happens and burns the optocouplers? I know they are cheap, but im looking for long time reliability, without changing stuff.

  1. What other option do i have to isolate the signal and have better reliability?

Some info on the project.
A system to control 2 water pumps based on the input of 6 float switches on 4 different tanks, based on a forum conversation i had, i have decided to go with adequately rated ssr( yes,heatsink). The arduino nano is going to be powered by 12v regulated to 5v ( lm317t).

I decided not to have a battery power for the arduino as i dont see any use of that because the motors are mains powered.

!!Load-shedding is quite common in my country. Does that harm the ssr's?!!

kaseftamjid:
The wires are guided by a thick water pipe that is fairly far from power lines, but that doesn't eliminate the surge problem.

What is the source of the surge?

What wire is used? Be specific- you said "I have to use common electric wire...". Why? Is it already installed? Is it a dedicated, not shared cable?

A hand drawn schematic is a lot better than your somewhat rambling description.

From your description I would suggest using a modification of the attached circuit.

Changes Required:

R2 should be 1.5k
R3 should be 500 Ohms
C5 should be 1 µF ceramic
you should add a 200 ohm resistor across C5 (watch the power in this resistor)

D5 Is a TVS should be ~ 12 V

The "from Track" will go through your float switch(s) then to +12V

The "to ESP" would go to your opto isolator

The bottom trace i.e. common of C5, D5 & C6 should be connected to the building ground.

Short of a lightning strike you should be in good shape.

Also, I think the wire type is irrelevant as long as its not connected to anything else.

John

Hi,
As per @JohnRob

Tom.. :slight_smile:

SteveMann:
What is the source of the surge?

What wire is used? Be specific- you said "I have to use common electric wire...". Why? Is it already installed? Is it a dedicated, not shared cable?

A hand drawn schematic is a lot better than your somewhat rambling description.

" long wire has another name, its an antenna"As the wire is an unterminated input, a lot of things can cause a voltage spike in the wire. I wouldve added a circuit, but i was outside...
It is a dedicated cable

JohnRob:
From your description I would suggest using a modification of the attached circuit.

Changes Required:

R2 should be 1.5k
R3 should be 500 Ohms
C5 should be 1 µF ceramic
you should add a 200 ohm resistor across C5 (watch the power in this resistor)

D5 Is a TVS should be ~ 12 V

The "from Track" will go through your float switch(s) then to +12V

The "to ESP" would go to your opto isolator

The bottom trace i.e. common of C5, D5 & C6 should be connected to the building ground.

Short of a lightning strike you should be in good shape.

Also, I think the wire type is irrelevant as long as its not connected to anything else.

John

TomGeorge:
Hi,
As per @JohnRob

Tom.. :slight_smile:

I was having a bit of trouble understanding the schematic, but tom made it quite simpler, Thanks a lot both of you..

Although im using 1 supply, but if i was using 2, one for arduino one for opto circuit, would i need to couple the battery ground with supply ground?

No.

Optos are used to separate circuits, but still be able to communicate between those circuits.
In this case you need to not have common ground.
GND symbols in the last schematic should be different from each other (if you take a real good look, they actually are !), and one of them should be named different, like GND1 (note that one of them was not named here).

If you would connect these GNDs, the optos would be useless and a transistor would be doing just the same thing.
Of course you already noticed that such circuits reverse logic, and a LOW would mean that the sensor is in active state.

kaseftamjid:
+12v -> float switch wire 1 -> float switch wire 2 -> optocoupler input 1 -> 12v ground.
I really cant tell the resistance of the wire before setting everything up, so resistors might be included so the opto Doesn't burn.

You always need current limiting resistor with an optocoupler....

But what if? What if a surge happens and burns the optocouplers? I know they are cheap, but im looking for long time reliability, without changing stuff.

The surge will basically be common-mode, not differential-mode. That's why you use opto-couplers in the first place because they can handle ~5kV of common-mode pulse.

If there's a significant chance of direct lightning strike near the cable, it may fail, that's a fact, and you then need optical fibre for best reliability. There will be many more surges within an opto-coupler's ability though, and the protection it affords is worth having.

One more note:

If you are connecting the GND from the float switch to the building ground as instructed, and the Arduino would be connected to your PC at the same time, be aware that a standard PC will (should) be connected to protective GND, which is the same as your building GND
So try to prevent that from happening at any moment you can expect these surges.

kaseftamjid:
Hey guys.

Short story, i have to connect 4 float switches with arduino that are on average 100 feet apart from the arduino.
I have to use common electric wire to connect the distance. I cant change the type of wire, i would’ve preferred cat-6 cable, but i cant get them now for various reasons. Anyways,
The wires are guided by a thick water pipe that is fairly far from power lines, but that doesn’t eliminate the surge problem. I will include
“if input is high/low for 10 seconds, read active or inactive, otherwise disregard input.” in code.( the switches are float switch, so 10 sec is not a problem)

Problems…

  1. How should i connect the long,long wires to arduino input? Directly connecting them to arduino pins is a circuit for disaster. I was thinking of something like

+12v → float switch wire 1 → float switch wire 2 → optocoupler input 1 → 12v ground.
I really cant tell the resistance of the wire before setting everything up, so resistors might be included so the opto Doesn’t burn.

But what if? What if a surge happens and burns the optocouplers? I know they are cheap, but im looking for long time reliability, without changing stuff.

  1. What other option do i have to isolate the signal and have better reliability?

Some info on the project.
A system to control 2 water pumps based on the input of 6 float switches on 4 different tanks, based on a forum conversation i had, i have decided to go with adequately rated ssr( yes,heatsink). The arduino nano is going to be powered by 12v regulated to 5v ( lm317t).

I decided not to have a battery power for the arduino as i dont see any use of that because the motors are mains powered.

!!Load-shedding is quite common in my country. Does that harm the ssr’s?!!

I quoted your entire original post so I can see it as I write.

Why all the float switches? Are your tanks all feeding a common pipe? If so, only two switches are needed for the whole system as water will backflow from tank to tank and all will be equal.

You write the sense wires are guided by a thick water pipe. Are the wires inside the pipe or just along side?

Are all the mains power supplied by a single mains transformer? If not, there may be a voltage difference in the grounds for the transformers and that is a problem for your design.

How are you powering the Arduino? If using a wall wart, then the Arduino ground is not your house ground, unless you have made special provisions for that connection. If other power, be sure that the Arduino is really connected to the house power ground.

And, lastly, what type of float switch? Are they the plastic devices encasing a reed switch and use a magnet to operate the switch. Or that the big round floating switches with a steel roller inside that makes contact as the float tips up or tips down?

Paul

Paul_KD7HB:
I quoted your entire original post so I can see it as I write.

Why all the float switches? Are your tanks all feeding a common pipe? If so, only two switches are needed for the whole system as water will backflow from tank to tank and all will be equal.

You write the sense wires are guided by a thick water pipe. Are the wires inside the pipe or just along side?

Are all the mains power supplied by a single mains transformer? If not, there may be a voltage difference in the grounds for the transformers and that is a problem for your design.

How are you powering the Arduino? If using a wall wart, then the Arduino ground is not your house ground, unless you have made special provisions for that connection. If other power, be sure that the Arduino is really connected to the house power ground.

And, lastly, what type of float switch? Are they the plastic devices encasing a reed switch and use a magnet to operate the switch. Or that the big round floating switches with a steel roller inside that makes contact as the float tips up or tips down?

Paul

I actually also quoted your whole post for the same reason (pinch?)

anyways,

there are 4 tanks in total. 2 above 7 stories and 2 below as reserve. water from mains collect here. Those are controlled by a mechanical float valve.

there are 2 switches in the high level( 7 story) tank, one for full and other for low.
so 2x2=4

the other 2 switches are in the lower reserve tanks as low level switch.
The thing is, NOTHING in my country is 100% reliable, nor gas, nor water, nor electricity nor anything.
so if the low level switches are not active, that means the tank has no water and that stops the motor from running which in turn prevents burning of the motor ( google " What happens when a centrifugal pump runs dry? ")

the water pipes were used before so someone below could see that the tank has overflowed and turn the pumps of manually,
the wires are going to be inside the pipe.

there is only one transformer(quite overrated for the load, thanks to grandpa) for the whole area, so yes, one transformer, no grounds voltage difference.

the float switches are reed switches

aand this is another part I'm confused about. I plan to use a 12v adapter to power the opto circuit and also use a lm317t regulator to feed 5v to arduino.
So basically there are 2 grounds, one from the ac supply( neutral actually, we have no ground wire here) and another from the dc adapter.

please explain this bit, I'm just a 11th grade hobbyist with not much theoretical knowledge than hundreds of google explanations..

Paul_KD7HB:
How are you powering the Arduino? If using a wall wart, then the Arduino ground is not your house ground, unless you have made special provisions for that connection. If other power, be sure that the Arduino is really connected to the house power ground.

Paul

MAS3:
Of course you already noticed that such circuits reverse logic, and a LOW would mean that the sensor is in active state.

I'm not pretty clear what this means.. please do explain a bit.
Does the opto circuit output low ( to arduino) if the switch is high/active?

Paul_KD7HB:
Why all the float switches? Are your tanks all feeding a common pipe? If so, only two switches are needed for the whole system as water will backflow from tank to tank and all will be equal.

the tanks are not connected nor do they share common pipe. actually this here is 2 systems.

maybe useless explanation

Actually the building i live in has 2 buildings, but both buildings share a common staircase. 1 was constructed few years after finishing the first one. so no one messed with the old ones plumbing.(each bulding have different plumbing) They just moved the 2 water pumps close together and the circuit breakers near them for easy 'manual' access.
so nothing is shared between the pumps. One pump for old reserve to old high tank, one pump for new reserve to new high tank.

TomGeorge:
Hi,
As per @JohnRob

Tom.. :slight_smile:

what about the 200ohm resistor across c5?
and what kind of power rating should i choose?
i can always mess with series/parallel resistor connections for desired power rating.

Thanks for explanation!

The "adapter" you are using, if it's like our common wall warts does NOT have a connection to your neutral line. The "-" or negative is floating just like the "+" line.

The problem is any disturbance in the - connections in your entire system will be reflected back to your Arduino as a change in the "+" line, since the - is used to determine when the + line changes. A noise pulse on the - line will possible make the voltage difference between the two exceed the voltage limits of the Arduino. Be sure to make a firm connection to your house neutral power.

How many wires are going to put into the pipes?

Paul

MAS3:
No.

Optos are used to separate circuits, but still be able to communicate between those circuits.
In this case you need to not have common ground.
GND symbols in the last schematic should be different from each other (if you take a real good look, they actually are !), and one of them should be named different, like GND1 (note that one of them was not named here).

If you would connect these GNDs, the optos would be useless and a transistor would be doing just the same thing.
Of course you already noticed that such circuits reverse logic, and a LOW would mean that the sensor is in active state.

I don’t follow. I’ve used Opto Isolators using a common ground all the time. As long as the supply power is separate then the optoisolator should work fine. I do question the 520k series resistor as the LED in the optoisolator may not light at all.

The whole point of using optos is gone when you’re reconnecting the circuits.
GND is part of this circuit, as it is one of the supply lines (most of the times it will be “minus”).
Sure it will work, but the here desired protection is gone.
Use a transistor instead, it’ll be a lot cheaper and will work just as fine.

I see 1K5 plus 0K5, makes 2K.
Seems a perfect logic choice for a 12 volts supply of the opto LED to me.

I’m not pretty clear what this means… please do explain a bit.
Does the opto circuit output low ( to arduino) if the switch is high/active?

That’s right.
When the switch in your floater closes, the opto’s LED will be lit, which will open the transistor, so the pin you programmed as PULL-UP as instructed in that schematic, will be pulled down towards GND level (the transistor wins from the pull up resistor).
It’s not a problem, you just need to look for a LOW in your code instead of a HIGH.
There are no other consequences, so it will not hurt, i promise.

Welcome!

Paul_KD7HB:
Thanks for explanation!

The "adapter" you are using, if it's like our common wall warts does NOT have a connection to your neutral line. The "-" or negative is floating just like the "+" line.

The problem is any disturbance in the - connections in your entire system will be reflected back to your Arduino as a change in the "+" line, since the - is used to determine when the + line changes. A noise pulse on the - line will possible make the voltage difference between the two exceed the voltage limits of the Arduino. Be sure to make a firm connection to your house neutral power.

How many wires are going to put into the pipes?

Paul

The connection/adapter is hoing to be connected inside a locked box.. So no chance of physical faulty connection.

Any non-physical disturbance i need to worry about?

I was originally hoping to connect the high level (top reserve) switch grounds together, which makes 3 wires on one tank. So 6 wires down the pipes.

Does using different ground wires for each individual switch give any advantage? Given the fact that all of those are going to be connected to a common ground/-?

MAS3:
The whole point of using optos is gone when you're reconnecting the circuits.
GND is part of this circuit, as it is one of the supply lines (most of the times it will be "minus").
Sure it will work, but the here desired protection is gone.
Use a transistor instead, it'll be a lot cheaper and will work just as fine.

I see 1K5 plus 0K5, makes 2K.
Seems a perfect logic choice for a 12 volts supply of the opto LED to me.

That's right.
When the switch in your floater closes, the opto's LED will be lit, which will open the transistor, so the pin you programmed as PULL-UP as instructed in that schematic, will be pulled down towards GND level (the transistor wins from the pull up resistor).
It's not a problem, you just need to look for a LOW in your code instead of a HIGH.
There are no other consequences, so it will not hurt, i promise.

MAS3:
The whole point of using optos is gone when you're reconnecting the circuits.
GND is part of this circuit, as it is one of the supply lines (most of the times it will be "minus").
Sure it will work, but the here desired protection is gone.
Use a transistor instead, it'll be a lot cheaper and will work just as fine.

I don't agree with this. They can be used for isolating grounds, but that's not the only purpose. You see optocouplers used when safety isolation is needed between devices or when they can’t share a common ground. I have used opto-isolators in kV circuits- something you really want to keep away from logic level circuits, and they always had a common ground.

Here is a modification to Tom's schematic showing an application where a common ground at the opto-isolator is not practical. But to the OP's question, yes, you can use a single ground wire from the power supply ground.

Opto_LongCableA.jpg

Opto_LongCableA.jpg