Electromagnet not functioning

Hi,

I cannot get my electromagnet to turn on.

I followed this tutorial:
Controlling an Electromagnet Tutorial

These are the parts I am using:

  • ELEGOO UNO R3
  • 5V Electromagnet 25KG Holding F (3875 Adafruit Industries LLC)
  • 2N3904-AP Transistor
  • 1N4148 Diode
  • 22KΩ Resistor

Attached are images of the circuit diagram and my breadboard setup. The red wire is connected to 5V, the black wire is connected to GND, and the green wire is connected to digital pin 2. The blue wires connect to the electromagnet.

Here is my code:

int elecMag=2;

void setup() {
  // put your setup code here, to run once:

Serial.begin(9600);
pinMode(elecMag, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:

digitalWrite(elecMag, HIGH);
}

The only potential issue that I see is my electromagnet connection. This electromagnet has loose wires at the end, which I just stuck directly into the breadboard. I am not sure if this is the proper way to connect wires that don't have the little black clamps at the end, so please let me know if there is a better way to connect the electromagnet to the breadboard.

Other than the loose wire connection of my electromagnet, I cannot spot any issues. What I am doing wrong?

Thank you for your help!

Screen Shot 2021-01-07 at 11.30.02 AM.png

Screen Shot 2021-01-07 at 11.30.02 AM.png

What current does that electromagnet use? How much current can the 5 volt supply provide?
22 kOhm is bit too much. Try using 220 Ohm.

according to the datasheet for the electromagnet, it draws a current of 0.6 Amps at 5V. With some research, I found that powering the Arduino from a USB limits your total power consumption to 500mA, so I may need to connect an external power supply to get this to work.

I tried using a 220Ω resistor, but it still did not function.

The circuit is okey so it must be a power issue.
You could try a power bank that supply 1 Amp or more of output.

so I may need to connect an external power supply to get this to work.

Definitely.

The 2N3904 transistor can handle only 200 mA. It may have burned out internally with that electromagnet. Also, breadboards are for low power logic circuitry, and the tracks tend to burn with high currents used by motors, servos and electromagnets.

Use a logic level MOSFET instead, for example this one and for permanent installations, use a PCB, not a breadboard.

Did you forget to connect the grounds together. Lets try a simple experiment, remove the connection from the microcontroller and connect it to 5V. If the electromagnet works you have a software/microcontroller problem, if not you blew the transistor. Also the diode you are using appears to be too small, it must be able to handle the full current of the electromagnet for the flyback pulse. If it is blown you will constantly blow transistors. If you cycled it with the diode disconnected for any reason by-by transistor. If you can get a logic level avalanche protected MOSFET and substitute it for the transistor B-G, E-S, B-G. If you use an avalanche rated MOSFET you will not need the diode. When it works change the resistor to something in the 25-50 ohm range. NOTE: 600mA is 3X 200mA why would that transistor work in the first place.

The 1N4148 peak forward current = 450 mA.

Use a 1N4001 or similar.

Hi,
Welcome to the forum.

Do you have a DMM?
As has been noted in earlier posts, make sure the gnd of the UNO is connected to the Emitter of the transistor and the gnd of the 5V solenoid supply.

Tom... :slight_smile:

I would like to add two Karmas, but I can only do one.

  1. Code posted with code tags, and
  2. A real schematic- no Fritzing.

SteveMann:
I would like to add two Karmas, but I can only do one.

  1. Code posted with code tags, and
  2. A real schematic- no Fritzing.

Second added.....

Well that electromagnetic magnet tutorial website is a load of pants.

steve1001:
Well that electromagnetic magnet tutorial website is a load of pants.

Yes very "brief"...

Although it has been mentioned already, the 2N3904 will be destroyed when you try to pass 600mA, it is max rated for 200mA only. Either use the suggested MOSfet or a power Darlington transistor.

AJLElectronics:
Either use the suggested MOSfet or a power Darlington transistor.

Note, he said the electromagnet was 5 V.

Obsolete Darlingtons not suitable! :astonished:

Obsolete Darlingtons still have their uses. Especially when one's bits box features many of them.

AJLElectronics:
Obsolete Darlingtons still have their uses. Especially when one's bits box features many of them.

if there is a power supply giving 1 - 1.5 volt more than the load needs to compensate for voltage drop acrosd the transistor...

Railroader:
if there is a power supply giving 1 - 1.5 volt more than the load needs to compensate for voltage drop acrosd the transistor...

Can't argue with that of course.

Paul__B:
Note, he said the electromagnet was 5 V.

Obsolete Darlingtons not suitable! :astonished:

What. Wait. Are you saying they don't make darlington transistors anymore?
I mostly use TIP122s
Steve

jremington:
Use a logic level MOSFET instead, for example this one and for permanent installations, use a PCB, not a breadboard.

Thank you for your advice.
I tested the tracks with an LED, and thankfully they are not burned out. I will try a MOSFET and an external power supply.

gilshultz:
If you use an avalanche rated MOSFET you will not need the diode. When it works change the resistor to something in the 25-50 ohm range.

Thank you for your advice. I will try this out.