220VAC to Digital Input - Page 1
Forum section: electronics / beginners

author: lmagalhaes
author_rank: Contributor
timestamp: December 02, 2020, 11:43:57 am
content: 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...

author: Ian.M
author_rank: Super Contributor
timestamp: December 02, 2020, 11:59:17 am
content: 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/11005Read 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.

author: lmagalhaes
author_rank: Contributor
timestamp: December 02, 2020, 02:21:24 pm
content: 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.

author: Ian.M
author_rank: Super Contributor
timestamp: December 02, 2020, 02:32:58 pm
content: 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.

author: lmagalhaes
author_rank: Contributor
timestamp: December 02, 2020, 04:49:38 pm
content: That's actually a great idea. But isn't there the same "system" but on a PCB mount ?

author: homebrew
author_rank: Frequent Contributor
timestamp: December 02, 2020, 05:21:52 pm
content: Quote from: Ian.M on December 02, 2020, 02:32:58 pmLike maybe on Google? (First hit, search term: current transformer open circuit secondary)https://voltage-disturbance.com/power-engineering/open-circuit-current-transformer-characteristics/

author: bill_c
author_rank: Regular Contributor
timestamp: December 02, 2020, 05:31:31 pm
content: 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?

author: bingo600
author_rank: Super Contributor
timestamp: December 02, 2020, 05:46:59 pm
content: I have used a wallwart and an Opto ... When i was in a hurry

author: Gregg
author_rank: Super Contributor
timestamp: December 02, 2020, 06:16:36 pm
content: 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-monitoringI have used these with 480 volt systems and they have been totally reliable.Perhaps you can find similar available closer to you.

author: james_s
author_rank: Super Contributor
timestamp: December 02, 2020, 06:29:05 pm
content: 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.

author: Ian.M
author_rank: Super Contributor
timestamp: December 02, 2020, 07:51:50 pm
content: Quote from: homebrew on December 02, 2020, 05:21:52 pmCurrent 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.Quote from: james_s on December 02, 2020, 06:29:05 pmDropper 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.

author: Brumby
author_rank: Unknown
timestamp: December 02, 2020, 11:03:45 pm
content: Quote from: bingo600 on December 02, 2020, 05:46:59 pmI 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.

author: Ground_Loop
author_rank: Frequent Contributor
timestamp: December 03, 2020, 03:23:32 am
content: 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.

author: Zero999
author_rank: Super Contributor
timestamp: December 03, 2020, 07:54:25 pm
content: Quote from: bill_c on December 02, 2020, 05:31:31 pmSeconded. 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/

author: SmallCog
author_rank: Frequent Contributor
timestamp: December 04, 2020, 02:05:39 am
content: I'd whack a relay across itIf 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

author: David Hess
author_rank: Super Contributor
timestamp: December 04, 2020, 02:02:38 pm
content: Quote from: Ian.M on December 02, 2020, 02:32:58 pmCurrent 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.