Electromagnetism is the physical interaction where an electric current flowing through a conductor generates a magnetic field, and a changing magnetic field induces an electric current. When you run DC through a straight wire, you get a weak circular magnetic field; coil that wire tightly around a ferromagnetic core, and you concentrate that field into a powerful, controllable force. This is not just abstract textbook physics—it is the foundational mechanism that allows makers and engineers to convert electrical energy into mechanical work (motors, relays) and store energy in magnetic fields (inductors, transformers).
What Electromagnetism Changes in a Real Circuit
When you introduce a coiled conductor into a circuit, electromagnetism fundamentally changes how the circuit handles current transitions by introducing inductance. An inductor fights any change in current flow. When current starts flowing, the expanding magnetic field absorbs energy, slowing the current rise. When you abruptly cut the power, the collapsing magnetic field dumps its stored energy back into the circuit to keep the current moving.
The Mechanical Analogy: Think of an inductor as a heavy mechanical flywheel. It takes significant effort (voltage) to get the flywheel spinning (current). Once it is spinning, it stores kinetic energy. If you suddenly jam a brake onto the flywheel shaft (opening a switch), the kinetic energy has nowhere to go, resulting in a violent mechanical shock. In a circuit, this shock manifests as a massive voltage spike known as back-EMF (electromotive force) or inductive kickback.
This collapsing-field voltage spike is the primary reason microcontrollers get bricked and MOSFETs explode when switching inductive loads without proper protection. The magnetic field does not care about your semiconductor's voltage ratings; it will generate whatever voltage is necessary to force the current across the air gap of an opening switch or through the silicon of a transistor.
Worked Numeric Example: The Inductive Kickback Problem
Let us look at a real-world scenario: you are using an ESP32 GPIO pin to drive the gate of an IRLZ44N logic-level MOSFET, which in turn switches a standard 12V Omron G5LE-14 relay.
- Coil Resistance (R): 400 Ω
- Coil Inductance (L): ~50 mH (0.050 Henries)
- Steady-State Current (I): 12V / 400 Ω = 30 mA (0.030 A)
While the relay is energized, energy is stored in the magnetic field of the coil. We calculate this using the inductor energy formula:
E = 0.5 × L × I²
E = 0.5 × 0.050 × (0.030)² = 22.5 μJ (microjoules)
When your ESP32 code pulls the MOSFET gate low, the transistor turns off in roughly 1 microsecond (1 μs). The magnetic field collapses, and the inductor tries to maintain that 30 mA of current. The induced voltage spike (V) is calculated by:
V = L × (di / dt)
V = 0.050 H × (0.030 A / 0.000001 s) = 1,500 Volts
That 1,500V spike will instantly punch through the IRLZ44N MOSFET's 55V drain-source breakdown limit, destroying the transistor. Worse, parasitic capacitance can couple that spike back into the ESP32's 3.3V GPIO rail, permanently frying the microcontroller. This is why a flyback diode is non-negotiable.
Where You Meet This in Practice
If you build anything that moves, clicks, or steps down voltage, you are relying on electromagnetism. Here is where it shows up on the workbench:
- Relays and Contactors: A low-power DC electromagnet pulls a ferromagnetic armature, closing heavy-duty mechanical contacts to switch high-voltage AC loads. The physical isolation between the coil and the contacts is what makes them safe for mains switching.
- Solenoid Valves: A coil generates a magnetic field that pulls a steel plunger upward against a spring, opening a fluid or gas path. Common in irrigation systems and pneumatics.
- Inductors and Chokes: Used in buck and boost converters (like the ubiquitous LM2596 modules) to store energy in a magnetic field and smooth out chopped DC into a steady output voltage.
- Transformers: Two coils share a magnetic core. AC current in the primary coil creates a constantly changing magnetic field, which induces a proportional AC voltage in the secondary coil via mutual inductance.
Bench Tip: When winding your own electromagnets or inductors, the core material matters immensely. Air cores handle high frequencies without losses but have low inductance. Ferrite cores are excellent for high-frequency switching power supplies, while laminated silicon steel cores are required for 50/60Hz mains transformers to prevent eddy current heating.
Common Confusions: Electromagnetism vs. Permanent Magnetism
Beginners frequently confuse electromagnetism with permanent magnetism (like a Neodymium N52 magnet) or electrostatics. Here is the functional difference for circuit design:
- Permanent Magnetism: The magnetic field is intrinsic to the material's aligned atomic domains. It requires zero external power to maintain the field. You cannot easily turn it off, which is why permanent magnet stepper motors exhibit "cogging torque" when unpowered.
- Electromagnetism: The field exists only while current flows (with the exception of latching relays, which use a permanent magnet to hold state after a brief pulse). You have precise, instant control over the field strength by varying the current.
- Electrostatics: Deals with stationary electric charges and electric fields (like a capacitor storing energy in a dielectric). Electromagnetism deals with moving charges (current) and magnetic fields. Capacitors fight changes in voltage; inductors fight changes in current.
Decision Path: Selecting Flyback Protection
Because electromagnetism guarantees an inductive kickback when a circuit opens, you must provide a safe path for the collapsing field's energy to dissipate. Use this decision matrix to select the exact protection component for your load.
| Application Scenario | Switching Frequency | Required Protection Type | Concrete Part Pick |
|---|---|---|---|
| Standard DC Relay or Solenoid (e.g., 12V/24V irrigation valve) | Low (< 10 Hz) | Standard Rectifier Diode (Cathode to VCC, Anode to Switch) | 1N4007 (1A, 1000V, slow recovery is fine here) |
| DC Motor or Solenoid driven by PWM for speed/force control | High (> 1 kHz) | Schottky Diode (Fast recovery to prevent shoot-through) | 1N5819 (1A, 40V, ultra-fast switching) |
| High-Current DC Contactor or large motor (> 5A) | Variable | Bidirectional TVS Diode (Clamps voltage instantly without shorting the coil) | SMBJ24CA (24V clamp, handles high joule transients) |
| AC Contactor (e.g., Schneider TeSys 120V/240V AC coil) | 50/60 Hz | RC Snubber Network (Diodes block AC; resistors/caps absorb the spike) | RM1S-230V Snubber Module or discrete 100Ω + 0.1μF X2 Cap |
Default Recommendation: If you are building a standard 12V DC hobby circuit switching a relay or solenoid with a microcontroller, default to a 1N4007 flyback diode placed in reverse bias across the coil. It costs pennies and prevents 90% of all inductive kickback failures on the bench.
Frequently Asked Questions
Does the right-hand rule apply to electron flow or conventional current?
The standard right-hand rule used in electrical engineering and physics applies to conventional current (positive to negative). If you are calculating magnetic field direction based on actual electron flow (negative to positive), you must use the left-hand rule. For all practical wiring and coil-winding purposes, stick to conventional current and the right-hand rule.
Can an electromagnet overheat if left on?
Yes. The coil is made of copper wire, which has resistance. Continuous DC current generates I²R heat. If the electromagnet is not rated for 100% duty cycle (like a starter motor solenoid or a cheap door lock actuator), leaving it energized will melt the enamel insulation on the wire, causing an internal short and ultimate failure. Always check the datasheet for duty cycle ratings.
Where can I read more about the physics of solenoids?
For deep-dive mathematical models of magnetic fields in coils, the Georgia State University HyperPhysics solenoid calculator is an excellent bench reference. For practical circuit transient analysis, All About Circuits provides a thorough breakdown of inductor discharge curves.






