jimbarstow
Posts: 1
Joined: Tue Apr 09, 2019 2:03 am

Detecting AC current using DC transformer

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?

thanks

pcmanbob
Posts: 7264
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Detecting AC current using DC transformer

Tue Apr 09, 2019 10:23 am

Hi.

First in answer to your negative wire question yes you would just connect it to the pi ground.

But .....

have you tested the power supply you are going to use, does it produce a stable 3v supply even with no load ?

you might be safer to use an opto isolator between the 3v power supply and the pi gpio , this would isolated the 2 devices from each other, and protect the pi in the event the 3v psu produces a higher than 3v output.

something like this

Image
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ElEscalador
Posts: 687
Joined: Tue Dec 15, 2015 4:55 pm
Location: Detroit, MI USA
Contact: Website

Re: Detecting AC current using DC transformer

Tue Apr 09, 2019 1:19 pm

The issue I would be wary of is you ac-dc converter may not (or may, I don't know anything about it) be filtered enough to prevent the pin from reading low 50 or 60 times/second. This could be handled with software debouncing... I also might wonder if that supply might start with a big voltage spike before it corrects. IDK...seems easier to me to switch another relay with that 110volts, then just run ground from the pi, through the N.O. relay contacts, then back to the pin you want to read - that pin set as input and pulled high. when the pin sees low, your relay is closed.
My Autonomous Robot Project and a few of my other projects below.

https://lloydbrombach.wordpress.com/

PhatFil
Posts: 1436
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Detecting AC current using DC transformer

Tue Apr 09, 2019 1:42 pm

i cant help wonder if there is an alternative indicator you could use? any led or neon indicators come on with power that could be masked with a lump of blutack containing a light sensitive resistor?? does the pump vibrate sufficiently for a tilt switch to register?

Or how about a bit of re-wiring, use a pi controlled relay (im a fan of wifi controlled smart switches) to control the pump and use the float switch directly connected to gpio to act as a control trigger?

your solution would work, but i would imagine keeping live mains power wiring and connections to a minimum would be preferable in a wet environment with water tanks and pumps..

JohnsUPS
Posts: 129
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Detecting AC current using DC transformer

Wed Apr 10, 2019 11:52 am

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?

thanks
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 :D 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.

Return to “Interfacing (DSI, CSI, I2C, etc.)”