I'm using an ATmega328P to contol 4 optoisolators via 2n3904 transistors. It works perfectly.

I want to eliminate the transistors if the Arduino can deliver the needed current to control them.

**It is a simple card SSR relay (with 4 outputs ) controlled by atmega328p.
**VCC 5V
**MOC3023 minimum current s 5mA
****Sorry! LEDs are red 3mm

Moc3023 datasheet LEDs datasheet

Four Triac controlled by atmega328p via MOC3023

  • 1
    \$\begingroup\$ So what did you find was a safe limit for the GPIO on the ATMega328P and what is your required current in the MOC3023. What is the ATMega328P operating voltage? Please capitalise properly for clarity. Welcome to EE.SE. \$\endgroup\$ – Transistor May 19 '20 at 18:15
  • \$\begingroup\$ Please add a schematic of your system, and provide a link to the manufacturer's datasheet for the optoisolators. \$\endgroup\$ – Elliot Alderson May 19 '20 at 18:25
  • \$\begingroup\$ 5 random phase opto-triacs... what are you building, a color organ? It may make sense to do that with directly DC supplied LEDs these days, not lightbulbs. \$\endgroup\$ – Chris Stratton May 19 '20 at 18:31
  • \$\begingroup\$ Atmega 328p voltage is 5V...and required current in the MOC3023 is 5mA \$\endgroup\$ – artCoding May 19 '20 at 18:32
  • 1
    \$\begingroup\$ electronics.stackexchange.com/questions/67092/… \$\endgroup\$ – Bruce Abbott May 19 '20 at 19:11

You need to provide at least 5mA to a 47Ω resistor, the visible LED, and the emitter in the optoisolator. The maximum forward voltage for the LED and optoisolator are specified as 2.2V and 1.15V, respectively, for a total of 3.35V. At 5mA you will also have about 0.25V across the resistor, so the maximum total voltage drop is about 3.6V.

If you are using an Arduino pin to sink current by pulling low then we need to look at the \$V_{OL}\$ specification for the ATmega. If we check the specification for the part, with a 5V supply, we see that it will sink at least 10mA while pulling down the output pin to 0.9V or less. So, it looks like the Arduino can indeed drive the optoisolator and LED. Will the LED be bright enough for you? It's hard to say. The LED manufacturer recommends 16mA to 18mA.

Now, what happens if the forward voltage of the LED and optoisolator are at their minimum values...will we be trying to sink too much current? The ATmega specifies a maximum pin current of 40mA. At 40mA we get about 2V across the resistor. The minimum voltage for the LED is specified as 1.8V but there is no minimum specified for the optoisolator. Let's say it is 1V. So now our total voltage drop is 4.8V, which means that the ATmega would need to be able to pull down to 0.2V will sinking 40mA. That doesn't look possible but the published specifications don't give us all of the information we need.

The bottom line is that it might work. But, the LEDs will not be as bright as if you used the transistor. There would also be some risk of drawing large currents through the ATmega, which will cause it to be warmer and introduce more switching noise on the ground lines. The safe approach is to keep the transistors, but you can try it if you want.

  • \$\begingroup\$ Sorry, I forget one thing ..with R47Ω LEDs have bright enough ; I replace it by 300Ω and LEDs-light become Ok as expected. \$\endgroup\$ – artCoding May 21 '20 at 13:31
  • \$\begingroup\$ Thank you ,Elliot Alderson for your detailed answer. \$\endgroup\$ – artCoding May 22 '20 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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