I have some home automation, and want to put a rain sensor far away (about 30') from my computer.

(EDIT: Rainfall meter or rain gauge, not a sensor. as per Transistor)

The sensor uses a mechanical teeter-totter with a magnet that momentarily triggers a reed switch as it tips.

I want to use the reed switch to set a flip-flop (74?109) that the computer can read at its leisure, then I want the computer to clear the flip-flop.

Do I put the flip-flop far from the computer and near the sensor running Vcc, Gnd, Clr, & Sens, or put the flip-flop near the computer only running the reed closure through the wire?

Reliability, of course, is paramount. I am thinking noise issues, and impedance.


My arguments for each case...

If I put the flip-flop near the reed switch, the reed switch will reliably trigger the flip-flop, but there may be a lot of noise on the clear line triggering false clears.

On the other hand, putting the flip-flop close to the computer will make that reliable, but the 60' of wire may not trip the flip-flop as the magnet goes by. Also, there may be noise on that line and may trigger false sets.

In either case, I have lots of old 4-conductor telephone (CAT3?) cord.


  • \$\begingroup\$ What's the shortest & longest interval you expect the reed switch to remain closed? What's it's current-carrying capability? \$\endgroup\$
    – TimWescott
    Jun 27, 2019 at 17:33
  • \$\begingroup\$ I think you are describing a rainfall meter or rain gauge rather than a rain sensor (which would detect the presence of rain). \$\endgroup\$
    – Transistor
    Jun 27, 2019 at 17:39
  • \$\begingroup\$ @Transistor, yes, a rainfall meter or rain gauge, not a sensor. I will edit. \$\endgroup\$ Jun 27, 2019 at 19:35
  • \$\begingroup\$ @TimWescitt, I think the reed sw pulse could be as short as 250mS. \$\endgroup\$ Jun 27, 2019 at 19:35

2 Answers 2


If you put the flipflop near the rain gauge, resistance of the wire will become problematic. The voltage drop from resistance and inductance of the wire could create noise and voltage drops. One could put the flip flop on the rain gauge, but it would also be wise to put a voltage regulator there also, to ensure that the voltage rail of the flip flop is constant. It might also be advantageous to use a Schmidt trigger to detect the voltage from the relay before the flip flop.

Since the gauge is simply a relay and open or closed, it would be sufficent to put the flip flop at the computer. There are several ways to prevent magnetic noise, one being twisted pair (which CAT 3 is) but it might also be better to use shielded twisted pair.

With outdoor wires, lighting and other electric fields can induce high voltages that could be too high for a digital input. Here are some ideas/example circuits to prevent high voltage from accessing digital electronics.

Either isolate the input with an optoisolator:

enter image description here

Source: https://www.avrfreaks.net/forum/level-protection-interfacing-24v-residential-electrical-installation

Or use voltage transient suppression (with a smaller fuse):

enter image description here

Source: https://dmohankumar.wordpress.com/tag/tvs-diode/

  • \$\begingroup\$ Hmmm, thanks, @laptop2d. I hadn't considered voltage strikes. I live in nw WA. and there are a couple of big trees near the house. I expect lightening is a very low probably, but I will reevaluate. Wire resistance is my main concern. I have 12V and 5V, maybe powering with 12V CMOS and then clamp it just as it feeds into the computer. I think I will noodle it for a while longer. \$\endgroup\$ Jun 27, 2019 at 20:21
  • \$\begingroup\$ meta.stackexchange.com/questions/126180/… \$\endgroup\$
    – Voltage Spike
    Jun 27, 2019 at 21:17
  • \$\begingroup\$ Actually, @laptop2d you gave me a great idea. I found a jacketed 60-foot dual fiber optic cable on eBay for $10. Maybe I will simply use that instead of using the magnet and reed relay idea. I can put a high output LED near the computer and let the teeter-totter interrupt the light when it is tipped left (or right.) This solves just about all the problems. it should be plenty slow enough for the computer to notice, eliminates voltage spike concerns, eliminates power to the rain gauge issues, and is so cool to boot. Thanks. Mark. \$\endgroup\$ Jul 8, 2019 at 18:33
  • \$\begingroup\$ Oh, cool, if you like the answer, then upvote and mark the best answer as answered. \$\endgroup\$
    – Voltage Spike
    Jul 8, 2019 at 18:34

You can do it either way safely, filter all noise and provide protection for 20kV ESD and stray lightning induced voltage 3kV or more if necessary.

  • Assuming a series R =< 10k to a voltage = for pullup
  • 0 Ohm contact close with bounce time ~<1ms to 0 V
  • use shielded twisted pair (STP) or CAT 3 with RJ11 or similar Plug/Jacks assume < 100pF/m
  • connect shield or 2 wires to outer 2 pins to earth ground pins on Jack
  • connect contacts A,B to other 2 wires to inner 2 pins.

  • to limit current R’s then to TVS or clamp diode,

  • use a series R string rated for 3kV for switch open CLK bias to Gnd. E.g. 10kOhm total. E.g. 1/4W resistors rated for 250Vac can withstand 1kV with 1us/10us tail , roughly...

  • RC time constant = 150 to 200ms after series R + Zener or TVS /diode clamp to earth ground. +5/-1V then

  • 2nd stage current limit series R=10k to Clk
  • 100kohm hysteresis from Q to CLK or 10% for noise immunity after RC LPF for line RF, can be increased.

Can make schematic later all using 5V 74HC Logic.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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