Magnetism is the physical force of attraction or repulsion between objects, while electromagnetism is the specific phenomenon where an electrical current flowing through a conductor generates a controllable magnetic field. In practical electronics and electrical work, this isn't just abstract physics; it is the fundamental mechanism that allows us to convert electrical energy into mechanical motion (relays, motors) or transfer power without direct electrical contact (transformers). Understanding how current creates flux—and how that flux behaves when the current stops—is what separates parts-swappers from competent circuit designers.
The Core Mechanism: Current Creates Flux
When electrons move through a conductor, they generate a circular magnetic field perpendicular to the direction of flow, governed by Ampere's Law. A straight piece of 14 AWG THHN wire carrying 15A generates a magnetic field, but it is incredibly weak and dissipates rapidly with distance.
To make this useful, we coil the wire. Think of a straight wire like a single garden hose spraying water; the mist spreads out weakly in all directions. Coiling the wire is like bundling 100 hoses together pointing down the same pipe—the combined flow creates a concentrated, high-pressure stream through the center. This bundled 'stream' is the magnetic flux. When you insert a ferromagnetic core (like iron or electrical steel) into that coil, the core's atomic domains align with the field, multiplying the magnetic strength by thousands of times.
Where You Meet This in Practice
You interact with electromagnetism constantly on the bench and in the panel. Here is where it dictates your component choices:
- Relays and Contactors: An electromagnet pulls a mechanical armature to close high-current contacts. A standard 30A automotive relay typically requires 150 to 200 Ampere-turns to pull in the contacts reliably.
- Transformers: Alternating current in the primary winding creates a constantly expanding and collapsing magnetic field, which induces a voltage in the secondary winding. This is how your 120V mains steps down to 12V for your LED drivers.
- Inductors and Chokes: Components designed specifically to store energy in a magnetic field. They resist changes in current, making them essential for filtering noise in switching power supplies and buck converters.
- Brushless DC (BLDC) Motors: Instead of mechanical brushes, an ESC (Electronic Speed Controller) sequentially energizes stator electromagnets to pull the permanent magnet rotor around.
Worked Numeric Example: Sizing a Relay Coil Driver
Let's calculate the actual magnetic field strength inside a solenoid to see if it's enough to pull a heavy contactor, and expose a common math trap that catches beginners.
The Setup: You are winding a custom solenoid for a DIY magnetic lock. You wrap 500 turns of 24 AWG magnet wire around a 5 cm (0.05 m) long core. You plan to push 0.5A of DC current through it.
The Math:
The formula for magnetic field intensity (H) is $H = n imes I$, where $n$ is turns per meter.
$n = 500 / 0.05 = 10,000$ turns/meter.
$H = 10,000 imes 0.5A = 5,000$ Ampere-turns/meter.
To find the actual magnetic flux density ($B$, measured in Tesla), we multiply $H$ by the permeability of the core material ($\mu$).
The Trap:
If you use an air core, $B$ is a pathetic 0.006 Tesla. So, you swap in a soft iron core with a relative permeability ($\mu_r$) of 2,000. The textbook formula suggests your $B$-field is now $0.006 imes 2000 = 12.0$ Tesla.
The Reality:
Electrical steel and soft iron physically saturate at about 1.5 to 1.6 Tesla. Once the core hits 1.6T, all its atomic domains are aligned. Pushing more current won't increase the magnetic pull; it will only generate $I^2R$ heat in your copper wire. This is why industrial contactors use precisely engineered air gaps and specific steel alloys rather than just adding infinite turns of wire. For deeper mathematical modeling of solenoid limits, refer to the Georgia State University HyperPhysics database.
Real-World Scenario: The Flyback Diode Failure
Electromagnetism doesn't just affect the circuit while the current is flowing; it violently reacts when the current stops. Here is a classic bench failure that destroys microcontrollers.
- The Setup: You are driving a 12V DC Songle SRD-12VDC-SL-C relay using an ESP32 DevKit v1. Because the ESP32 GPIO can only source 40mA at 3.3V, you use an IRLZ44N logic-level MOSFET to switch the relay's ground path.
- The Numbers: The relay coil resistance is 400 ohms. Steady-state current is $I = 12V / 400\Omega = 30\text{ mA}$. The coil has an inductance of roughly 1.5 Henrys. The energy stored in the magnetic field is $E = 0.5 imes L imes I^2$, which equals 0.675 millijoules.
- The Outcome: Your code toggles the GPIO pin LOW, turning off the MOSFET. The current path is instantly broken. The magnetic field collapses in microseconds.
- What Went Wrong: Faraday's Law of Induction dictates that a collapsing magnetic field will induce a voltage to keep current flowing in the same direction. Because the MOSFet is now an open circuit (infinite resistance), the voltage spikes massively to overcome it. Without a flyback diode, the spike easily hits 80V to 100V. This exceeds the IRLZ44N's 55V drain-source breakdown rating, punching through the silicon. The 12V rail then back-feeds through the destroyed MOSFET into the ESP32's 3.3V GPIO pin, instantly frying the onboard AMS1117 voltage regulator.
The Fix: Always place a standard 1N4007 diode in reverse bias directly across the relay coil (cathode to +12V, anode to the MOSFET drain). When the field collapses, the diode provides a safe, low-resistance loop for the induced current to dissipate as heat. See this All About Circuits guide on inductive flyback for exact diode placement schematics.
Common Confusions: Flux, Density, and Inductance
People commonly confuse the magnetic properties of a circuit with its electrical resistance. Here is how to keep the terminology straight:
| Concept | Symbol & Unit | What It Actually Means | The Common Confusion |
|---|---|---|---|
| Magnetic Flux | $\Phi$ (Webers) | The total 'amount' of magnetic field passing through an area. | Confused with Flux Density. Flux is the total volume; density is the concentration. |
| Flux Density | $B$ (Tesla) | How tightly packed the flux lines are in a specific spot. | Often mistaken for total magnetic strength, ignoring the physical area of the core. |
| Inductance | $L$ (Henries) | A component's ability to store energy in a magnetic field. | Confused with Resistance. Resistance opposes steady current; Inductance opposes changes in current. |
Frequently Asked Questions
Q: Can I use a permanent magnet instead of an electromagnet to hold a relay closed?
A: You can use a 'latching relay' which uses a permanent magnet to hold the armature in place after a brief electromagnetic pulse moves it. However, you cannot use a permanent magnet to replace the coil entirely, because you cannot electronically 'turn off' a permanent magnet to release the contacts without adding a mechanical release mechanism.
Q: Does the direction of current (polarity) matter when wiring an AC contactor coil?
A: No. AC current reverses direction 50 or 60 times a second anyway. The magnetic field constantly flips polarity, but the physical attraction between the electromagnet and the steel armature remains pulling inward regardless of the field's direction. (Note: Polarity does matter for DC relay coils if they contain built-in flyback diodes or LED indicator circuits).
Q: Why do transformers hum?
A: This is called magnetostriction. When the alternating magnetic field aligns the domains in the transformer's steel laminations, the physical dimensions of the steel change by a microscopic fraction of a millimeter. This rapid expansion and contraction at 120Hz (twice the 60Hz AC line frequency) vibrates the air, creating the familiar 120Hz mains hum.






