0
\$\begingroup\$

I have recently made an internet controlled switch with an arduino mkr1000 and the software part worked just fine. I'm new to electronics and i have a few questions for the wiring part. I have a opto-isolated relay module (datasheet) which have 2 power pins operating at 5V and 2 logic pins. I power both the relay and arduino separately with a 5V power supply and i've connected directly the logic wirings (mkr1000 work at 3.3V). I've tried putting a led for protection just because i had no other diodes but it seems it drains too much current and the relay does not work. I've searched on the internet but the aswers related on using a transistor and a diode consider using the same power supply, does a separate one change something? I got all the stuff working but is it safe to drive a relay like this? Do i have to add a diode or a transistor?

\$\endgroup\$
1
\$\begingroup\$

If the relay is already opto-isolated, you may very well not need any sort of diode for dumping the coil's stored energy. If you want an led for indication, simply put it in parallel with the data pin and ground with a resistor for current limiting.

The use of diodes for non-isolated relays is very important in preventing the coil from sending a voltage spike back to the chip when the signal is removed. as you energize the coil, current will begin to flow and the coil builds up a magnetic field. when you remove the voltage, the current can't stop instantly, and will build up a charge on the negative terminal of the coil (technically backwards because real charge is primarily provided by electrons which have a negative charge). if there is nowhere for this charge to go, it can build up a relatively large voltage (on what is supposed to be your ground pin). putting a diode across the coil so current can flow from the negative terminal to the positive terminal allows this the current to flow in a loop through the coil and the diode to dissipate more slowly. there will still be a voltage generated at the negative terminal, but it will be limited to the turn-on voltage of the diode.

for more information on relay protection diodes, see wikipedia...

\$\endgroup\$
  • \$\begingroup\$ thanks! Is there any risk that the relay is draining too much power from the arduino board and damaging it? \$\endgroup\$ – Giacomo Pasini Jan 20 '17 at 12:55
  • \$\begingroup\$ your datasheet specifies ~14ma on the input pin, so I'd assume it's fine, but going through the calculations is always a good idea. the datasheet for your relay board isn't very informative, but it kinda looks like there's already a resistor for the input pin on the board (effectively a resistor and diode in series on the input side). Arduino's and the like can usually supply at minimum 20ma and often up to 50ma from data pins \$\endgroup\$ – Aaron Jan 20 '17 at 14:57
  • \$\begingroup\$ Not the version of arduino i'm using unfortunately. It says it can supply 7mA. Is it completely bad to solder 2 wire from different data pins to reach 14 mA? \$\endgroup\$ – Giacomo Pasini Jan 21 '17 at 12:48
  • \$\begingroup\$ I'd use a transistor circuit for switching in that case.. I'm a big fan of Ben Krasnow He has an excellent youtube page and in particular a video on designing transistor switching circuits for microcontroller applications \$\endgroup\$ – Aaron Jan 23 '17 at 14:53

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.