We have already obtained our result using transformer for our college project ,but can't find circuit to convert 230V sine wave into 5V square wave which is supplied to microcontroller.

Edit: Our team got this circuit from web,but not sure whether it can handle 230V main supply and generate 5V square wave. enter image description here

  • 3
    \$\begingroup\$ Keep on using the transformer if that gave you the result. \$\endgroup\$
    – Andy aka
    Oct 18, 2018 at 16:49
  • \$\begingroup\$ What are you asking for? An alternative circuit that does this without a transformer? \$\endgroup\$
    – Reinderien
    Oct 18, 2018 at 21:17
  • \$\begingroup\$ Actually we want to decrease the size and weight of circuit for our application that's why we need a alternative circuit without transformer \$\endgroup\$
    – sammy
    Oct 19, 2018 at 17:08

1 Answer 1


The other technique would be to use an optoisolator (with appropriate isolation barrier ratings) along with some current limiting resistor(s). For a nominal LED drive of 10-20mA drive you'd need about 24k-12k. Overall dissipation is about 2.2W-4.5W, which would get warm, but you can either get a power resistor, or share the load with multiple series/parallel combination resistors (make sure they can take the 230VAC range). Several things to watch for in terms of safety. Flameproof resistors are recommended, put a diode across the optoisolator LED terminals but anode to cathode, to prevent the LED from seeing too much of a reverse bias voltage on the other half of the AC waveform (improves reliability). MOV and PTC is nice to have for incoming transients and faults. Verify that the layout physically isolates the AC from the low voltage DC portion (creepage, etc.) You want to make sure that any fault will not cross over to the low voltage side.

  • \$\begingroup\$ You don't need 20mA LED drive current, there are optocouples out there which work nicely for this application at 2mA. It's not about speed, it's not about CTR accuracy, it's not about high CTR. \$\endgroup\$
    – Janka
    Oct 19, 2018 at 17:43
  • \$\begingroup\$ True, CPC1301 (eg) would work fine, price, availability can sometimes be a problem, but if this is a one-off design that won't matter; and it certainly reduces the dissipation issue. Only other issue is having margin for long term degradation of LED luminosity, but with a Darlington you won't have a problem. \$\endgroup\$
    – user201365
    Oct 20, 2018 at 4:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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