0
\$\begingroup\$

I'm trying to power a small electromagnet using my Arduino Uno, but when I use the 5V pin, the current flow is not enough and the electromagnet ends up being a lot weaker than it is with a regular 1.5V AA battery. I thought it was a resistor issue at first but even using a potentiometer to completely drop resistance does not solve the problem.

Would using a transistor or a relay help in this case? Do you have any recommendations on which one I should use? Is there anything else I would need to ensure there's enough current flowing?

\$\endgroup\$
0
\$\begingroup\$

Arduinos are limited to a MAX of 40mA per I/O pin (20mA is the recommended). This would explain why your electromagnet wasn't powerful enough.

Sure, a transistor and relay would work to switch an electromagnet, but a simpler and cheaper implementation would be to just use a N-Channel MOSFET as a low side switch. The protection diode is still required.

Google "N-Channel Mosfet low side switch" or "mosfet used as low-side switch" and you'll find about a million tutorials on how to wire one up. As far as picking out a MOSFET, you'll need a TTL "Logic Level" mosfet, similar to the IRLZ44N.

\$\endgroup\$
  • \$\begingroup\$ I tried this without the protection diode and it seems to be working using a 9V battery! Only problem is that there seems to be a pretty significant current drop. As soon as the electromagnet is on I can measure around 160 mA but that quickly drops to <10 mA within minutes. Any idea why that could be? \$\endgroup\$ – Youmna Mar 8 at 22:39
0
\$\begingroup\$

Yes, that is exactly the solution. You need a transistor or relay. If you used a relay, you would still need to use a transistor since the MCU pin cannot supply enough current for a relay coil. See the scheamtic below. Your electromagnet is basically a relay coil too so if you want to use a transistor only just sub in your electromagnet into the relay coil.

If you want to use a relay, connect your electromagnet to the primary contacts of the relay. Don't forget to incldue the flyback diode since both the relay coil and electromagnet are inductive and so will produce a voltage spike when current is interrupted and this spike can burn out the transistor.

When current in an inductor decreases or is interrupted, the magnetic field collapses and the inductor dumps the energy in the magnetic field into producing a voltage to keep pushing the current to maintain the same current level. If it has to push the current very hard (i.e. through a newly opened switch) then the voltage will be very high.

Without more details about your electromagnet and current draw, we can't help you pick a relay or transistor. You can use either an NPN transistor or NMOS. The NPN is what is shown in the schematic and will require a properly sized base resistor. The NMOS does not require such a resistor.

https://www.petervis.com/Raspberry_PI/Driving_Relays_with_CMOS_and_TTL_Outputs/relay-driver-circuit-using-npn-transistor.gif

https://www.petervis.com/Raspberry_PI/Driving_Relays_with_CMOS_and_TTL_Outputs/Driving_Relays_with_CMOS_and_TTL_Outputs.html

https://www.petervis.com/Raspberry_PI/Driving_Relays_with_CMOS_and_TTL_Outputs/relay-driver-circuit-using-npn-transistor.gif

\$\endgroup\$
  • 1
    \$\begingroup\$ That's part of it in concept, but it probably won't work with a weak 2n222A. The other part is that the power needs to not come from the Arduino board, either. The solenoid needs its own connections back to a suitable high-current power supply, the Arduino should only be providing a control signal relative to a shared ground. \$\endgroup\$ – Chris Stratton Feb 25 at 23:31
  • \$\begingroup\$ Yes yes. Don't have the electromagnet current (or even the relay current if you use one) running through the arduino board. \$\endgroup\$ – Toor Feb 25 at 23:33

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.