After searching for a very long time for a 127v/220v (AC) sensor without using any kind of transformers, I found this very nice idea (image below): I'd like to understand how this module works because I'll have to replicate it in my project without actually using it. I can already tell what's the role of every component, except for both resistors. The first resistor (10k) is placed between the capacitor's legs and, therefore, I'm assuming it's just a bleeding resistor. Am I right? The second resistor (220k), between the AC source and the optocoupler, I have no clue. I was also thinking whether I can improve this sensor by adding a rectifier bridge between the AC source and the optocoupler, allowing me to use a smaller capacitor to normalize the signal. Does that make sense? Thanks!

  • 1
    there is basically no creepage separation on that board, do it better if you DIY. all you really need is an LDR forming half a voltage divider being illuminated by a current-limited AC-driven LED. The LDR's slower illumination response eliminates the need for AC smoothing, and the luminosity will scale to volts.
    – dandavis
    Commented Apr 12, 2017 at 18:38

1 Answer 1


The first resistor is working with the capacitor as an RC filter. Since you are sensing AC at 50~60Hz, you need this RC filter to get a constant output instead of a pulsed output. Remember your otpo-coupler has a LED (diode) inside, so it will only produce light when voltage is positive.

The second resistor is there to limit the current from your AC 220Vrms (which is 311V peak) so that is within the opto-coupler's LED forward current range. The voltage between your LED´s pins will always be it´s forward voltage (1.2V to 1.4V), so the resistor will bring down the 311V to 1.2 to 1.4V. Without this resistor, you would have 311V between the LED pins, and this would fry the poor thing.

The equivalent input circuit is something like this:


simulate this circuit – Schematic created using CircuitLab

Ok so how did they figure out the 220kOhms value?
First, take the worst case scenario: 220Vrms AC gives us 311Vpeak, and LED forward voltage is 1.2V.
So the voltage between the 311V and the diode is 311 - 1.2V = 309,8V

OHM Law: R = V/I (R=resistance, V=voltage, I=current)

In this case, the current chosen for the LED was about 1.4mA or 0.0014A, so R = 309.8V/0.0014A

R = 221k Ohms. The closest we get to this is 220kOhms

With 127Vrms (179.6Vpeak), your LED current will be: I = 178.4V/220000 = 811uA

I have simplified the calculations, because this is a simple case, but keep in mind that real life engineering calculations will be more complex than this.

  • 1
    keep in mind the top of a full AC wave is going to be higher voltage than the RMS
    – dandavis
    Commented Apr 12, 2017 at 18:36
  • yeah, I forgot the basics of the basics, LOL. Fixed, thanks.
    – cyberponk
    Commented Apr 12, 2017 at 18:50
  • the cap also raises the RMS, so the imrpoved figure looks closer to an IR led current
    – dandavis
    Commented Apr 12, 2017 at 18:57
  • Wow, that's a very comprehensive answer. Thanks! The moment you said "Remember your opto-coupler has a LED (diode) inside", I realized what the role of the 220k resistor was. I'm reading the Wikipedia page on "low-pass filters" right now to better understand the concept of the RC filter.
    – Vinicius
    Commented Apr 12, 2017 at 19:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.