596  Electronics Introduction and Calculators

596.1 Learning Objectives

By the end of this section, you will be able to:

  • Understand Semiconductors: Explain conductors, insulators, and semiconductors
  • Differentiate N-type and P-type: Understand doping and semiconductor types
  • Explain Diodes: Understand one-way current flow and applications
  • Compare Transistor Types: Differentiate BJT and FET transistors
  • Design Switch Circuits: Use transistors as digital switches in IoT devices

Simple Analogy: Electronics as the Brain and Nerves

Think of an IoT device like a human body: - Electricity = blood flowing through veins (provides energy) - Electronics = brain and nervous system (controls what happens) - Transistors = neurons (make decisions: “fire” or “don’t fire”) - Circuits = neural pathways (connect sensors to actions)

Just as your brain decides “too hot → sweat” or “danger → run,” electronics decide “temperature > 75°F → turn on fan” or “motion detected → send alert.”

Why Electronics ≠ Electricity

Electrical Device Electronic Device Key Difference
Light bulb - flip switch → light on Smart bulb - phone command → chip decides → light on Electronics add intelligence
Fan - plug in → spins at fixed speed Smart fan - sensor reads temp → microcontroller adjusts speed Electronics react to sensors
Heater - always on when plugged in Smart thermostat - monitors temp → turns heater on/off automatically Electronics make decisions

The magic ingredient? Transistors - tiny electronic switches that can turn on/off millions of times per second, making all digital logic possible.

Key Building Blocks Explained

Component Simple Explanation Real-World IoT Example Why It Matters
Voltage (V) Electrical “pressure” pushing electrons 3.3V from ESP32 GPIO pin Too high voltage = fried components
Current (I) Flow of electrons (like water flow rate) LED draws 20mA Too much current = overheating
Resistance (R) Opposition to current flow 220Ω resistor limits LED current Prevents component damage
Ohm’s Law V = I × R (the fundamental relationship) V=3.3V, LED needs 20mA → R=3.3/0.02=165Ω → use 220Ω resistor Design every circuit with this
Diode One-way valve for electricity Prevents battery reverse polarity damage Protects expensive circuits
Transistor Electronic switch controlled by voltage/current ESP32 pin (3.3V) controls 12V motor via transistor Microcontrollers can’t directly drive high-power loads

Real Numbers: Why You Need Electronics Knowledge

Without Electronics Knowledge With Electronics Knowledge Impact
Connect LED directly to GPIO → LED or GPIO burns out Add 220Ω resistor → LED lights safely Prevent $20 ESP32 damage
Control relay with GPIO pin → GPIO pin damaged Use transistor switch → relay works perfectly Avoid 40mA relay coil damaging 12mA GPIO
Battery lasts 6 months → acceptable? Optimize with MOSFET load switching → 5 year battery life 10× improvement
Trial-and-error debugging (4 hours) Read datasheet, calculate voltages → fix in 15 minutes 16× faster debugging

The Most Important Electronics Concepts for IoT

  1. Transistors as Switches (90% of IoT usage):
    • Microcontroller GPIO can only provide 10-40mA
    • Motors, relays, high-power LEDs need 100mA to 10A
    • Transistor acts as electronically-controlled switch: small signal controls big load
    • Example: ESP32 (12mA) → Transistor → 1A LED strip
  2. Power vs Signal (Critical distinction):
    • Signal: 3.3V GPIO, I2C/SPI data lines (low current, logic levels)
    • Power: Motor supply, LED strips, actuators (high current, voltage can vary)
    • Never mix these! Use transistor to separate signal from power
  3. Current Limiting (Protect everything):
    • LEDs without resistors → burn out in seconds
    • Transistors without base resistors → damaged GPIO
    • Always calculate resistor values, don’t guess

Quick Self-Assessment

Before proceeding, can you answer these?

Question Beginner Answer You Should Know
“Can I connect a 5V sensor directly to ESP32 (3.3V)?” “Let me try…” ❌ “No! Need level shifter or voltage divider” ✓
“LED not lighting, what’s wrong?” “LED is broken” ❌ “Check: polarity? resistor value? voltage? current?” ✓
“How to control 12V motor with ESP32?” “Connect GPIO to motor wire” ❌ “Use transistor (MOSFET) as switch + flyback diode” ✓

If you got those right, you’re ready for this chapter. If not, read carefully and take notes!

Recommended Learning Path: 1. Start: Read this chapter (Electronics Fundamentals) - understand transistors 2. Foundation: Study Electricity - master Ohm’s Law and power calculations 3. Application: Sensor Circuits - connect real sensors 4. Practice: Sensor Labs - hands-on ESP32 projects

Electronics is like having a super-smart brain that can make decisions about electricity!

596.1.1 The Sensor Squad Adventure: The Traffic Controller

Max the Microcontroller was very proud of his special friend - a tiny switch called Terry the Transistor. “Terry can turn electricity on and off super fast!” Max explained. “Even faster than you can blink!”

One day, Sammy the Sensor detected that a room was getting too hot. “It’s 30 degrees! Too warm!” Sammy reported. Max thought quickly. “Terry, we need to turn on the cooling fan!” But the fan needed lots of electricity - way more than Max could provide by himself. Terry the Transistor said, “Don’t worry, Max! You just give me a tiny signal, and I’ll let the big electricity through to power the fan!”

Lila the LED watched in amazement as Terry worked. With just a whisper from Max (a tiny signal), Terry opened a big gate that let powerful electricity flow to the fan. “It’s like being a traffic controller!” Lila said. “A small hand signal can stop or start huge trucks!” Bella the Battery smiled. “That’s exactly right! Electronics are smart controllers. They use tiny signals to control big power - that’s why your tablet can play videos, your toys can talk, and smart homes can do amazing things!”

596.1.2 Key Words for Kids

Word What It Means
Electronics Smart parts that can control and direct electricity
Transistor A tiny switch that can turn electricity on/off really fast
Microcontroller A mini computer brain that makes decisions
Signal A message sent using electricity (like a secret code)
Chip A tiny piece with millions of transistors inside
Circuit Board A flat board where electronic parts connect together

596.1.3 Try This at Home!

Play the Transistor Game!

  1. One person is the “Microcontroller” (the boss who gives quiet commands)
  2. One person is the “Transistor” (the gatekeeper)
  3. Other people are “Electricity” waiting to get through

Rules: - The Microcontroller whispers “ON” or “OFF” to the Transistor - When the Transistor hears “ON,” they open their arms and let Electricity people walk through - When they hear “OFF,” they block the path with closed arms - The Electricity people can ONLY pass when the Transistor opens the gate!

What you learned: Just like in real electronics, a tiny command (whisper) controls whether big electricity (people) can flow through. That’s how transistors work in all your electronic devices!

596.2 Prerequisites

Before diving into this chapter, you should be familiar with:

  • Electricity Fundamentals: Understanding voltage, current, resistance, Ohm’s Law, and power calculations is critical for analyzing transistor circuits and calculating bias resistor values
  • Atomic Structure: Basic knowledge of atoms, electrons, protons, and electron shells helps you understand semiconductor physics, doping, and PN junctions
  • Circuit Analysis: Ability to read circuit diagrams and apply Kirchhoff’s laws for analyzing transistor switching and amplifier circuits
ImportantWhy Electronics Matters for IoT

Transistors are the foundation of all modern computing. Every microcontroller, sensor, and communication module in IoT contains billions of transistors. Understanding how they work is essential for IoT hardware design.

NoteKey Concepts
  • Semiconductor: Material with controllable conductivity between conductors and insulators; foundation of all electronics
  • Doping: Adding impurities to silicon to create N-type (excess electrons) or P-type (excess holes) semiconductors
  • Diode: Two-layer semiconductor (PN junction) allowing current flow in only one direction; forward bias conducts, reverse blocks
  • Transistor: Three-layer semiconductor acting as voltage/current-controlled switch or amplifier; building block of all digital logic
  • BJT (Bipolar Junction Transistor): Current-controlled device where small base current controls large collector-emitter current
  • FET (Field Effect Transistor): Voltage-controlled device where gate voltage controls drain-source current; nearly zero input current
NoteKey Takeaway

In one sentence: Every sensor circuit is a voltage divider, current source, or bridge–understanding these three patterns unlocks all sensor interfacing.

Remember this rule: ADC resolution is useless if your circuit noise exceeds one LSB–for a 12-bit ADC at 3.3V, one LSB is 0.8mV, so keep noise below that threshold.


596.3 🌱 Getting Started (For Beginners)

Tip👋 New to Electronics? Start Here!

This section is designed for beginners. If you’re already familiar with semiconductors, diodes, and transistors, feel free to skip to the technical sections below.

596.3.1 What is Electronics? (Simple Explanation)

Analogy: Think of electronics as the “brain and nervous system” of smart devices. While electricity is like the blood that flows through the body, electronics is the intelligent control system that decides when and where that blood should flow.

The key difference: - Electrical devices (light bulb, toaster, fan): Just use electricity—turn it on, it runs - Electronic devices (smartphone, laptop, IoT sensor): Actively control and manipulate electricity with transistors

596.3.2 Why Electronics is the Foundation of IoT

Every smart device contains billions of tiny electronic switches called transistors: - Your smartphone: ~10-15 billion transistors - ESP32 microcontroller: ~200 million transistors - Simple sensor chip: ~1-10 million transistors

What transistors do: - Act as tiny switches that turn on/off millions of times per second - Process data (0s and 1s are just transistors being OFF or ON) - Make decisions based on sensor inputs - Control when to send data over Wi-Fi/Bluetooth

Without transistors, there is no IoT. No sensors, no microcontrollers, no wireless communication—nothing.

596.3.3 Real-World Examples You Use Every Day

Device What the Electronics Do
Smart thermostat Transistors compare temperature sensor data to your setpoint, then switch the heater on/off
Motion sensor light Transistor amplifies tiny signal from PIR sensor, then switches LED driver circuit
Smartphone camera Millions of transistors process light sensor data to create your photo
Fitness tracker Transistors read heart rate sensor, process the signal, and send data via Bluetooth

596.3.4 Key Terms You’ll See

  • Semiconductor: A material (usually silicon) that can be controlled to conduct electricity or block it. The “magic material” that makes electronics possible.
  • Doping: Adding tiny amounts of impurities to silicon to control how it conducts electricity (N-type has extra electrons, P-type has “holes”).
  • Diode: A one-way valve for electricity. Current flows forward but is blocked backwards. Used for protection and power conversion.
  • Transistor: A tiny electronic switch controlled by voltage or current. The fundamental building block of ALL electronics.
  • PN Junction: The boundary between P-type and N-type semiconductors. This junction creates the “magic” that makes diodes and transistors work.

596.3.5 Prerequisites (What You Should Know)

Before diving into electronics, make sure you understand:

  • Voltage & Current: From the Electricity Fundamentals chapter
  • Ohm’s Law: V = I × R and how to calculate resistance
  • Atoms & Electrons: Electrons are negatively charged particles that flow in circuits
  • Basic Circuits: How to read simple circuit diagrams with resistors and power supplies

If these concepts are new, review the Electricity Fundamentals chapter first.

596.3.6 Quick Self-Check

Q: You want to control a high-power LED (1A current) with a microcontroller GPIO pin that can only supply 10mA. What electronic component would you use?

Click to see the answer A: Use a transistor (like a MOSFET or BJT). The transistor acts as an electronic switch: - The microcontroller’s small 10mA signal controls the transistor’s gate/base - The transistor switches the high-power 1A current from a separate power supply to the LED - This is how microcontrollers control motors, relays, and other high-power devices!

Ready to learn more? The sections below explain how semiconductors, diodes, and transistors actually work at the atomic level!

596.4 From Electricity to Electronics

Electronics is the study and application of devices that control electron flow using semiconductors.

While electrical devices (motors, heaters, lamps) just use current flow, electronic devices (computers, sensors, microcontrollers) actively control and manipulate current using semiconductors.

596.4.1 Analog to Digital Signal Flow in IoT Systems

One of the most critical electronics concepts for IoT is how analog sensor signals are converted to digital data:

Flowchart diagram

Flowchart diagram
Figure 596.1: Signal flow from physical phenomenon to wireless transmission in IoT systems. Physical events (temperature, light, pressure) are converted by sensor transducers into continuous analog voltages (0-3.3V), conditioned through amplification and filtering circuits, digitized by ADC converters into discrete binary values (10-16 bit resolution), processed by microcontrollers, and transmitted wirelessly. Orange nodes represent analog domain, teal nodes represent digital domain, with ADC as the critical bridge between continuous and discrete signal representations.

This layered variant emphasizes the domain boundaries between physical, analog, and digital realms, helping students understand where signal transformations occur and what challenges exist at each transition.

%% fig-cap: "IoT Signal Processing Domain Boundaries"
%% fig-alt: "Layered diagram showing three signal processing domains: Physical Domain (continuous real-world phenomena), Analog Domain (continuous electrical signals with noise challenges), and Digital Domain (discrete binary values with quantization). Each boundary shows the transformation type and key challenges: transducer at Physical-Analog boundary, ADC at Analog-Digital boundary. Annotations show typical values and error sources at each stage."

%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#ecf0f1', 'noteTextColor': '#2C3E50', 'noteBkgColor': '#fff3cd', 'textColor': '#2C3E50', 'fontSize': '16px'}}}%%

graph TB
    subgraph Physical["PHYSICAL DOMAIN"]
        P1["Real-World Phenomena<br/>Temperature: 25.3°C<br/>Light: 500 lux<br/>Pressure: 101.3 kPa"]
    end

    subgraph Analog["ANALOG DOMAIN"]
        A1["Continuous Signals<br/>Voltage: 0-3.3V<br/>Infinite resolution<br/>Subject to noise"]
        A2["Signal Conditioning<br/>Amplification<br/>Filtering<br/>Level shifting"]
    end

    subgraph Digital["DIGITAL DOMAIN"]
        D1["Discrete Values<br/>12-bit: 0-4095<br/>Finite resolution<br/>Noise immune"]
        D2["Processing & Storage<br/>Calibration<br/>Averaging<br/>Transmission"]
    end

    P1 -->|"Transducer<br/>(Converts energy)"| A1
    A1 --> A2
    A2 -->|"ADC<br/>(Samples & Quantizes)"| D1
    D1 --> D2

    Physical -.->|"Challenges:<br/>Sensor accuracy<br/>Linearity"| T1["Error: ±0.5°C"]
    Analog -.->|"Challenges:<br/>EMI noise<br/>Drift"| T2["Error: ±10mV"]
    Digital -.->|"Challenges:<br/>Quantization<br/>Aliasing"| T3["Error: ±1 LSB"]

    style P1 fill:#7F8C8D,stroke:#2C3E50,stroke-width:2px,color:#fff
    style A1 fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
    style A2 fill:#E67E22,stroke:#2C3E50,stroke-width:2px,color:#fff
    style D1 fill:#16A085,stroke:#2C3E50,stroke-width:2px,color:#fff
    style D2 fill:#2C3E50,stroke:#16A085,stroke-width:2px,color:#fff
    style T1 fill:#ecf0f1,stroke:#7F8C8D,stroke-width:1px,color:#2C3E50
    style T2 fill:#ecf0f1,stroke:#7F8C8D,stroke-width:1px,color:#2C3E50
    style T3 fill:#ecf0f1,stroke:#7F8C8D,stroke-width:1px,color:#2C3E50

Figure 596.2: Domain boundary view showing signal transformations and error sources at each processing stage.

Key Stages Explained:

  1. Physical → Sensor: Environmental changes (temperature rises from 20°C to 25°C) are converted to electrical signals
  2. Analog Signal: Continuous voltage proportional to physical quantity (e.g., 10mV per °C)
  3. Signal Conditioning: Amplify weak signals (µV → mV), filter noise, level shift to ADC input range
  4. ADC Conversion: Sample analog voltage at regular intervals, quantize to nearest digital value
  5. Digital Processing: Microcontroller applies calibration, averages readings, detects thresholds
  6. Wireless Transmission: Packaged data sent via communication protocol to cloud or gateway

Example - Temperature Sensor Chain: - NTC Thermistor: 10kΩ at 25°C → Voltage divider: 1.65V → Op-amp gain ×2: 3.3V → 12-bit ADC: 4095 → ESP32 converts to 25.2°C → MQTT publishes value


596.5 Interactive Electronics Calculators

Before diving into semiconductors, let’s master the practical calculations you’ll use daily in IoT development.

596.5.1 Ohm’s Law & Circuit Analysis Tool

Ohm’s Law (V = I × R) is the foundation of all circuit analysis. This interactive tool helps you calculate voltage, current, resistance, and power for your IoT circuits.

TipUsing the Ohm’s Law Calculator

Common IoT Applications:

1. LED Current Limiting: - Supply voltage - LED forward voltage = voltage across resistor - R = V_resistor / I_desired - Always use next higher standard resistor value

2. Pull-up/Pull-down Resistors: - Typical values: 10kΩ (low power), 4.7kΩ (faster switching), 1kΩ (strong pull) - Higher resistance = less current = longer battery life - Lower resistance = faster response time

3. Power Budget: - Calculate power for each component: P = V × I - Sum total power consumption - Verify power supply can handle total current - Check individual component power ratings (¼W, ½W, 1W resistors)

Standard Resistor Values (E12 series): 10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68, 82 (and multiples: ×10, ×100, ×1k, ×10k, ×100k)

596.5.2 LED Resistor Calculator

LEDs are everywhere in IoT - status indicators, displays, and debugging. This tool calculates the perfect current-limiting resistor.

596.5.3 Voltage Divider Calculator

Voltage dividers are essential for reading analog sensors and interfacing different voltage levels. This tool helps you design voltage dividers for IoT applications.

596.5.4 Battery Life Calculator

Understanding battery life is critical for IoT devices. This tool calculates runtime based on current consumption and sleep modes.

596.5.5 IoT Device Power Supply Architecture

Before optimizing battery life, understand how power flows through your IoT device:

Flowchart diagram

Flowchart diagram
Figure 596.3: IoT device power supply architecture showing complete power distribution from sources (battery, USB, solar) through power management (charger ICs, LDO regulators, buck converters, PMIC load switching) to device loads (microcontroller, wireless radio, sensors, actuators) with protection circuits (flyback diodes, TVS/Zener overvoltage protection, fuses). Orange nodes are power sources, navy nodes are power regulation, teal nodes are digital loads, gray nodes are high-power loads requiring transistor switches and protection circuits.

596.5.6 Alternative View: Power Source Selection Decision Tree

This decision tree helps IoT designers select the optimal power source based on deployment constraints. Rather than showing power flow, it guides through the critical questions that determine which power architecture is feasible for your application.

%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#7F8C8D', 'fontSize': '11px'}}}%%
flowchart TD
    START([IoT Power Design]) --> Q1{Mains power<br/>available?}

    Q1 -->|Yes| Q2{Size<br/>constraints?}
    Q1 -->|No| Q3{Outdoor with<br/>sunlight?}

    Q2 -->|Flexible| AC["AC/DC Adapter<br/>5-12V, unlimited power"]
    Q2 -->|Compact| USB["USB Power<br/>5V @ 2.4A max"]

    Q3 -->|Yes| Q4{Average current<br/>< 50mA?}
    Q3 -->|No| Q5{Deployment<br/>duration?}

    Q4 -->|Yes| SOLAR["Solar + Battery<br/>Self-sustaining"]
    Q4 -->|No| BATTERY_LARGE["Large Battery<br/>Regular replacement"]

    Q5 -->|< 1 year| BATTERY_AA["AA Alkaline<br/>2000mAh"]
    Q5 -->|1-5 years| BATTERY_LITHIUM["Lithium Primary<br/>Non-rechargeable"]
    Q5 -->|> 5 years| ENERGY_HARVEST["Energy Harvesting<br/>Thermoelectric, Vibration"]

    style START fill:#2C3E50,stroke:#16A085,color:#fff
    style AC fill:#16A085,stroke:#2C3E50,color:#fff
    style USB fill:#16A085,stroke:#2C3E50,color:#fff
    style SOLAR fill:#E67E22,stroke:#2C3E50,color:#fff
    style BATTERY_AA fill:#7F8C8D,stroke:#2C3E50,color:#fff
    style BATTERY_LITHIUM fill:#7F8C8D,stroke:#2C3E50,color:#fff
    style ENERGY_HARVEST fill:#7F8C8D,stroke:#2C3E50,color:#fff

Figure 596.4: Decision tree for selecting IoT power sources: Start with mains availability, consider size constraints and deployment location, then match battery chemistry to expected deployment duration. Solar is viable when average current is low enough for panel sizing. Energy harvesting suits long-term, maintenance-free installations.

Power Path Strategies:

  1. Linear Regulation (LDO): Simple, low noise, but inefficient
    • Use for: Microcontroller and sensitive analog sensors
    • Efficiency: 60-70% (Vout/Vin)
    • Example: 5V → 3.3V LDO wastes (5-3.3) × current as heat
  2. Switching Regulation (Buck Converter): Complex but efficient
    • Use for: Battery-powered devices, high current loads
    • Efficiency: 80-95% regardless of voltage difference
    • Example: 12V → 3.3V at 90% efficiency vs 27.5% for LDO
  3. Load Switching via PMIC: Gate power to unused peripherals
    • Use for: Sensors, radios not continuously needed
    • Savings: Eliminate standby current (often 100µA - 10mA per device)
    • Implementation: P-channel MOSFET controlled by MCU GPIO
  4. Direct Battery Connection: Bypass regulators when possible
    • Use for: High-power actuators (motors, solenoids)
    • Control: MOSFET switch from MCU GPIO
    • Protection: Flyback diode for inductive loads
TipBattery Life Optimization Strategies

1. Sleep Mode Selection: - Light sleep: 2mA, wake in <1ms, RAM preserved - Use for: Frequent wake-ups (<1 second intervals) - Deep sleep: 0.01mA, wake in 100ms, most RAM lost - Use for: Periodic monitoring (minutes to hours) - Hibernation: <0.001mA, wake in seconds, complete power down - Use for: Emergency backup, yearly wake-ups

2. Transmission Optimization: - Wi-Fi transmission: 200-300mA burst for 1-2 seconds - BLE advertising: 10-20mA for 10ms every 100ms-1s - LoRaWAN: 100-150mA for 50-500ms (spreading factor dependent) - Strategy: Collect 10-100 readings, transmit once vs transmit each reading

3. Real-World Targets: - Coin cell (CR2032): 0.02-0.05mA average → 1-3 years - AA batteries: 0.5-2mA average → 1-5 years - Rechargeable (daily charging): <100mA average → 20+ hours - Solar powered: Match average consumption to solar generation (typically 5-50mA)


596.6 What’s Next?

Continue to Conductors, Insulators, and Semiconductors to learn about semiconductor materials and the component building blocks of electronics.