Resistive vs capacitive dropper for 230V AC button sensing

Thread Starter

AleMonti

Joined Aug 11, 2024
30
Hi everyone,

I’m designing a circuit to sense up to four standard 230V/50Hz mechanical wall buttons using an RP2040. They are used to control the lights in a room so they won't see a lot of continuous use.
I’m debating between a resistive and a capacitive dropper to drive the optocouplers. I’m leaning toward the capacitive approach primarily to address contact wetting current, but I’d appreciate a sanity check on my design decisions, component choices and whether I’ve missed any critical safety components.

Option A: resistive dropper (4.5mA RMS)
Screenshot 2026-04-15 at 18.02.14.png
R2 FMP200JR-52-51K51kΩ 2W 500V flameproof


Option B: capacitive dropper (24mA RMS)
Screenshot 2026-04-15 at 18.02.25.png
C2 PX334K2C0702330nF X2 310VAC
R6 AS101AJ0102T4E1kΩ 1.5W 500V anti-surge
R4 RV1206FR-071ML1MΩ 500V

Thanks in advance!
 
Last edited:

Thread Starter

AleMonti

Joined Aug 11, 2024
30
Hello,

Where are your inputs coming from? There is no info on the voltage or anything like that which is needed to calculate just about anything.
They are 230VAC @ 50Hz (standard EU mains). The buttons are standard momentary wall switches. When pressed, the button connects the AC_BUTTON terminal to live. The AC_NEUTRAL terminal is permanently tied to the mains neutral rail.

I've edited the schematics in the first post to be more clear.
 
Last edited:

MrAl

Joined Jun 17, 2014
13,677
They are 230VAC @ 50Hz (standard EU mains). The buttons are standard momentary wall switches. When pressed, the button connects the AC_BUTTON terminal to live. The AC_NEUTRAL terminal is permanently tied to the mains neutral rail.

I've edited the schematics in the first post to be more clear.
Hi,

Oh that's good. Now can you describe the behavior of R6 when there is a 325ma surge, or a potential of 325v across it for a short time?

If R6 was a 1k resistor the surge current could be as high as 325ma and the opto LEDs may or may not be able to handle that. I would lower that myself. Optos usually take 20ma or more but i don't know about 325ma you could check the specs of the opto though, or figure out if R6 can limit it to a lower value like 40ma.

Is this just to detect buttons or does anything have to be synchronized to the line frequency?
If it is just buttons there's no reason to bang the opto LEDs with a high current. The highest current would come when the cap is charged in the opposite direction and the button is pressed, and that could lead to an even higher surge like 650ma in theory (without counting how much R6 limits the surge by presumably changing value). If the cap is discharged, the surge could be as high as 325ma at nominal line.

The reason you would so something like this is if you had to sync to the line frequency for some reason because then you would have to detect small voltages like 1 to maybe 10 volts. With a button detector you would only have to worry about low line voltage which means a much higher value of resistance for R6 at the least.
 

Thread Starter

AleMonti

Joined Aug 11, 2024
30
According to the datasheet, the PC814 has an absolute maximum forward current of 50mA and a peak forward current of 1A (100us pulse width). It should be fine I think. I can't really increase R6 further because it would dissipate too much power. 2kΩ is 1W and 10kΩ is almost 3W!

This is just to detect button presses. No need to sync the line frequency. The primary reasoning for the high current was to break though oxidation on the switch contacts, but maybe I'm worrying too much or there's better ways to deal with it.
 
Last edited:

MrAl

Joined Jun 17, 2014
13,677
According to the datasheet, the PC814 has an absolute maximum forward current of 50mA and a peak forward current of 1A (100uS pulse width). It should be fine I think. I can't really increase R6 further because it would dissipate too much power. 2kΩ is 1W and 10kΩ is almost 3W!

This is just to detect button presses. No need to sync the line frequency. The primary reasoning for the high current was to break though oxidation on the switch contacts, but maybe I'm worrying too much or there's better ways to deal with it.
Hello again,

Oh ok so you are shooting for 1/2 watt I guess, then using a higher power resistor. That part sounds good.
However, are you going after maybe 20ma rms for the opto LEDs ? You may not need that high, you might get by with 10ma for example. I did not look up the current transfer ratio of the 814 you can look into that and what your output circuit has to look like.

You can also look into rectification with a little filtering, and perhaps 1/2 wave operation.
 

AnalogKid

Joined Aug 1, 2013
12,077
For normal operation, the peak LED current in circuit #1 is 6.4 mA. I would stay with this circuit, but split R2 into two 24 K / 2 W resistors in series.

With a different opto, one with only one input LED, plus one diode and one resistor, you can cut the average power dissipation in half.

ak
 

Reloadron

Joined Jan 15, 2015
7,867
I would run with a resistive circuit. Looking at the data sheet Vfwd at 20 mA should be 1.2 volts. The opto will likely work fine with 10 mA fwd current. Anyway, I would be using a series resistor.

Ron
 

Thread Starter

AleMonti

Joined Aug 11, 2024
30
Anything greater than 2.3mA RMS is enough to drive the opto reliably, I've tested with 100kΩ now and it works just fine. The output signal is a pulse train rather than a square wave, but it doesn't really matter for detection.
I originally picked the PC814 (two leds) instead of the more common PC817 (one led) to have a 100Hz output signal, which I thought was better for latency etc. I could test with a PC817 and a reverse diode and see if I can feel differences in the latency/responsiveness of the detection. If not, I agree it would be a great way to halve power dissipation with the resistive dropper.

I'm not sure I have enough space on the board for two 2W series resistors per channel, but maybe one 3W resistor can fit. Button presses are infrequent and not on all channels at the same time, but I wouldn't want to risk setting things on fire if a button gets stuck or a heavy object is left leaning against it.

What was worrying me about the low current is oxidation of the button's contacts in the long run. What current should I aim for? Or how can this problem be avoided? Normally in industrial boards how is this problem solved?
 

Pyrex

Joined Feb 16, 2022
501
Modify the circuit a little :

R1 is thick film 1K, 1.5W , as you listed
R2 is 100 Ohm 0.2W
D1 is 5.1V 1W Zener, 2x 1N4733A or similar
Zener diodes will easily limit the current surge through the optocoupler .PS. I drew the diagram a little more nicely.AC presence indicat.png
 
Last edited:

drjohsmith

Joined Dec 13, 2021
1,571
Anything greater than 2.3mA RMS is enough to drive the opto reliably, I've tested with 100kΩ now and it works just fine. The output signal is a pulse train rather than a square wave, but it doesn't really matter for detection.
I originally picked the PC814 (two leds) instead of the more common PC817 (one led) to have a 100Hz output signal, which I thought was better for latency etc. I could test with a PC817 and a reverse diode and see if I can feel differences in the latency/responsiveness of the detection. If not, I agree it would be a great way to halve power dissipation with the resistive dropper.

I'm not sure I have enough space on the board for two 2W series resistors per channel, but maybe one 3W resistor can fit. Button presses are infrequent and not on all channels at the same time, but I wouldn't want to risk setting things on fire if a button gets stuck or a heavy object is left leaning against it.

What was worrying me about the low current is oxidation of the button's contacts in the long run. What current should I aim for? Or how can this problem be avoided? Normally in industrial boards how is this problem solved?
be carefull using resistor values based on meassuring one opto. they are incredably variable over PVT , so it might work now , but not over PVT or if you change a opto
 

MrAl

Joined Jun 17, 2014
13,677
I would run with a resistive circuit. Looking at the data sheet Vfwd at 20 mA should be 1.2 volts. The opto will likely work fine with 10 mA fwd current. Anyway, I would be using a series resistor.

Ron
Hi there Ron,

The reason they use capacitors with resistors rather than just resistors alone is to reduce power consumption in the resistive part. This is very typical in LED night lights.

You can compare the two quite easily by just calculating the power dissipation in the resistor, and assume that the dissipation in the cap is very low because it always is.
For example, say we want 10ma through the LED which is really two LEDs in antiparallel. Compared to the peak of a 230vac line 1.2v forward voltage is so low we can consider it to be zero for a simplified calculation.
For the resistor only solution, the current is:
iR=230/R

and we need 10ma so R comes out to 23000 Ohms.

The power in the resistor is:
pR=230^2/R which is 52900/R

and because we needed 10ma and came up with R=23000 that means the power pR comes out to 2.3 watts.
That does not sound like much, but the resistor can get pretty hot even a 5 watt ceramic.

Now let's add the capacitor in series and see what kind of resistor we can come up with.
First, the resistor now plays a different role: it limits the surge current mostly and only slightly limits the current. So for now we assume the resistor value will be relatively small and that means the cap does most of the current limiting.
So first calculating with the cap alone we have:
iC=230/zC
where zC is the impedance of the capacitor. To make a long story short, we get a current of 10ma when C=0.138uf.
With just the cap alone we limited the current to 10ma, and the cap does not dissipate much power so we just improved the efficiency by a lot. We went from 2.3 watts down to almost nothing, at least for the series element which limits current.
Now we add the resistor.
The steady state current is now:
iC=230/sqrt(R^2+1/(10000*pi^2*C^2))
and with our cap of 0.138uf we see we end up with:
iC=230.0/sqrt(R^2+5.32e8)
As a check, if we set R=0 we again get close to 10ma. We can also estimate this as:
ic=230/sqrt(R^2+5e8)
If we look at values of R=0 and R=10k we see that iC goes from about 9ma to about 10ma. That means, at first, values of R=0 to R=10k could be reasonable. So let's calculate the power in R next.

Obviously if R=0 we get no power in R, but R=0 does not help with surge current, which is the max current when the device is first plugged in. When the device is first plugged in, the max surge current is:
iSurge=230*sqrt(2)/R which is about 325/R.
If we want to limit the surge current to ten times the normal operating current, we need iSurge=100ma.
Solving that for 100ma we get:
R=3250 Ohms
That value is between 0 and 10k so we know we get at least 9ma which is close to 10ma.
The power calculation is a little more complicated here so I'll skip the formula. It comes out to approximately:
P=0.3 watts

So we went from 2.3 watts down to 0.3 watts, a significant decrease. That means much better efficiency and much less temperature rise.

That's the main idea behind using a cap and resistor rather than just a cap alone.
There is another issue that is usually addressed too though, and that is a bleed resistor for the cap. It can be as high as 10M Ohms sometimes.
The other issue is human safety. For this kind of circuit there is no isolation from line voltages, so it must be encased in a sturdy enclosure so no part of the circuit can be touched by a human.

A funny side story...
With some night lights the cap stays charged for a few seconds when it is unplugged. That means there is still some electrical energy left in the cap when it is unplugged. The funny thing is, if you short out the two plug contacts with your finger just after it is unplugged, the LED lights for a second before it goes out completely. You don't feel much in the finger either but the LED lights up. This might not work with every night light though it depends on several factors like what resistance they use for the bleeder resistor, or even if they have a more complicated circuit inside.
 
Last edited:

Thread Starter

AleMonti

Joined Aug 11, 2024
30
The reason they use capacitors with resistors rather than just resistors alone is to reduce power consumption in the resistive part.
Thanks for taking the time to write down the calculations, more or less this was the same thought process I had. For the power dissipation in the surge resistor, I was doing the calculation like this:
$$X_c=\frac{1}{2\pi \cdot 50Hz\cdot 330nF\cdot 10^{-9}}\approx 9.6kΩ\;\;\rightarrow\;\;I_{RMS}=\frac{230V}{\sqrt{1kΩ^2+9.6kΩ^2}}=23.8mA\;\;\rightarrow\;\;P_{R6}=I_{RMS}^2\cdot 1kΩ\approx 0.57W$$

be carefull using resistor values based on meassuring one opto. they are incredably variable over PVT , so it might work now , but not over PVT or if you change a opto
True, thanks for pointing this out. This also reminded me about ghosting issues. During testing with the 100kΩ resistive dropper, switching a fan on the same AC circuit was sometimes enough to briefly turn on the led and give false readings. I fixed in software by validating pulses only if they were spaced correctly so it shouldn't be an issue anymore.

If I understand correctly you are using the head to head zeners to clamp the led current to ~46mA during spikes. Looks great to me: it would mean that I can keep R6 (R1 in your drawing) small and use the spike to my advantage for clearing the oxidation, while limiting the peak current for the opto. What about using a TVS like the SMAJ5.0CA instead of the zeners?

I feel like this is the solution. I need to re-do calculations and optimise the values and parts, then figure out if it can fit on the space I have on the board... What do we think?
 

MrAl

Joined Jun 17, 2014
13,677
Thanks for taking the time to write down the calculations, more or less this was the same thought process I had. For the power dissipation in the surge resistor, I was doing the calculation like this:
$$X_c=\frac{1}{2\pi \cdot 50Hz\cdot 330nF\cdot 10^{-9}}\approx 9.6kΩ\;\;\rightarrow\;\;I_{RMS}=\frac{230V}{\sqrt{1kΩ^2+9.6kΩ^2}}=23.8mA\;\;\rightarrow\;\;P_{R6}=I_{RMS}^2\cdot 1kΩ\approx 0.57W$$


True, thanks for pointing this out. This also reminded me about ghosting issues. During testing with the 100kΩ resistive dropper, switching a fan on the same AC circuit was sometimes enough to briefly turn on the led and give false readings. I fixed in software by validating pulses only if they were spaced correctly so it shouldn't be an issue anymore.


If I understand correctly you are using the head to head zeners to clamp the led current to ~46mA during spikes. Looks great to me: it would mean that I can keep R6 (R1 in your drawing) small and use the spike to my advantage for clearing the oxidation, while limiting the peak current for the opto. What about using a TVS like the SMAJ5.0CA instead of the zeners?

I feel like this is the solution. I need to re-do calculations and optimise the values and parts, then figure out if it can fit on the space I have on the board... What do we think?
Hi,

I think the cap should be reduced and then the resistor can be increased slightly. The calculation I did gave me about 0.14uf and 3.2k so you might use 0.1uf or 0.22uf, or if you can get a 0.15uf if they make them.
That should ensure long life.
 

Pyrex

Joined Feb 16, 2022
501
Thanks for taking the time to write down the calculations, more or less this was the same thought process I had. For the power dissipation in the surge resistor, I was doing the calculation like this:
$$X_c=\frac{1}{2\pi \cdot 50Hz\cdot 330nF\cdot 10^{-9}}\approx 9.6kΩ\;\;\rightarrow\;\;I_{RMS}=\frac{230V}{\sqrt{1kΩ^2+9.6kΩ^2}}=23.8mA\;\;\rightarrow\;\;P_{R6}=I_{RMS}^2\cdot 1kΩ\approx 0.57W$$


True, thanks for pointing this out. This also reminded me about ghosting issues. During testing with the 100kΩ resistive dropper, switching a fan on the same AC circuit was sometimes enough to briefly turn on the led and give false readings. I fixed in software by validating pulses only if they were spaced correctly so it shouldn't be an issue anymore.


If I understand correctly you are using the head to head zeners to clamp the led current to ~46mA during spikes. Looks great to me: it would mean that I can keep R6 (R1 in your drawing) small and use the spike to my advantage for clearing the oxidation, while limiting the peak current for the opto. What about using a TVS like the SMAJ5.0CA instead of the zeners?

I feel like this is the solution. I need to re-do calculations and optimise the values and parts, then figure out if it can fit on the space I have on the board... What do we think?

Bidirectional TVS is a good choice.

It would be worth choosing R1 (R6) small enough to reduce its heating. On the other hand, this resistor must withstand the current surge at the moment of switching on
 

Thread Starter

AleMonti

Joined Aug 11, 2024
30
I've landed on these components and values:
Screenshot 2026-04-16 at 16.13.30.png

The 220nF dropper paired with a 390Ω surge resistor provides a total of 16mA RMS. With the 2.2kΩ shunt included for ghosting immunity, the opto receives 14mA nominal current. R5 dissipates only 0.1W, and 830mA of inrush should be effective for contact wetting. The TVS stays inactive during normal 5.6V peaks but clamps the led current to 25mA in case of surges.
How does it look? Now for the board, hopefully everything fits in the space I have with enough creepage.
 

drjohsmith

Joined Dec 13, 2021
1,571
I've landed on these components and values:
View attachment 366025

The 220nF dropper paired with a 390Ω surge resistor provides a total of 16mA RMS. With the 2.2kΩ shunt included for ghosting immunity, the opto receives 14mA nominal current. R5 dissipates only 0.1W, and 830mA of inrush should be effective for contact wetting. The TVS stays inactive during normal 5.6V peaks but clamps the led current to 25mA in case of surges.
How does it look? Now for the board, hopefully everything fits in the space I have with enough creepage.
fyi.
remember, everything nedds to be mains voltage rated .
so capacitors / resistors might normaly only see say 50v across them but they need be mains rated ,
 
Top