Author Topic: 220VAC to Digital Input  (Read 1786 times)

0 Members and 1 Guest are viewing this topic.

Offline lmagalhaesTopic starter

  • Contributor
  • Posts: 43
  • Country: pt
220VAC to Digital Input
« on: December 02, 2020, 11:43:57 am »
Hi there,

I don't know if this has been asked here before, but I have this "very basic" question and all the solutions I come up are either a bit expensive and include throwing away alot of energy. Here's the context:

I have a water boiler that is being controlled by a pressostat. I have a relay that I control with my arduino to feed power into the pressostat. Internally, it regulates the temperature of the water based on the pressure reading inside the boiler, meaning it will turn on and off the heater resistors. I wanted to have an approximate energy consumption value for this system and for that I need to know when the heater is on and not. If I take the integral of the time the relay control is ON, which is 99.9% of the time (it's just not on before having a minimum value of water inside the boiler, after that it's always on) the energy consumption value is much higher than it actually is because the heater is not always turned on.

My idea was to wire the output of the pressostat relay to the heater and take it all the way to the PCB and sense it. If it has 220VAC, then the heater is turned on and I need to count the ON time. If it doesn't, then the heater is not ON.

My first reaction was to use a simple voltage divider to bring down the voltage of the AC to like 3Vac and then feed it into an optocoupler. Even if I used like 10 0805 resistors of 100K in series and then in series with the LED of the optocoupler. I'm a little concerned with the safety of this approach (arcing across the resistors, something blowing up). Also, in software, I'd have to be looking for the transitions and determining when it's turned off. Other solutions include using a small transformer from 220VAC to something more manageable like 6VAC (BV EI 307 8009 for example), however this little guy is a bit expensive and not only that but it would be the same, on the other side of the optocoupler. I could add a diode bridge and a cap to make it into DC, but maybe I'm overthinking all of this. Is there any simpler approach to this that I'm not getting at ?

I have also seen some approaches where people use capacitors like resistors (http://www.circuitdiagram.org/simple-220v-mains-indicator-led.html) to try and reduce the current flowing, but I don't know how valid this approach is either...
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13076
Re: 220VAC to Digital Input
« Reply #1 on: December 02, 2020, 11:59:17 am »
Your best bet is probably a clip-on current sensor (current transformer) on the live feed to the heating element(s).  Here's one from Sparkfun: https://www.sparkfun.com/products/11005

Read its datasheet and application notes.  There are many similar alternatives on Amazon and Ebay which may be easier for you to to buy.

N.B. its critically important for current transformers that you *NEVER* let the secondary be open circuit while the primary circuit is connected.

A cheap but somewhat 'hacky' way to do a safe mains present sensor is to closely couple a photocell (LDR) to a mains neon indicator.  Simply attach the LDR to the face of the indicator with clear glue, heatshrink over it, and back-fill the LDR end with black potting compound or non-corrosive black sealant.  N.B. the LDR resistance change will decrease as the neon bulb fades due to aging.  Make sure your detection threshold allows enough margin.
« Last Edit: December 02, 2020, 12:05:30 pm by Ian.M »
 

Offline lmagalhaesTopic starter

  • Contributor
  • Posts: 43
  • Country: pt
Re: 220VAC to Digital Input
« Reply #2 on: December 02, 2020, 02:21:24 pm »
Regarding those current clips I had already looked into it to get a current value instead of going this route but besides being somewhat expensive, I've read they're a fire hazard. Also, I don't need to actually measure the current, I just want to know if the relay is on or not.

Regarding the LDR solution, there's no LED going on when that relay closes.

 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13076
Re: 220VAC to Digital Input
« Reply #3 on: December 02, 2020, 02:32:58 pm »
I'd be interested in *where* you found a reference to clip-on current transformers being a possible fire hazard. 

Who said anything about needing an existing LED?  You buy an off-the-shelf mains indicator, preferably with a one piece plastic body, wire it across the load you need to monitor power to, glue the LDR to it and heatshrink over it.
 

Offline lmagalhaesTopic starter

  • Contributor
  • Posts: 43
  • Country: pt
Re: 220VAC to Digital Input
« Reply #4 on: December 02, 2020, 04:49:38 pm »
That's actually a great idea. But isn't there the same "system" but on a PCB mount ?
 

Offline homebrew

  • Frequent Contributor
  • **
  • Posts: 293
  • Country: ch
Re: 220VAC to Digital Input
« Reply #5 on: December 02, 2020, 05:21:52 pm »
I'd be interested in *where* you found a reference to clip-on current transformers being a possible fire hazard. 

Who said anything about needing an existing LED?  You buy an off-the-shelf mains indicator, preferably with a one piece plastic body, wire it across the load you need to monitor power to, glue the LDR to it and heatshrink over it.

Like maybe on Google? (First hit, search term: current transformer open circuit secondary)
https://voltage-disturbance.com/power-engineering/open-circuit-current-transformer-characteristics/
 

Offline bill_c

  • Regular Contributor
  • *
  • Posts: 132
  • Country: us
Re: 220VAC to Digital Input
« Reply #6 on: December 02, 2020, 05:31:31 pm »
I have used a capacitive divider with 120VAC and it works when done correctly, but that one you linked will turn on and off each cycle. You can solve that with hardware or software.
Why not use a small 240V relay coil in parallel with heater, contacts to micro?
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 2032
  • Country: dk
Re: 220VAC to Digital Input
« Reply #7 on: December 02, 2020, 05:46:59 pm »
I have used a wallwart and an Opto ... When i was in a hurry
 

Offline Gregg

  • Super Contributor
  • ***
  • Posts: 1140
  • Country: us
Re: 220VAC to Digital Input
« Reply #8 on: December 02, 2020, 06:16:36 pm »
There are AC current sensors available that operate dry contacts when current is sensed in the wire routed through the current transformers.  These are available in many configurations some with adjustable current values and self powered built in relays.  Here is an example from Veris Industries: https://www.veris.com/126822/category/current-monitoring I have used these with 480 volt systems and they have been totally reliable. 
Perhaps you can find similar available closer to you.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: 220VAC to Digital Input
« Reply #9 on: December 02, 2020, 06:29:05 pm »
You can use an ordinary optocoupler, the type with an LED and transistor in it. They even make ones that are meant for AC and have two back to back LEDs in them but this is not really necessary, you can filter the pulsating output either in hardware by using a capacitor, or just do the filtering in software (no pulses after x amount of time = power is off). You can use a capacitor or high value resistor to limit the current to the LED, and if you use a standard DC optocoupler put a diode or indicator LED anti-parallel across the optocoupler LED pins otherwise the high reverse voltage will damage it.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13076
Re: 220VAC to Digital Input
« Reply #10 on: December 02, 2020, 07:51:50 pm »
I'd be interested in *where* you found a reference to clip-on current transformers being a possible fire hazard. 

Who said anything about needing an existing LED?  You buy an off-the-shelf mains indicator, preferably with a one piece plastic body, wire it across the load you need to monitor power to, glue the LDR to it and heatshrink over it.

Like maybe on Google? (First hit, search term: current transformer open circuit secondary)
https://voltage-disturbance.com/power-engineering/open-circuit-current-transformer-characteristics/
Current transformers with an integral primary winding are known to be a potential fire risk under overload conditions as the fault current may grossly exceed the winding's ratings, however the energy that can be transferred to the secondary side of a small clip-on current transformer is limited by the small core's saturation, thus low ratio ones (e.g. 100:1 or lower) cant develop enough open circuit voltage to sustain an arc assuming reasonable terminal separation.  e.g. if the core area only is sufficient for a saturation voltage of 2V/turn (RMS), you will never see much over 300V peak across an open circuit 100:1 secondary.

For higher ratio ones its easy to mitigate the risk of the secondary arcing over if its burden resistor becomes disconnected by soldering a small low voltage bidirectional TVS diode directly across the secondary terminals.

You can use an ordinary optocoupler, the type with an LED and transistor in it. They even make ones that are meant for AC and have two back to back LEDs in them but this is not really necessary, you can filter the pulsating output either in hardware by using a capacitor, or just do the filtering in software (no pulses after x amount of time = power is off). You can use a capacitor or high value resistor to limit the current to the LED, and if you use a standard DC optocoupler put a diode or indicator LED anti-parallel across the optocoupler LED pins otherwise the high reverse voltage will damage it.

Dropper resistors for line-fed Optocouplers is one of the applications for which through hole resistors are still preferable.  Even so, assuming min. 200V rated 'commodity' resistors, its advisable to use two in series for 115V supplies and at least three for 230V operation.  If you *NEED* to use a SMD part, you'll need to select a long bodied part with sufficient voltage rating to withstand the peak mains voltage + transients, and its fairly likely you'll need a slot in the PCB under it to improve the creepage distance.
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 12380
  • Country: au
Re: 220VAC to Digital Input
« Reply #11 on: December 02, 2020, 11:03:45 pm »
I have used a wallwart and an Opto ... When i was in a hurry

I was going to say a small mains transformer with a low voltage, low current output (3V-5V and naff all current).  Isolation with an opto would be good.  If you wanted to throw in a more modern SMPS wall wart, then the opto becomes mandatory (in my book).

Cheap, easy and as safe as the wall wart allows.
 

Offline Ground_Loop

  • Frequent Contributor
  • **
  • Posts: 664
  • Country: us
Re: 220VAC to Digital Input
« Reply #12 on: December 03, 2020, 03:23:32 am »
Are you just looking at the on time and not heater current. If so, can't you just use a second relay contact to your controller to indicate that the heater is energized.
« Last Edit: December 03, 2020, 07:30:35 pm by Ground_Loop »
There's no point getting old if you don't have stories.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19918
  • Country: gb
  • 0999
Re: 220VAC to Digital Input
« Reply #13 on: December 03, 2020, 07:54:25 pm »
Why not use a small 240V relay coil in parallel with heater, contacts to micro?
Seconded. It beats messing around with opto-couplers, wallwarts, transformers etc. Most relays with mains coils will not have gold plated contacts so will require a certain minimum wetting current to ensure the contacts close properly. A quick way to fix this is to put a small capacitor across the contacts to provide a high current spike, when they close: 100nF will do.

https://uk.rs-online.com/web/p/non-latching-relays/6803937/
 

Offline SmallCog

  • Frequent Contributor
  • **
  • Posts: 307
  • Country: au
Re: 220VAC to Digital Input
« Reply #14 on: December 04, 2020, 02:05:39 am »
I'd whack a relay across it

If this isn't feasible, or you're not confident with mains wiring, you could look at something like this:



Nice simple non contact sensing of mains voltage specifically for arduino's
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17117
  • Country: us
  • DavidH
Re: 220VAC to Digital Input
« Reply #15 on: December 04, 2020, 02:02:38 pm »
I'd be interested in *where* you found a reference to clip-on current transformers being a possible fire hazard.

Current transformers are fire hazards if their load becomes disconnected; the high voltage produced on the secondary can arc causing a fire.  For this reason the load on the current transformer should include shunt protection.

But this is not much different than the threat of shorting a power transformer and it is not something that would ever stop me from using a current transformer.
« Last Edit: December 04, 2020, 02:04:56 pm by David Hess »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf