How to detect AC voltage (not measuring)

Hi.

I need to detect if AC is present for 4 channels. How to do that?

  1. I'll not use cell chargers to get 5v, since i'll use at least 4 of then and it's not cool to have 4 chargers just to detect AC.

  2. I don't need to measure voltage or current, just know if an interrupter is on or off

  3. I can't use interrupts or timming on Arduino, since i'm already doing a lot of time calculations and using timmer interrupts (for dimming and other function)

  4. I'm sure i must use optocoupler. But, since A/C has a 'zero' point, my program should count and detect this to know if AC still on or off. But, again: I can't use any interrupt or time counters anymore. I must just check if pin is LOW or HIGH.

  5. I'm thinking about this circuit (attached). The idea is to use H11AA1 instead of 4N25 (H111AA1 can work directly with 110v) and put a capacitor to 'hold' energy while sine is in 'zero-point'. Can this work? If so, what's the correct value for this capacitor? I've tried with 2 and 3 capacitor of 10nF/250V (poliester) each, but didn't make any difference on output.
    Even if there's a small delay while turning off interrupter, there's no problem. I just need to know when an interrupter on wall is turned on and when is off.

You can use a modified circuit to that.
Use the filter on the right hand side of the opto-isolators.
Trial and error can determine the capacitor size.
Add a load resistor for tuning the time constant.

Careful, AC can kill you!
.

Well, that circuit will not directly adapt to using a H11AA1. The preferred way of driving the AC opto-coupler is to use a mains AC-rated capacitor of something like 0.22 μF in series to control the current, and a 470 Ohm resistor also in series to limit the inrush current on first connection.

The output of the opto-coupler will then be switched on for most of the AC cycle, you could then put a capacitor of perhaps 1 μF across that to provide delay.

Alternatively, just poll regularly in your loop and consider the AC present if for 100 increments of millis(), it is present at least once. This most certainly does not require interrupts (other than those which already drive the millis() function).

1 Like

Paul__B:

Well, that circuit will not directly adapt to using a H11AA1. The preferred way of driving the AC opto-coupler is to use a mains AC-rated capacitor of something like 0.22 μF in series to control the current, and a 470 Ohm resistor also in series to limit the inrush current on first connection.

The output of the opto-coupler will then be switched on for most of the AC cycle, you could then put a capacitor of perhaps 1 μF across that to provide delay.

Alternatively, just poll regularly in your loop and consider the AC present if for 100 increments of millis(), it is present at least once. This most certainly does not require interrupts (other than those which already drive the millis() function).

Like this?

PS: how do I insert attached picture on post itself?


Given that you use the H11AA1 AC optocoupler and not the 4N25, and the output capacitor should be at least 100 nF, that would be right. An alternative is to use a bridge rectifier just before the 4N25.

Oh, and lose the silly ground wire.

jmaurin:
PS: how do I insert attached picture on post itself?

The attachment process was badly - and perversely, quite deliberately - broken on this forum a couple of years back. It is one of the persistent nuisances of attempting to work with the Arduino developers. In some browser configurations, the attachments cannot even be downloaded or displayed.

Nevertheless, if you make an attachment of a graphic, once posted, copy the link location of the attachment then modify (from the "More" link at bottom right) your post to insert it as an image using the "screen" icon.

Paul__B:


Given that you use the H11AA1 AC optocoupler and not the 4N25, and the output capacitor should be at least 100 nF, that would be right. An alternative is to use a bridge rectifier just before the 4N25.

Oh, and lose the silly ground wire.
The attachment process was badly - and perversely, quite deliberately - broken on this forum a couple of years back. It is one of the persistent nuisances of attempting to work with the Arduino developers. In some browser configurations, the attachments cannot even be downloaded or displayed.

Nevertheless, if you make an attachment of a graphic, once posted, copy the link location of the attachment then modify (from the "More" link at bottom right) your post to insert it as an image using the "screen" icon.

Tks!
I've made it to work! I'm using my first schema:

The modifications that I've made:
a) removed C1 from AC side of opto
b) Added an 47uF capacitor to DC side and using 5v to detect if opto is activate or note.

When AC is diconnected, I got level 1 on pin. When Ac is connected, I got level 0 on pin. It's working fine, without any problems and I can't even notice the 'delay' when switch AC from ON to Off (the time of caps discharge).

What is the voltage rating of your capacitor?

.

25v. I'm using just 5v.

This capacitor consumes energy while opto is not activated? This could be a problem? I mean, wast energy on this caps.

If your AC voltage is 120VRMS the peak value is 120X1.414=~170
Use an appropriate rated capacitor.
Maybe 200VDC

.

LarryD:

If your AC voltage is 120VRMS the peak value is 120X1.414=~170
Use an appropriate rated capacitor.
Maybe 200VDC

.

But this caps (C1) doesn't exist anymore. The caps that I'm using right now (47uF 25v) is on the DC side.

Well I guess we need to see the current schematic.

.

Since you think that phone chargers are "not cool", I assume you want to save at some point. If it is initial cost, the, well, there are pretty cheap ones. If it is standby power, then you should consider that your resistors also dissipate almost halve a Watt each.
We have discussed that recently in this thread: Power consumption of AC monitoring with optocoupler - General Electronics - Arduino Forum

I read somewhere that the hlk-pm01 has quite a low quiescent current, but I cannot find that anywhere. So you might still be able to go for the power source way. Of course, you would still have to implement the safety measures like fuses and varistors. Look into the thread I referred to.