jimbarstow wrote: ↑
Tue Apr 09, 2019 2:12 am
I need to monitor a float in a water tank. The float acts as a switch in a 120V AC circuit; when the water level falls below a specified level, the float switch closes and activates a contactor (relay) in the pump house that turns the well pump on. When the water level rises above a set level, it switches the AC circuit off and the pump shuts down.
What I've done is wire a standard outlet into the return side of the float AC circuit and plugged in a 3V AC-DC transformer. I'd like to attach the positive output of the transformer to a GPIO pin and monitor its HIGH/LOW state. When the float switch is open, the outlet will get no power and the pin should be LOW. When the water level falls, the float switch will close, the transformer will be powered, and the pin will go HIGH.
I've got a couple questions:
1) Is there some reason this won't work?
2) What do I do with the transformers negative wire? Just connect it to the RPI ground?
3) Do I need an separate pull-down resistor or will the RPI's internal be ok?
I'd recommend connecting an opto isolator as pcmanbob has suggested. This is the route that I would take in this situation. This isolates the Pi, and the output should be pretty immune to multiple output transitions (bouncing). This will also be a reliable solution.
Even without knowing the specifics of your 3V AC-DC power supply, I wouldn't connect the output of it directly to the Pi, even if the output is 3V. This is beause you don't know what kind of gymnastics the output will go through prior to settling down to the rated output voltage. Many times, the no load
output voltage is much higher than the nameplate voltage (not always, but be aware). Because the GPIO pins represent a fairly high input impedance, odds are that the supply may spike momentarily above what would be considered a safe HI input voltage. Those spikes may not cause a failure right away, but in time they might.
You could connect the coil of a suitably rated relay, but then you may have to contend with contact bounce.
I did something somewhat similar with my sump pump. I put two counters on it - one totalizing counter and one resettable type. Not that I needed to, but because I can
It was a little side project to use up some counters that I had laying around. No digital electronics were involved (mechanical Durant-type counter), so I used a relay, otherwise I would have used an opto.