# Optimal LDA210 optocoupler circuit for mains detection

I am trying to sense mains with an ESP32. For that I plan to use this circuit:

I want to optimize the resistors from If current in order to lower the power (W) they use so they don't get hot.

According to the datasheet (page 43), the ESP32 has 45kΩ pull up resistors, so I was planning to use external 10kΩ to give it some margin.

I was trying to calculate what is the minimum If current I can use in order to use as little power as possible, to reduce waste and the resistors temperature since I will place this in a small PCB. Following this article, I searched for a high CTR bidirectional optocoupler (LDA210 datasheet) and tried to calculate the minimum If current needed:

Optocoupler datasheet params:

Minimum If current for typical CTR calculation

My concerns:
This looks too tiny current to me, but I cannot find in the optocoupler (LDA210) datasheet any minimum forward current. Am I missing something?
Is the Input Control Current the minimum Input current or affecting the equations in any way?

• In your previous question you had 4 Mohm at the 230 V AC side and I then mentioned that that would result in an extremely low current. I also made some suggestions on how to reduce the power dissipation. So explain why you are now suggesting even higher value resistors. My guess is that the current will be so low that the optocoupler will not work. Commented Nov 30, 2021 at 12:03
• @Bimpelrekkie, exactly, your comment made me wonder what would the optimal resistor be, and when I started calculating I got these values that look ridiculously low. The article uses 300k but it does not say where that value comes from. So I decided to post a question to find out where my calculations are wrong, or what concept I am missing. I tried with 1M ohms in total and it seems to work, but It might be just pure luck. Thanks a lot for your help!! :) Commented Nov 30, 2021 at 12:23
• The article uses 300k but it does not say where that value comes from. 230 V / 300 kohm = 0.76 mA which is a usable current for an opto coupler or a sensitive LED. Also 230 V * 0.76 mA = 170 mW which is low enough for a single 0.25 W resistor. Commented Nov 30, 2021 at 12:30
• Thanks! that is exactly what I don't know :) Is that 0.76 something that everybody knows empirically, or is it written anywhere? I will change my design accordingly! Commented Nov 30, 2021 at 12:32
• Is that 0.76 something that everybody knows empirically, or is it written anywhere? It is not that complex and it doesn't need to be 0.76 mA. You could use 1 mA with a 220 k ohm resistor, that would also work but at the cost of slightly higher power dissipation. Probably it is more like: someone used 300 k and that worked. That schematic was put on the internet for all to see. Many saw it and also used 300 k as that was proven to work. Commented Nov 30, 2021 at 12:57

I'd consider using a capacitor dropper in series with a resistor that limits excessive surge currents. That capacitor value is chosen so that it has the correct impedance to supply sufficient current at the lowest AC line voltage (with a little margin to spare). Assume that the series resistor is somewhere in the region of 3300 Ω.

I would also use a simulator to double check everything.

From the opto data sheet I'd be considering a nominal mid range input current of about 2 mA RMS as appropriate. From a subsequent comment: -

How did you get to "2mA RMS"? I can't find anything in the datasheet that gives me a hint on what to use.

Look at the graphs such as this one: -

.

The lowest led drive current is 0.5 mA and, that figure tallies with the maximum current transfer ratio graph (red mark ups by me): -

So, at your minimum supply voltage you should be aiming for between 0.5 mA and 1 mA. I added the RMS bit on the end to make it more convenient for any AC numbers you were considering. So, at maybe mid range voltages, 2 mA is about right. What you don't want to do is run on the rising slope of the CTR graph cause you'll get odd results at different voltages.

• Thanks @Andy! How did you get to "2mA RMS"? I can't find anything in the datasheet that gives me a hint on what to use. I will also look into the capacitor dropper Commented Nov 30, 2021 at 12:35
• Look at the graphs. Pretty much the lowest led drive current is 0.5 mA and that roughly tallies to the maximum current transfer ratio graph (maybe 1 mA for that graph). So, at your minimum supply voltage you should be aiming for between 0.5 mA and 1 mA. I added the RMS bit on the end to make it more convenient for any AC numbers you were considering. So, at maybe mid range voltages, 2 mA is about right. What you don't want to do is run on the rising slope of the CTR graph cause you'll get odd results at different voltages. Commented Nov 30, 2021 at 12:46

The LDA210 has Darlington outputs (your schematic symbol does not show this), so very small LED currents will indeed work. But if you design your circuit to trigger at 4 µA, it will be very sensitive to noise.

Please note that the typical CTR is not guaranteed; you have to use the minimum value of 300 %.

Also note that the CTR is guaranteed only for a forward current of 1 mA, and will go down for very small currents:

The maximum sensitivity is near 0.5 mA. Below about 0.1 mA, the CTR cannot be estimated from the graph, and the minimum might be well below 100 %, so you should avoid that.