← all lessons
DC Circuits · #2 of 48

Ohm's Law + Power

V = I × R, P = V × I

Why it matters

Ohm’s Law is the foundation of all electronics. Without it, you’re guessing. Power tells you if components will overheat and fail.

The idea

Ohm’s Law

The relationship between voltage (V), current (I), and resistance (R): V = I × R

flowchart LR
    V[Voltage V] -->|Ohm's Law| I[Current I]
    R[Resistance R] -->|Ohm's Law| I
    V -->|Power| P[Power P]
    I -->|Power| P

What It Means

Power

Power is energy per unit time: P = V × I

Real-World Example

ESP32 GPIO pin at 3.3V driving an LED with 220Ω resistor:

Demo

Adjust Voltage and Resistance to see how current and power change.

Watch for:

I: 3.30 mA P: 10.9 mW

Key takeaways

Going deeper

Ohm’s Law applies to linear (resistive) circuits. Diodes, transistors, and other non-linear components have more complex relationships. For DC circuits with resistors, Ohm’s Law is king.

Math details

Ohm's Law:
  V = I × R
  I = V / R
  R = V / I

Power:
  P = V × I
  P = I² × R  (substitute V = I×R)
  P = V² / R  (substitute I = V/R)

Example calculations:
  Given: V = 5V, R = 1000Ω
  I = 5V / 1000Ω = 0.005A = 5mA
  P = 5V × 0.005A = 0.025W = 25mW

Component ratings:
  Resistor: usually 0.25W (1/4W) or 0.5W (1/2W)
  LED: typically 20mA max current, ~0.1W power
  ESP32 GPIO: 40mA max source, 28mA max sink

Implementation

LLM Prompt: Current Calculator

Write a Rust function that calculates current and power given voltage and resistance.
Include safety checks: warn if current exceeds 40mA (ESP32 GPIO limit) or
if power exceeds 0.25W (common resistor rating). Return Result with error messages.

Lab Exercise

  1. Measure a 220Ω resistor with multimeter (should read ~220Ω)
  2. Connect LED + 220Ω resistor to 3.3V power supply
  3. Measure voltage across resistor (should be ~1.3V if LED drops 2V)
  4. Calculate current: I = V_resistor / R = 1.3V / 220Ω ≈ 5.9mA
  5. Verify LED is bright but not dim (if dim, resistor is too large)

full glossary →