Ac voltage - 817 optocoupler - Arduino

i want to monitor the state of some switches that are using ac voltage (48volt)
in my follow drawing i am sawing the 3 methods i used in order to achieve that (from first try until the third and final)

as you can see the best result i had it when i use the third circuit .

My question has to do with if that is the optional way (the right way to do) or are other methods to achieve that (Reading a ac voltage)

thanks in advance

Is this 48 V AC voltage 60 Hz?

48 V RMS = 48 x root2 = ~ 67.8 V effective.

First case:
It is not correct, because in the negative semicycle, the voltage on the PC817 led will be approximately 67.8 V, and it will burn out.
Datasheet informs: Reverse voltage V Max 6V.

Second case:

Current over the PC817 LED = 67.8V / 22 K = ~ 0.003 A = ~ 3 mA.
I think very little to sensitize the photo transistor.
Datasheet: Forward current mA Max: 50 mA.
I recommend ~ 25 mA.
= 67.8V / 0.025 = ~ 2K7. 2K7 resistor instead of 22K.
The output on the photo transistor will be pulsating at the frequency
of the input 48V.

Third case:

The difference with the second case is that
the output will be continuous due to the effect of the 1uF capacitor.

In all cases the output of the photo transistor is a little confusing.
Is there a need for this LED on the arduino port?

RV mineirin

1 Like

I'm pretty sure those "results" are simulations because the Arduino isn't synchronized with the AC frequency and that's not exactly what you're going to see. :wink:

Not really. As long as you read a high periodically (i.e. once per cycle) the AC is present. You simulation appears to only show the switch-on (voltage present) state.

In the 1st circuit the LED will be off half of the time so it won't appear as bright as the other circuits. BTW the LED will probably be too dim with a 10K series resistor. You might try 1K or you can go lower but I haven't checked the current capability of that opto-isolator.

You can get rid of the existing 1K series resistor and connect the Arduino directly to the opto-isolator.

I'd go with the "simplest solution" - You can put a reversed diode or LED in parallel with the opto-isolator input to protect it.

If you put an LED on the opto's input you can eliminate ALL of the circuitry on the output-side by enabling the Arduino's built-in pull-up resistor. You might have to find an example of how to wire it. With a pull-up instead of a pull-down the Arduino will read low when the opto turns-on so you'd have to reverse your software logic.

1 Like

thanks for the answer.
The AC is 50Hz

The led is present as i want to make this circuit to a pcb and want to have optical sign when the switch is on or off

thanks for the reply and your suggestions...

i will try to find how to synchronize my arduino to the 50Hz of my ac power in order to read the state of my switch without fluctuating based in ac periode


Don't need to go to that sort of trouble, just use the third circuit with the smoothing capacitor.
Just use an LED and resistor between the input pin and gnd, it will come on when the 48Vac is present.

Tom.... :grinning: :+1: :coffee: :australia:

1 Like

Fourth circuit - use a PC814.

However putting a LED indicator on the output side of the opto-isolator is generally a bad idea because the CTR may only be 1 (AKA 100%) or lower (Note the wide specs on the PC817!).

The opto-coupler should be close to the Arduino and connect between the input pin and ground using INPUT_PULLUP. No other component is necessary. If you still must add a LED (with a resistor), it goes from the pin to 5 V,

If you sample the output at no less than four times the mains frequency, you guarantee to detect presence of the mains within two samples.

There is enough voltage available that a bridge rectifier is not needed. Just a single diode, half wave rectifier, with a small smoothing capacitor will do the job nicely.

1 Like

thanks i will consider that solution for an other project

Thanks you.... i didnt know that there were optocouplers (814) for using them in ac .

That was what i need it to design my ciruit .

Thank again

It certainly makes the deign a lot simpler! :+1:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.