The fundamental equation for magnetic field generated by a long, straight, current-carrying wire is B = (μ₀ × I) / (2π × r). This formula, derived from Ampère's Circuital Law, allows electrical engineers, makers, and electricians to calculate the exact magnetic flux density at any given distance from a conductor. Whether you are designing an inductor, troubleshooting electromagnetic interference (EMI) on a PCB, or understanding how a non-contact clamp meter reads current without touching the copper, this single equation is your starting point.
The Core Equation and Realistic Magnitudes
Before plugging in numbers, you need an intuition for what the output actually means. Magnetic flux density (B) is measured in Teslas (T), but because a Tesla is a massive unit, practical electronics and wiring usually deal in microteslas (μT) or milliteslas (mT).
- Earth's Magnetic Field: ~25 to 65 μT (This is your baseline ambient noise).
- Standard Fridge Magnet: ~5,000 μT (5 mT).
- 10A Wire at 1 cm distance: ~200 μT (Easily detectable by a cheap Hall effect sensor).
- MRI Machine: 1,500,000 to 3,000,000 μT (1.5 to 3 T).
When you use the equation for magnetic field around a standard 12 AWG branch circuit wire carrying 15A, the field drops off rapidly. At 1 cm away, it is roughly 300 μT. At 10 cm away, it drops to 30 μT—barely distinguishable from the Earth's natural magnetic field. This inverse relationship with distance is why physical separation is the cheapest and most effective EMI shielding technique in PCB layout and panel wiring.
Symbol Definitions and Rearranged Forms
Every variable in the formula must be tracked in standard SI units. If you mix imperial or CGS units into this specific arrangement, your answer will be off by orders of magnitude.
| Symbol | Parameter | Standard SI Unit | Notes / Constants |
|---|---|---|---|
| B | Magnetic Flux Density | Tesla (T) | Often converted to μT (×10⁶) or Gauss (1 T = 10,000 G) |
| μ₀ | Vacuum Permeability | T·m/A or H/m | 4π × 10⁻⁷ (approx. 1.2566 × 10⁻⁶) |
| I | Current | Amperes (A) | Must be DC or instantaneous AC value |
| r | Radial Distance | Meters (m) | Distance from the center axis of the wire |
Rearranged Forms for Practical Problem Solving
You will rarely just solve for B. Here is how to rearrange the equation for magnetic field to solve for the other variables:
- Solving for Current (I):
I = (B × 2π × r) / μ₀
Use case: This is the exact physics governing how an AC clamp meter calculates current by measuring the magnetic field outside the insulation. - Solving for Distance (r):
r = (μ₀ × I) / (2π × B)
Use case: Calculating the minimum clearance required between a high-current busbar and a sensitive magnetometer or compass module on a custom PCB.
Assumptions, Boundaries, and Unit Traps
The equation for magnetic field presented above is an idealized model. According to NIST CODATA guidelines and standard electromagnetic theory, it relies on strict assumptions. If you violate them, the math breaks down.
Unit Mistakes That Break the Calculation
- The Centimeter Trap: The distance r must be in meters. If you measure 5 cm from the wire and plug "5" into the equation instead of "0.05", your calculated magnetic field will be 100 times too small.
- The Gauss vs. Tesla Confusion: Many hobbyist sensors (like the QMC5883L) output data in Gauss or milliGauss. The SI equation outputs Teslas. Remember: 1 Tesla = 10,000 Gauss. Failing to convert will result in catastrophic design errors.
- Ignoring the Medium: The constant μ₀ applies to a vacuum (and air, for practical purposes). If your wire is encased in a ferromagnetic material, or routed through a steel conduit, the permeability changes drastically (μ = μ₀ × μᵣ), amplifying the field and rendering the base equation invalid.
Worked Examples: From EV Chargers to Hall Sensors
Let's apply the formula with strict unit tracking to two common bench and jobsite scenarios.
Problem 1: EMI Clearance for a 20A EV Charger Cable
Scenario: You are routing a 20A DC fast-charger cable near a low-voltage data line. You need to know the magnetic flux density exactly 10 cm away from the center of the power cable to ensure it won't induce noise.
- Given: I = 20 A, r = 10 cm = 0.1 m, μ₀ = 4π × 10⁻⁷ T·m/A
- Formula: B = (μ₀ × I) / (2π × r)
Step-by-step derivation:
- Substitute the values: B = (4π × 10⁻⁷ × 20) / (2π × 0.1)
- Cancel out π from numerator and denominator: B = (4 × 10⁻⁷ × 20) / (2 × 0.1)
- Simplify numerator: 4 × 20 = 80 → 80 × 10⁻⁷
- Simplify denominator: 2 × 0.1 = 0.2
- Divide: (80 × 10⁻⁷) / 0.2 = 400 × 10⁻⁷ T
- Convert to standard scientific notation: 4.0 × 10⁻⁵ T
Final Answer: 40 μT. This is roughly equivalent to the Earth's magnetic field, meaning at 10 cm, the DC cable will not significantly interfere with standard unshielded data lines.
Problem 2: Saturated Hall Effect Sensor on an ESP32 Board
Scenario: You are building a custom current monitor using an ESP32 and a DRV5053 Hall effect sensor. The sensor saturates (maxes out) at 800 μT. The trace you are measuring carries a peak current of 2A. How far away must you place the sensor to avoid saturation?
- Given: B = 800 μT = 8 × 10⁻⁴ T, I = 2 A, μ₀ = 4π × 10⁻⁷ T·m/A
- Rearranged Formula: r = (μ₀ × I) / (2π × B)
Step-by-step derivation:
- Substitute values: r = (4π × 10⁻⁷ × 2) / (2π × 8 × 10⁻⁴)
- Cancel out 2π: r = (2 × 10⁻⁷ × 2) / (8 × 10⁻⁴)
- Simplify numerator: 4 × 10⁻⁷
- Divide: (4 × 10⁻⁷) / (8 × 10⁻⁴) = 0.5 × 10⁻³ m
- Convert to millimeters: 0.5 mm
Final Answer: 0.5 mm. If you place the sensor any closer than half a millimeter to the center of the trace, it will clip the reading. In PCB design, you would use a 1mm via clearance to provide a safety margin.
Frequently Asked Questions
How does the equation for magnetic field apply to AC circuits and RMS current?
The base equation calculates the instantaneous magnetic field. If you feed it an RMS AC current value (like 15A from a wall outlet), it will output the RMS magnetic field. However, the actual field is oscillating at 50Hz or 60Hz, crossing zero twice per cycle. If you are using a microcontroller to sample the field via an ADC, you must sample at least twice the AC frequency (Nyquist theorem) and calculate the peak or RMS values in software, rather than relying on a single DC snapshot.
Why does the equation for magnetic field yield zero when measuring a 2-conductor cable?
If you try to measure the magnetic field around a standard 12/2 NM-B (Romex) cable with a clamp meter, you will read zero. This is not a failure of the equation; it is a demonstration of superposition. The hot wire carries current in one direction, and the neutral wire carries the exact same current in the opposite direction. Because the wires are separated by only a few millimeters, their opposing magnetic fields cancel each other out almost perfectly at any distance greater than a few centimeters. To measure the field, you must separate the conductors or measure only one leg.
How does the equation for magnetic field change when calculating the center of a wire loop?
The straight-wire equation fails entirely for loops. For a single circular loop of wire, the geometry concentrates the field lines in the center. The equation changes to B = (μ₀ × I) / (2 × R), where R is the radius of the loop. Notice that the distance variable r is gone, replaced by the fixed radius R, and the π in the denominator is eliminated. If you stack multiple loops to form a coil, you multiply this result by the number of turns (N), which is the foundational principle behind electromagnets and relay coils.
What unit mistakes break the equation for magnetic field in practical DIY projects?
The most common fatal error in DIY projects is mixing CGS (Centimeter-Gram-Second) units with SI units. Older textbooks and some legacy magnetometer datasheets use Oersteds (Oe) for magnetic field strength and Gauss (G) for flux density. The equation provided here strictly requires SI units: Amperes, Meters, and Teslas. Furthermore, hobbyists often forget that the permeability of free space (μ₀) is a very small number (10⁻⁷). If your calculator drops the exponent and you just use "4π", your final answer will be off by a factor of ten million. Always use scientific notation on your calculator when working with μ₀.






