Electronics Fundamentals

Table of Contents


Ohm's Law

The fundamental relationship between voltage, current, and resistance:

V = I × R

Basic Parameters

Parameter Symbol Unit Water Analogy
Voltage V Volts (V) Water pressure pushing through pipes
Current I Amperes (A) Water flow rate (liters/second)
Resistance R Ohms (Ω) Pipe narrowness or blockage

Understanding Current

Definition: 1 Ampere = 1 Coulomb per second

Where: 1 Coulomb = 6.242 × 10¹⁸ electrons

Example: If 1A flows through a wire, about 6.242 quintillion electrons pass through every second!

Practical Examples

Example 1: LED Circuit
- Voltage: 5V
- Resistance: 220Ω
- Current: I = V/R = 5/220 = 0.023A = 23mA

Example 2: Finding Resistance
- Voltage: 12V
- Current: 0.5A
- Resistance: R = V/I = 12/0.5 = 24Ω

Voltage Divider

A circuit that uses resistors in series to reduce a larger input voltage to a smaller output voltage.

Formula

Vout = Vin × (R2 / (R1 + R2))

Circuit Diagram

Vin ──┬──[R1]──┬── Vout
      │        │
     GND      [R2]
              │
             GND

Key Principles

  1. Output voltage is always a fraction of input voltage
  2. If R1 = R2, then Vout = Vin/2 (half the input voltage)
  3. Larger R2 relative to R1 → Higher output voltage
  4. Larger R1 relative to R2 → Lower output voltage
  5. Voltage divides proportionally based on resistance ratios

Examples

Example 1: Equal Resistors
Vin = 10V, R1 = 10kΩ, R2 = 10kΩ
Vout = 10 × (10/(10+10)) = 10 × 0.5 = 5V

Example 2: 3.3V from 5V
Vin = 5V, R1 = 1.7kΩ, R2 = 3.3kΩ
Vout = 5 × (3.3/(1.7+3.3)) = 5 × 0.66 = 3.3V

Example 3: Reading Battery Voltage
For a 12V battery with ESP32 (max 3.3V input):
R1 = 10kΩ, R2 = 3.9kΩ
Vout = 12 × (3.9/(10+3.9)) = 3.36V ✓

Power and Energy

Power (Watts)

Definition: Rate at which energy is transferred or converted

Power (P) = Energy / Time
Power (P) = Voltage (V) × Current (I)

Unit: Watts (W) - 1 Watt = 1 Joule per second

Examples

  • 10W LED: Converts 10 joules of electrical energy into light every second
  • 5W Phone Charger: Delivers up to 5 joules per second to charge battery
  • 100W Light Bulb: Consumes 100 joules of energy every second

Energy (Joules)

Definition: Total work done or energy transferred

Analogy: - Power (Watts) = How fast trucks deliver cargo (boxes per minute) - Energy (Joules) = Total cargo delivered (total number of boxes)

Practical Example: Phone Charging

Phone battery stores: 50,000 joules
Charger power: 5W (5 joules/second)
Time to charge: 50,000 ÷ 5 = 10,000 seconds = 2.8 hours

Power Calculations

Example 1: LED Strip
Voltage: 12V, Current: 1.5A
Power = 12 × 1.5 = 18W

Example 2: Motor
Voltage: 5V, Current: 0.8A
Power = 5 × 0.8 = 4W

Example 3: Energy Consumption
100W bulb running for 10 hours:
Energy = 100W × 10h = 1000Wh = 1kWh

Communication Protocols

Comparison Table

Feature UART I2C SPI
Full Name Universal Asynchronous Receiver-Transmitter Inter-Integrated Circuit Serial Peripheral Interface
Pins 2 (TX, RX) 2 (SDA, SCL) 4 (MISO, MOSI, CS, CLK)
Speed 115,200 baud (typical) 400 kHz (fast mode) Up to 10 Mbps
Type Asynchronous Synchronous Synchronous
Devices 1-to-1 Multiple (addressable) Multiple (chip select)
Wires Separate TX/RX Shared bus Separate MISO/MOSI
Complexity Simple Medium Complex

UART (Serial Communication)

Common Uses: GPS modules, GSM modules, Bluetooth modules, serial debugging

Pins: - TX (Transmit): Sends data - RX (Receive): Receives data

Configuration: Baud rate must match on both devices (9600, 115200, etc.)

I2C (Inter-Integrated Circuit)

Common Uses: OLED displays, sensors (temperature, accelerometer), EEPROMs

Pins: - SDA (Serial Data): Bidirectional data line for transferring data between master and slave - SCL (Serial Clock): Clock line controlled by master to synchronize data transfer

Advantages: - Only 2 wires needed - Multiple devices on same bus (up to 127 devices) - Each device has unique address

Typical Speeds: - Standard mode: 100 kHz - Fast mode: 400 kHz - Fast mode plus: 1 MHz - High-speed mode: 3.4 MHz

SPI (Serial Peripheral Interface)

Common Uses: SD cards, TFT displays, high-speed sensors, flash memory

Pins: - MOSI (Master Out Slave In): Data from master to slave - MISO (Master In Slave Out): Data from slave to master - CLK (Clock): Clock signal from master - CS (Chip Select): Selects which slave to communicate with

Advantages: - Very fast (10+ Mbps) - Full-duplex communication - Simple hardware interface


Linear Voltage Regulators (LDO)

LDO = Low Dropout Regulator

Converts higher input voltage to stable lower output voltage (e.g., 5V → 3.3V).

Evolution of LDO Technology

Generation 1 (1995-2000): Bipolar Technology

Popular ICs: LM1117, LM317, LM2596, 78xx series

Specifications (LM1117): - Output Current: 800 mA - Dropout Voltage: 1.2V (1200mV) - Input Voltage: Up to 15V - Quiescent Current (Iq): 5mA (5000µA) - Output Noise: 200µVrms

Equivalent ICs: - AMS1117 (Advanced Monolithic Systems) - LD1117 (STMicroelectronics) - NCP1117 (ON Semiconductor)

Pros: - ✅ Excellent for USB-powered devices (5V input) - ✅ Extremely cheap - ✅ Widely available

Cons: - ❌ High dropout voltage (1.2V) - ❌ Not suitable for LiPo/Li-ion batteries (4.2V max) - For 3.3V output: Need minimum 3.3V + 1.2V = 4.5V input - ❌ High quiescent current (5mA) - wastes power during sleep - ❌ High heat dissipation - ❌ High output noise

Generation 2 (2000-2010): CMOS Revolution

Popular ICs: XC6206, MCP1700, MP1584, MO2307

Specifications: - Quiescent Current (Iq): 1µA (5000× improvement!) - Dropout Voltage: 250mV - Output Current: 200mA - Battery Range: 3.25V to 6V

Key Improvement: Ultra-low quiescent current for battery-powered devices

Generation 3 (2010-Present): Performance Boost

Popular ICs: AP2112K, RT9013, TPS7A0233, MAX38903

Specifications: - Quiescent Current (Iq): 55µA - Dropout Voltage: 250mV - Output Current: 600mA - Output Noise: 50µVrms (4× improvement) - Battery Range: 3.25V to 6V - Features: Enable pin, soft-start, thermal protection

LDO Comparison for ESP32 Projects

LDO Model Manufacturer Current Iq Dropout Used In Notes
RT9080 Richtek 600mA 2µA 100mV SparkFun ESP32-C3/C6/S3 Dual rail
MIC5528 Microchip 500mA 55µA 275mV Adafruit Feather ESP32-S3 Widely used
AP2127K Diodes Inc 1A 55µA 280mV - High current
MAX38903 Analog Devices 300mA 5.5µA 140mV - Ultra-low Iq
TLV75533 Texas Instruments 500mA 19µA 305mV - Good balance
XC6220B Torex 1A 80µA 250mV Xiao C3 High current
RT9013 Richtek 500mA 20µA 240mV - Popular choice
MIC5504 Microchip 300mA 38µA 90mV - Low dropout
ME6211 Microne/Nanjing 300mA 40µA 100mV ESP32-C3 Super Mini Budget option
XC6206P Torex 200mA 1µA 250mV - Max battery life
MCP1700 Microchip 250mA 2µA 625mV - Ultra-low Iq

Note: Chinese dev kit manufacturers (Espressif, Seeedstudio, DFRobot, Waveshare) often use Chinese regulators like ME6211 and SGM2212 for cost savings.

Choosing the Right LDO

For Battery Life: Choose lowest Iq (XC6206P: 1µA, MCP1700: 2µA)

For High Current: Choose high current rating (AP2127K: 1A, XC6220B: 1A)

For Low Dropout: Choose low dropout voltage (RT9080: 100mV, ME6211: 100mV)

For Noise-Sensitive Applications: Choose low output noise (Gen 3 LDOs: ~50µVrms)


Transistors

Transistors act as switches or amplifiers - a small control signal can control a much larger current.

Types of Transistors

BJT (Bipolar Junction Transistor)

Types: NPN and PNP

Control Method: Current-controlled (requires base current to turn on)

Power Rating: Suitable for small power (100-200mA max)

Popular ICs: - 2N2222 (NPN, general purpose) - BC547 (NPN, low power) - BC557 (PNP, low power) - TIP120 (NPN Darlington, higher current)

Characteristics: - Less efficient (base draws current continuously) - Simpler to understand - Good for low-power applications

MOSFET (Metal-Oxide-Semiconductor Field-Effect Transistor)

Types: N-Channel and P-Channel

Control Method: Voltage-controlled (gate voltage controls current)

Power Rating: Can handle very high currents (up to 100A+)

Popular ICs: - IRLZ44N (N-channel, logic level) - IRF540N (N-channel, high current) - IRF520 (N-channel, moderate current) - IRLB8721 (N-channel, logic level, low Rds(on)) - IRF9540 (P-channel)

MOSFET Drivers: TC4420, TC4428, IR2113 (for high-speed switching)

Characteristics: - ✅ More efficient (gate doesn't draw current) - ✅ Suitable for high power devices - ✅ Fast switching speed - ✅ Lower heat generation

Note: "IR" stands for International Rectifier (American company, now part of Infineon)

Logic Level MOSFETs

Definition: Can be fully turned on with 3.3V or 5V gate voltage

Identification: Typically has "L" in model number (IRL series)

Examples: - IRLZ44N (55V, 47A) - IRL540N (100V, 28A) - 2N7000 (60V, 200mA, small signal)

Why Important: Standard MOSFETs require 10V+ gate voltage. Logic level MOSFETs work directly with microcontrollers (3.3V/5V GPIO).

BJT vs MOSFET Comparison

Feature BJT MOSFET
Control Current Voltage
Efficiency Lower Higher
Speed Slower Faster
Power Handling Low (100-200mA) High (up to 100A+)
Cost Cheaper Slightly more expensive
Best For Signal amplification Power switching

Recommendation: Use MOSFETs for most projects due to efficiency and power handling.


Relays

Definition: Electromechanical switches that use an electromagnet to control contacts

Key Features

  • Isolation: Electrical isolation between control circuit and load
  • AC/DC Load: Can switch both AC and DC loads
  • High Current: Handle high currents (10A+)
  • Audible Click: Physical feedback when switching

Common Uses

  • Controlling AC appliances (lights, fans, heaters)
  • High-power DC loads (motors, heaters)
  • Home automation
  • Industrial control systems

Relay Module Specifications

Typical Specs: - Control Voltage: 3.3V or 5V (for coil) - Load Voltage: 250V AC or 30V DC - Load Current: 10A (common) - Switching Time: 5-10ms

Note: Relay modules usually include: - Driver transistor - Flyback diode (protects against voltage spikes) - LED indicator

When to Use Relays vs MOSFETs

Use Relay Use MOSFET
AC loads DC loads only
Need complete isolation Same ground OK
Low switching frequency High-speed switching (PWM)
Very high voltage Moderate voltage

Connectors

JST Connectors

JST = Japan Solderless Terminal

Common types for LiPo/Li-ion batteries:

Type Pitch Common Use
JST-PH 2.0mm LiPo batteries (most common)
JST-XH 2.54mm Battery balance connectors
JST-SH 1.0mm Small electronics, sensors

JST-PH 2-Pin: Standard for single-cell LiPo batteries - Red wire: Positive (+) - Black wire: Negative (-)

Screw Terminals

Also Called: Block terminal connectors

Common Types: - KF128: 5.08mm pitch - KF301: 5.08mm pitch - KF350: 3.5mm pitch

Uses: - AC mains connections - High-current DC connections - Easily removable connections - No soldering required

Advantages: - Tool-free installation - Reusable - Secure connection - Accepts wide wire gauge range


IC Packages

IC packages protect fragile silicon chips and provide electrical connections.

Common Package Types

DIP (Dual In-Line Package)

Features: - Through-hole mounting - Pin spacing: 2.54mm (0.1") - Pins on two sides only - Easy to breadboard

Uses: - Prototyping - DIY projects - Education - Legacy designs

Examples: 555 timer, ATmega328P (Arduino Uno), L293D motor driver

Tip: Use IC sockets instead of soldering directly for easy replacement

SOP (Small Outline Package)

Features: - Surface mount (SMD) - Pin spacing: < 2.54mm - Pins on two sides - Smaller than DIP

Variants: - SOIC (Small Outline IC) - SSOP (Shrink Small Outline Package) - TSSOP (Thin Shrink Small Outline Package)

SOT (Small Outline Transistor)

Features: - SMD package for transistors and small ICs - 3 to 8 pins - Very compact

Common Types: - SOT-23 (3 pins): Small signal transistors - SOT-223: Voltage regulators (e.g., AMS1117) - SOD (Small Outline Diode): For diodes

QFP (Quad Flat Package)

Features: - Pins on all 4 sides - Pin spacing: 0.4mm to 1.0mm - Pins protrude outward (gull-wing leads) - Easy to solder with regular iron

Uses: - Microcontrollers - Complex ICs - Medium pin count (32-256 pins)

Examples: STM32 microcontrollers, ATmega2560

Advantages: - Hand-solderable - Visual inspection possible - Good for prototyping

QFN (Quad Flat No-leads)

Features: - Pins on all 4 sides - Pins do NOT protrude (flat contacts) - Exposed thermal pad underneath - Very compact

Uses: - Modern microcontrollers - RF modules - Power ICs

Examples: - RP2040 (Raspberry Pi Pico) - RP2350 (Raspberry Pi Pico 2) - ESP32 SoCs (all variants)

Thermal Pad Benefits: - Better heat dissipation to PCB - Improved electrical performance - Lower thermal resistance

Challenges: - Requires reflow soldering (hot air or oven) - Difficult to inspect solder joints - Not breadboard-friendly

BGA (Ball Grid Array)

Features: - Solder balls arranged in 2D grid underneath - No external pins visible - Highest pin density - Excellent electrical performance

Uses: - High-performance processors - FPGAs - Memory chips (RAM) - Complex SoCs

Examples: - Raspberry Pi SoC (BCM2711, BCM2712) - Smartphone processors - Graphics cards

Characteristics: - Requires professional reflow equipment - X-ray inspection for quality control - Not suitable for hand soldering - Best thermal performance

Package Comparison

Package Mounting Pin Count Hand Solder? Use Case
DIP Through-hole 8-40 Easy ✅ Prototyping, education
SOP SMD 8-28 Moderate General purpose
SOT SMD 3-8 Easy ✅ Transistors, small ICs
QFP SMD 32-256 Possible ✓ Microcontrollers
QFN SMD 16-100+ Difficult ⚠️ Modern MCUs, compact designs
BGA SMD 100-1000+ No ❌ High-performance processors

Power Supply and Batteries

Lithium Battery Comparison

Feature Lithium Polymer (LiPo) Lithium-Ion (Li-ion)
Electrolyte Solid polymer Liquid
Form Factor Flexible, any shape Rigid, typically cylindrical
Packaging Soft pouch Hard metal case
Cost More expensive Less expensive
Energy Density Lower Higher
Discharge Rate (C Rating) High (20C-100C+) Moderate (1C-10C)
Safety Can swell/puncture Safer with protection circuit
Best For Drones, RC, wearables Laptops, power tools, EVs
Popular Brands Turnigy, Tattu, Gens Ace Panasonic, Samsung, LG, Molicel

Voltage Characteristics

Both LiPo and Li-ion batteries use similar lithium-ion chemistry and have nearly identical voltage curves:

Voltage State Notes
4.2V Fully charged ⚠️ Don't exceed - damages battery life
4.0V ~90% charged Good stopping point for longevity
3.7V Nominal voltage Rating voltage
3.5V ~30% charged Safe operating range
3.3V ~10% charged Consider recharging soon
3.0V Discharged Flat - no more useful current
< 3.0V Over-discharged ⚠️ Permanent damage to battery

Discharge Curve

Voltage
4.2V  ●────────╮
      │        ╰──╮
3.7V  │           ╰────────╮
      │                    ╰──╮
3.0V  │                       ╰──●
      └────────────────────────────→ Time
      0%                       100%

Key Points: - Voltage stays relatively stable between 4.0V and 3.3V - Rapid voltage drop below 3.3V - Most useful capacity is between 4.0V and 3.3V

Battery Protection Circuit

LiPo cells typically include a Battery Management System (BMS) that prevents: - ⚠️ Overcharge (> 4.2V) - stops charging - ⚠️ Over-discharge (< 3.0V) - cuts off load - ⚠️ Overcurrent - protects from short circuits - ⚠️ Over-temperature - monitors battery temperature

Protection IC Location: Usually on the battery itself, under heat-shrink or pouch

C Rating

Definition: Rate at which a battery can safely charge or discharge

Formula:

Maximum Current = Capacity (Ah) × C Rating

C Rating Examples (10Ah Battery)

C Rating Current Duration Use Case
0.5C 5A 2 hours Slow charge, max battery life
1C 10A 1 hour Standard charge/discharge
2C 20A 30 minutes Fast discharge
5C 50A 12 minutes High-power applications
10C 100A 6 minutes Racing drones, RC cars
20C 200A 3 minutes High-performance racing

Practical Examples

Example 1: Drone Battery - Capacity: 2200mAh (2.2Ah) - C Rating: 25C - Max discharge: 2.2 × 25 = 55A - Good for high-power racing drones

Example 2: DIY Project - Capacity: 1000mAh (1Ah) - C Rating: 1C - Max discharge: 1 × 1 = 1A - Suitable for low-power microcontroller projects

Example 3: Power Bank - Capacity: 10000mAh (10Ah) - C Rating: 0.5C (typical) - Max discharge: 10 × 0.5 = 5A - Can charge phones and tablets

Battery Safety Tips

  1. ⚠️ Never over-discharge below 3.0V
  2. ⚠️ Never overcharge above 4.2V
  3. ⚠️ Use proper charger with balance charging for multi-cell
  4. ⚠️ Store at 3.7-3.8V for long-term storage
  5. ⚠️ Check for swelling - dispose if puffy
  6. ⚠️ Use fireproof bag when charging
  7. ⚠️ Don't puncture - can cause fire
  8. ⚠️ Monitor temperature - stop if hot

Calculating Runtime

Runtime (hours) = Battery Capacity (Ah) / Current Draw (A)

Example: ESP32 Project
- Battery: 2000mAh (2Ah)
- ESP32 current: 80mA (0.08A) average with WiFi
- Runtime: 2 / 0.08 = 25 hours

Quick Reference

Essential Formulas

Ohm's Law:        V = I × R
Power:            P = V × I
Voltage Divider:  Vout = Vin × (R2/(R1+R2))
Energy:           E = P × t
Battery Runtime:  t = Capacity / Current
C Rating:         Max Current = Capacity × C Rating

Voltage Levels

Voltage Common Use
1.8V Low-power sensors
3.3V Modern microcontrollers, ESP32, RP2040
5V USB, Arduino, sensors, relays
9V Battery-powered devices
12V LED strips, motors, automotive
24V Industrial, some LED strips
230V AC Mains (Europe/Asia)
120V AC Mains (North America)

Current Ratings (Typical)

Device Current
LED (3mm/5mm) 20mA
ESP32 (active WiFi) 160-260mA
ESP32 (deep sleep) 10µA
Raspberry Pi Pico 30-80mA
Arduino Nano 19mA
Servo motor (small) 100-300mA
Relay coil 70-90mA
OLED display (small) 15-30mA

Additional Resources

Happy building! ⚡🔧