In science, a magnet is a material or object that produces a magnetic field, exerting an invisible force that attracts ferromagnetic metals and pushes or pulls on moving electrical charges.

In a real circuit, a magnetic field is the physical mechanism that allows energy to cross an isolation barrier (like in a transformer), stores energy temporarily (in an inductor), or converts electrical energy into mechanical motion (in a relay or motor). Builders commonly confuse magnetic flux density (measured in Tesla or Gauss, representing the concentration of the field at a specific point) with total magnetic flux (measured in Webers, representing the total field passing through a given surface area).

The Core Science: How Magnetic Fields Interact with Electrons

When you place a conductor inside a magnetic field, nothing happens if both are perfectly still. The science of magnetism in electronics is entirely dependent on relative motion or changing field strength. This is the foundation of electromagnetism, governed by Faraday's Law of Induction.

If you move a magnet past a copper wire, the magnetic field forces the free electrons in the copper to drift, creating an electromotive force (EMF), or voltage. Conversely, if you force current through a wire, it generates its own magnetic field. This two-way street is why we can build both motors (electricity to motion) and generators (motion to electricity). The strength of this interaction depends on three variables: the number of wire turns in your coil, the strength of the magnet (its flux density), and the speed at which the magnetic field changes relative to the conductor.

The Math That Matters: Faraday’s Law and Induced Voltage

To design a pickup coil, a DIY wind turbine generator, or a shake-flashlight, you need to calculate the induced voltage. The formula is:

E = -N × (ΔΦ / Δt)

  • E = Induced voltage (Volts)
  • N = Number of turns in the coil
  • ΔΦ = Change in magnetic flux (Webers)
  • Δt = Time it takes for the change to occur (Seconds)

The negative sign represents Lenz’s Law, which simply states that the induced voltage will create a current whose magnetic field opposes the original change. For calculating raw voltage magnitude, we can ignore the sign.

Worked Numeric Example: DIY Generator Coil

Let’s say you are building a simple hand-crank generator using a strong neodymium magnet and a custom-wound coil.

  • Coil: You wind 200 turns of 24 AWG magnet wire.
  • Magnet: You use an N42 grade neodymium disc with a surface flux density of 1.2 Tesla.
  • Area: The coil has a cross-sectional area of 0.0005 m² (roughly 2.5 cm in diameter).
  • Time: You crank the handle so the magnet passes completely through the coil's field in 0.05 seconds.

First, calculate the total magnetic flux (Φ):
Φ = B × Area = 1.2 T × 0.0005 m² = 0.0006 Webers

Next, plug the values into Faraday’s equation:
E = 200 × (0.0006 Wb / 0.05 s)
E = 200 × 0.012

Result: The peak induced voltage is 2.4 Volts.

If you need 5V to charge a USB power bank, you now know exactly what to change: you must either double your coil turns to 400, spin the crank twice as fast (Δt = 0.025s), or use a larger coil area to capture more flux. You can verify these physical relationships further via the Faraday's Law reference on HyperPhysics.

Where You Meet Magnetism in Practical Circuits

You don't need to be building a generator to deal with magnetic fields. They are hiding in plain sight on your workbench and inside your walls.

1. Inductors and Chokes (Energy Storage)

An inductor is just a coil of wire that uses its own self-generated magnetic field to resist changes in current. When current flows, energy is stored in the magnetic field (E = ½ L I²). When the circuit opens, the collapsing magnetic field induces a massive voltage spike to keep the current moving. This is exactly how a boost converter steps up 3.3V from an ESP32 to 12V for a sensor, and it is why you must always place a flyback diode across a relay coil to protect your transistors from that collapsing field.

2. Relays and Contactors (Mechanical Actuation)

A standard 12V automotive relay contains an electromagnet. When you apply 12V to the coil (typically drawing 30mA to 70mA), it generates a magnetic field of roughly 50 to 100 milliTesla. This field pulls a steel armature against a spring, physically closing the high-current contacts. The magnetic field provides the crucial galvanic isolation between your low-voltage microcontroller logic and the 120V/240V mains load.

3. Brushless DC (BLDC) Motors

In a modern drone or CNC spindle, permanent neodymium magnets are glued to the rotor (the spinning bell). The stator contains the copper coils. An Electronic Speed Controller (ESC) sequentially energizes the stator coils, creating a rotating magnetic field that drags the permanent magnets along. The timing of this field reversal is critical; if the ESC misreads the rotor position, the magnetic fields fight each other, resulting in a stuttering motor and potentially burned MOSFETs.

Decision Tree: Picking the Right Magnetic Sensor for Your Build

When your project requires detecting a magnet—whether for a door alarm, a tachometer, or a current sensor—choosing the wrong component leads to jittery readings or fried logic boards. Use this decision matrix to select the right technology.

Application Scenario Speed / Environment Best Technology Concrete Part Pick
Door/window security alarm (simple open/close) Low speed, battery-powered, needs zero standby current Reed Switch (Passive mechanical) Meder Electronic MK-25 Reed Switch
High-speed RPM tachometer or BLDC commutation High frequency (kHz), solid-state reliability required Digital Hall Effect Sensor (Open-drain output) Allegro A3144 Hall Switch
Measuring DC current without breaking the circuit Continuous analog monitoring, bidirectional current Hall Effect Current Sensor IC Allegro ACS724 (30A bidirectional)
Proximity sensing, joystick position, or fluid level Requires distance/proportional measurement, not just on/off Linear (Analog) Hall Effect Sensor Honeywell SS49E Linear Sensor
The Default Recommendation: If you are building a general-purpose Arduino or ESP32 project and need to detect the presence, speed, or proximity of a magnet, default to the Honeywell SS49E linear Hall effect sensor paired with a 10mm N42 neodymium disc magnet. The SS49E costs under $0.80 per unit, operates from 2.7V to 6.5V (making it safe for 3.3V logic without level shifters), and outputs a clean analog voltage that scales linearly with the magnetic field strength. Unlike the A3144, which only gives you a harsh digital 'snap' on/off, the SS49E allows you to write code that measures exactly how far away the magnet is.

Edge Cases: Demagnetization and Shielding

Before you finalize your BOM, you must account for two physical limitations of magnets in electronic environments: heat and interference.

The Curie Temperature Trap

Permanent magnets are not permanent if they get too hot. Every magnetic material has a Curie temperature—the point at which thermal agitation completely randomizes the magnetic domains, destroying the field. For standard N42 neodymium magnets, the maximum operating temperature is typically 80°C (176°F). If you mount an N42 magnet directly to the stator of a high-power motor or near a TO-220 voltage regulator without thermal management, it will permanently lose its magnetization. For high-heat environments, you must specify Samarium Cobalt (SmCo) magnets, which survive up to 300°C, though they cost roughly 3x to 5x more per unit.

Magnetic Shielding with Mu-Metal

If you are designing a sensitive analog front-end (like an audio preamp or a high-resolution ADC for a load cell), stray magnetic fields from nearby transformers or switching power supplies can induce 50/60Hz hum in your traces. Standard aluminum enclosures do absolutely nothing to block low-frequency magnetic fields. To shield sensitive circuitry, you must use Mu-metal (a nickel-iron soft magnetic alloy). Mu-metal has extremely high magnetic permeability, meaning it absorbs and redirects magnetic field lines around your sensitive components rather than letting them pass through. You can find Mu-metal foil sheets from suppliers like Magnetic Shield Corporation for roughly $40 to $60 per square foot, which is usually enough to line a project enclosure.

For standardized definitions of the Tesla and Weber units used in these calculations, refer to the NIST Guide to the SI. If you are integrating Hall sensors into a commercial PCB, review the Texas Instruments Hall Effect Sensor design guidelines for layout best practices regarding trace routing and decoupling capacitors.