8  Electronics Fundamentals

8.1 Learning Objectives

  • Explain how semiconductors, diodes, and transistors form the foundation of all IoT device hardware
  • Distinguish between conductors, insulators, and semiconductors and describe how doping creates N-type and P-type materials
  • Compare BJT and MOSFET transistors and determine which is appropriate for a given IoT switching or amplification task
  • Analyze transistor switching circuits for controlling high-power loads such as motors, relays, and LED strips from microcontroller GPIO pins
In 60 Seconds

Electronics is the study of controlling electron flow using semiconductors. This chapter covers conductors, insulators, semiconductors, diodes, and transistors (BJT and MOSFET) – the essential building blocks that enable every IoT microcontroller, sensor interface, and actuator control circuit.

Key Concepts
  • Semiconductor: A material with electrical conductivity between conductors and insulators; silicon is the most common; conductivity is controlled by temperature, light, and intentional doping; the foundation of all modern electronic components
  • P-N Junction Diode: The simplest semiconductor device; allows current in one direction (forward bias, > ~0.7 V for silicon) and blocks it in the other (reverse bias); the building block of LEDs, solar cells, transistors, and integrated circuits
  • BJT (Bipolar Junction Transistor): Three-terminal device (base, collector, emitter) using a small base current to control a much larger collector current; current amplification factor (hFE or beta) typically 50-500; used as amplifiers and digital switches
  • MOSFET: Voltage-controlled transistor using gate voltage to control drain current; N-channel MOSFET: gate voltage above threshold turns it on; near-zero gate current makes it easy to drive from microcontroller GPIO; preferred for power switching in IoT applications
  • Operational Amplifier (Op-Amp): A high-gain differential amplifier used with feedback resistors to implement precise amplification, filtering, and mathematical operations; ideal op-amp assumptions: infinite input impedance, zero output impedance, infinite open-loop gain
  • Integrated Circuit (IC): Thousands to billions of transistors, diodes, and resistors fabricated on a single silicon chip; enables complex functions (microcontrollers, ADCs, wireless modems) in small, low-cost packages
  • Capacitor Function: Stores charge proportional to applied voltage (Q = C x V); blocks DC while passing AC; used for power supply filtering, timing circuits, and signal coupling/decoupling; value in farads (F), commonly in nF and uF for IoT circuits
  • Inductor Function: Stores energy in a magnetic field; opposes changes in current (V = L x dI/dt); used in power converters (buck, boost), RF filters, and as the energy storage element in switching regulators

8.2 Overview

This chapter introduces electronics fundamentals essential for IoT development. Understanding semiconductors, transistors, and circuit design is critical for interfacing sensors, actuators, and microcontrollers.

Original Chapter: 16,747 words split into 5 focused sections.


8.3 Chapter Navigation

8.3.1 1. Electronics Introduction and Calculators

~3,450 words | Beginner

  • Learning objectives and prerequisites
  • Electronics vs electricity fundamentals
  • Interactive calculators (Ohm’s Law, LED resistor, voltage divider, battery life)
  • Power supply architecture and optimization strategies
  • Beginner-friendly explanations with real-world examples

Start here if you’re new to electronics or need practical calculation tools.


8.3.2 2. Conductors, Insulators, and Semiconductors

~3,150 words | Beginner

  • Material classification (conductors, insulators, semiconductors)
  • Electronic components taxonomy (passive, active, integrated circuits)
  • Component quick reference guide with IoT applications
  • Circuit patterns and selection guidelines
  • Real component examples with specifications

Key Topics: R, C, L components, voltage dividers, decoupling, current limiting, component ratings


8.3.3 3. Semiconductors, Doping, and Diodes

~5,100 words | Intermediate

  • Semiconductor physics and atomic structure
  • N-type and P-type doping mechanisms
  • PN junction operation
  • Diode types and applications
  • Forward and reverse bias characteristics
  • Knowledge checks and quizzes

Deep Dive: Understanding how semiconductors work at the atomic level enables better circuit design.


8.3.4 4. Transistor Selection Guide for IoT

~2,050 words | Intermediate

  • BJT vs MOSFET comparison
  • Transistor specifications (voltage rating, current rating, power dissipation)
  • Switching speed and gate drive requirements
  • Logic-level vs standard MOSFETs
  • Practical selection criteria for IoT projects

Practical Focus: Choose the right transistor for motors, relays, LED strips, and high-current loads.


8.3.5 5. Electronics Summary and Resources

~2,900 words | Beginner

  • Chapter summary and key takeaways
  • Common pitfalls (ESD damage, thermal drift)
  • Visual reference gallery
  • AI-generated figure galleries
  • Related chapters and further resources

Reference: Quick lookup for component symbols, troubleshooting, and design resources.


8.4 Learning Path Recommendation

Your Background Start Here Then Read
Complete beginner IntroductionConductors & Insulators Practice with calculators, then move to semiconductors
Some electronics knowledge Semiconductors & Doping Deep dive into theory, then apply with transistor selection
Need practical guidance Transistor Selection Guide Jump to component selection, refer back to theory as needed
Quick reference Summary & Resources Use visual galleries and component tables

8.5 How It Works: Building a Smart Light from Silicon

Let’s trace how electronics principles build a complete IoT device - a Wi-Fi-controlled LED light.

Step 1: Starting Material - Pure Silicon We begin with ultra-pure silicon (99.9999999% pure - “nine nines”). Silicon has 4 valence electrons, making it a semiconductor - not a great conductor, but not an insulator either.

Step 2: Doping Creates N-type and P-type Engineers add tiny amounts of impurities: - Phosphorus (5 valence electrons) → N-type silicon (extra electrons available) - Boron (3 valence electrons) → P-type silicon (missing electrons, creating “holes”)

Step 3: PN Junction = Diode Place N-type and P-type together → PN junction → a diode forms. Conventional current flows one way (from P-side anode to N-side cathode) but not the reverse. This becomes our power rectifier to convert AC wall power to DC.

Step 4: Three Layers = Transistor Add a third layer: - NPN transistor: N-type, thin P-type, N-type - Controls current flow with a tiny gate/base signal - Millions of these make our ESP32 microcontroller

Step 5: Building the Smart Light Circuit

Wall AC → Diode Rectifier → Voltage Regulator → ESP32 (millions of transistors)
                                 ↓                     ↓
                            Battery Backup       Wi-Fi Module (more transistors)
                                                       ↓
                                                  GPIO Output
                                                       ↓
                                              MOSFET (single transistor)
                                                       ↓
                                                  LED + Resistor

Component Breakdown:

  1. Diode bridge: 4 PN junctions convert AC to pulsing DC
  2. Capacitor: Smooths pulsing DC to steady DC
  3. Voltage regulator (contains many transistors): Drops 12V to 3.3V for ESP32
  4. ESP32 microcontroller: Millions of transistors executing code
  5. MOSFET driver (N-channel, 3 layers): Switches LED on/off from GPIO signal
  6. LED (another diode!): Emits light when forward-biased
  7. Current-limiting resistor: Protects LED from overcurrent

The Electronics Magic:

  • Diodes ensure current only flows the correct direction
  • Transistors in the ESP32 store your Wi-Fi settings in SRAM cells (each made of 6 transistors)
  • MOSFET switches the high-current LED (1A) using only the 3.3V GPIO voltage signal – essentially zero current drawn from the GPIO pin!
  • Capacitors smooth voltage ripples from the power supply

All from Doping Silicon: Every component except resistors and capacitors is made from doped silicon forming PN or NPN/PNP junctions. The entire difference between a diode, BJT, MOSFET, and microcontroller is just the arrangement and doping profile of silicon layers!

Key Insight: Electronics is applied semiconductor physics. Understanding PN junctions, doping, and transistor operation explains how millions of components work together to create intelligent devices from inert silicon.

8.6 Why This Chapter Matters for IoT

Critical Skills for IoT Development

Every IoT device relies on electronics:

  • Microcontrollers contain millions of transistors
  • Sensors require proper signal conditioning circuits
  • Actuators need transistor-based switching circuits
  • Power management depends on voltage regulators and MOSFETs
  • Wireless modules use RF electronics

Without understanding electronics, you cannot:

  • Interface sensors safely (risk of damage)
  • Control high-power loads (motors, relays, LED strips)
  • Optimize battery life (inefficient power circuits)
  • Debug hardware issues effectively

8.7 Prerequisites

Before starting, you should understand:

  • Electricity Fundamentals: Voltage, current, resistance, Ohm’s Law
  • Atomic Structure: Atoms, electrons, protons, electron shells
  • Circuit Analysis: Reading circuit diagrams, Kirchhoff’s laws

8.8 Incremental Example Set: Transistor Switching Circuits

8.8.1 Beginner Example: Switching an LED with NPN BJT

Scenario: Use an ESP32 GPIO pin (3.3V, max 12mA) to control a high-brightness LED that requires 100mA.

Components:

  • NPN transistor: 2N2222 (β = 100-300)
  • LED: Forward voltage = 2.0V, forward current = 100mA
  • Power supply: 5V

Circuit Design:

         5V
          │
         [LED Vf=2V]
          │
      Collector (C)
          │
   2N2222 NPN    ───> Current: 100mA
          │
      Emitter (E)
          │
         GND

GPIO (3.3V) ──[1kΩ]──> Base (B)

Calculations:

Using Ohm’s Law \(R = \frac{V}{I}\), with voltage across resistor = 5V - 2V (LED) - 0.2V (Vce(sat)) = 2.8V and desired current 100 mA: \(R = \frac{2.8V}{0.1A} = 28\Omega\). Worked example: With a 33Ω standard resistor, actual current is \(I = \frac{2.8V}{33\Omega} = 85\text{ mA}\), which is safe (below 100 mA max) and provides sufficient brightness. Note: The simplified calculation ignoring Vce(sat) gives 30Ω, which is also acceptable since a slightly higher resistance just means slightly less LED current.

  1. LED resistor (if needed above LED):
    • Voltage across resistor: 5V - 2V (LED drop) - 0.2V (Vce(sat)) = 2.8V
    • Current: 100mA
    • Resistor: R = 2.8V / 0.1A = 28Ω (use 33Ω standard for safety margin)
  2. Base resistor:
    • Required collector current: Ic = 100mA
    • Transistor gain (minimum): β = 100
    • Required base current: Ib = Ic / β = 100mA / 100 = 1mA
    • Add safety factor (2x): Ib = 2mA
    • Base voltage drop: Vbe = 0.7V
    • Resistor: R = (3.3V - 0.7V) / 2mA = 2.6V / 0.002A = 1.3kΩ (use 1kΩ)

Result: GPIO high → 2mA into base → 100mA through collector → LED lights at full brightness ✓


8.8.2 Intermediate Example: Switching a Relay with MOSFET

Scenario: Control a 12V relay (coil resistance = 400Ω, current = 30mA) to switch 240V AC mains power to a lamp.

Components:

  • N-channel MOSFET: 2N7000 (logic-level, Vgs(th) = 0.8-3.0V, typical 2.1V)
  • Relay: 12V coil, SPDT contacts rated 10A @ 250VAC
  • Flyback diode: 1N4001 (protects MOSFET from inductive kick)

Circuit Design:

         12V
          │
       [Relay Coil]
          │   ┌───────┐
          │   │1N4001 │ (flyback diode, cathode to +12V)
          └───┘       │
          │           │
      Drain (D)  <────┘
          │
   2N7000 MOSFET
          │
      Source (S)
          │
         GND

GPIO (3.3V) ──[100Ω]──> Gate (G)
                │
              [10kΩ] Pull-down
                │
               GND

Why MOSFET instead of BJT?:

  • MOSFET gate current: ~0µA (vs 2mA for BJT)
  • Lower power dissipation: Rds(on) = 5Ω → P = I²R = (0.03)² × 5 = 4.5mW
  • BJT would dissipate: Vce(sat) × Ic = 0.2V × 30mA = 6mW (comparable, but BJT wastes GPIO current)

Flyback Protection: When relay coil de-energizes, collapsing magnetic field induces voltage spike (can reach 100V+). Diode provides discharge path: spike energy dissipates through diode instead of destroying MOSFET.

Calculations:

  • Relay current: I = V / R = 12V / 400Ω = 30mA
  • MOSFET Vgs = 3.3V > Vgs(th) typical 2.1V → on ✓ (note: verify Vgs(th) max for your specific device; worst-case 2N7000 can have Vgs(th) up to 3.0V, leaving minimal margin at 3.3V)
  • Gate resistor: 100Ω limits inrush current when GPIO goes high (prevents ringing)
  • Pull-down: 10kΩ ensures gate stays at GND when GPIO is floating (prevents spurious relay activation)

Result: GPIO high → MOSFET conducts → relay energizes → mains lamp turns on ✓


8.8.3 Advanced Example: PWM Motor Control with Power MOSFET

Scenario: Variable-speed control of a 12V DC motor (stall current: 2A, running current: 500mA) using PWM from ESP32.

Components:

  • N-channel Power MOSFET: IRLZ44N (logic-level, Rds(on) = 0.022Ω @ Vgs=10V, ~0.028Ω @ Vgs=5V, Id(max) = 47A)
  • Motor: 12V, 500mA running, 2A stall
  • Flyback diode: 1N5819 Schottky (low forward voltage, fast recovery)
  • Gate driver: Optional, but improves switching speed

Circuit Design:

         12V
          │
       [DC Motor]
          │   ┌────────┐
          │   │1N5819  │ (Schottky flyback)
          └───┘        │
          │            │
      Drain (D)   <────┘
          │
   IRLZ44N MOSFET
          │
      Source (S)
          │
         GND

ESP32 PWM ──[100Ω]──> Gate (G)
                │
              [10kΩ] Pull-down
                │
               GND

Advanced Consideration: MOSFET Switching Losses

At PWM frequency of 1 kHz (ESP32 default): - Conduction loss (when ON): P = I² × Rds(on) = (0.5)² × 0.022 = 5.5mW (using Rds(on) at Vgs=10V; at Vgs=3.3V expect ~0.05Ω, giving ~12.5mW – still negligible) - Switching loss (transitions): Depends on gate charge (Qg) and switching time

Gate Charge Calculation:

  • IRLZ44N gate charge: Qg = 63nC (from datasheet)
  • PWM frequency: f = 1 kHz
  • Gate drive current (average): I = Q × f = 63nC × 1000 = 63µA (negligible!)
  • Switching loss (simplified): P ≈ Qg × Vgs × f = 63nC × 3.3V × 1000 = 0.2mW

Total Power Dissipation: 5.5mW + 0.2mW = 5.7mW → no heatsink needed

If using higher PWM frequency (20 kHz for quieter operation):

  • Switching loss: 63nC × 3.3V × 20,000 = 4.2mW
  • Total: 5.5mW + 4.2mW = 9.7mW → still OK without heatsink

Motor Characteristics:

  • PWM duty cycle 50% → average voltage 6V → motor runs at ~50% speed
  • Flyback diode handles inductive kick when motor current changes
  • Schottky diode chosen for fast recovery (important at high PWM frequency)

Advanced Protection:

  • Add 0.1µF capacitor across motor terminals (suppresses EMI/RFI noise)
  • Add 100nF ceramic cap from Vgs to GND (stabilizes gate voltage during fast switching)

Result: ESP32 PWM (0-100% duty) → MOSFET switches 500mA → motor speed varies smoothly. Power loss in MOSFET minimal due to ultra-low Rds(on) ✓

Key Differences from Beginner/Intermediate:

  • Power MOSFET handles 2A vs 30mA (relay) or 100mA (LED)
  • Switching losses become significant at high frequency
  • EMI suppression needed for motor commutation noise
  • Schottky diode for faster recovery than standard 1N4001
  • Heat dissipation calculated to verify no heatsink needed

Design Insight: For loads >500mA, always calculate power dissipation. If P > 500mW, add heatsink. If P > 2W, consider active cooling or multiple MOSFETs in parallel.

8.8.4 MOSFET Power Dissipation Calculator

Use this calculator to estimate power dissipation and determine whether a heatsink is needed for your MOSFET switching circuit.

8.9 Concept Relationships

Concept Relationships: Electronics Fundamentals
Concept Relates To Relationship
Doping Conductivity Adding impurities (P or N type) increases semiconductor conductivity by orders of magnitude
PN Junction Diode Two doped layers (P+N) form a diode - the fundamental building block of all semiconductors
Transistor Diode A transistor is two PN junctions back-to-back (NPN or PNP), forming a controllable switch
BJT Base Current Collector Current Ic = β × Ib (current gain typically 100-300); base current controls collector current
MOSFET Gate Voltage Drain Current Voltage-controlled; Id flows when Vgs > Vgs(th); essentially zero gate current (<1µA)
Power Dissipation Heat P = V × I (BJT) or I² × Rds(on) (MOSFET); >500mW requires heatsinking

Cross-module connection: Electronics principles connect to Sensor Circuits for signal conditioning, Actuator Control for motor/relay driving, and Power Management for voltage regulation and battery optimization.


8.10 Knowledge Check

8.11 See Also

Related Content Across Modules

Within This Module (Physical World):

Fundamentals (Module 1):

Engineering & Power (Module 9):

Real-World Examples:

8.12 Try It Yourself: Design a Smart Fan Controller

Your Challenge: Design a circuit that automatically turns on a 12V DC fan (300mA) when temperature exceeds 30°C, using an ESP32 and LM35 temperature sensor.

Given Components:

  • ESP32 (3.3V I/O, 12-bit ADC, max GPIO current 12mA)
  • LM35 temperature sensor (outputs 10mV/°C, e.g., 300mV @ 30°C)
  • 12V DC fan (running current: 300mA, stall current: 800mA)
  • Power supply: 12V, 1A
  • Available transistors: 2N2222 NPN BJT, IRLZ44N N-channel MOSFET
  • Resistors: assorted 1kΩ - 100kΩ
  • Diodes: 1N4001, 1N5819 Schottky

Step 1: Sensor Interface

The LM35 outputs 300mV at 30°C. ESP32 ADC reads 0-3.3V (12-bit = 4096 levels).

Question: Can you connect LM35 directly to ESP32 ADC? - Hint: LM35 max output is 1.5V @ 150°C. ESP32 ADC reads 0-3.3V.

Step 2: Transistor Selection

The fan draws 300mA running, 800mA stall.

Questions:

  • 2N2222 is rated for 600mA max collector current. Is it suitable?
  • If using 2N2222, what base resistor is needed for 300mA collector current (assume β=100)?
  • If using IRLZ44N MOSFET, what is the power dissipation at 300mA (Rds(on) = 0.022Ω)?

Step 3: Protection Circuit

DC motors generate inductive spikes when switched off.

Questions:

  • Which diode is better for flyback protection: 1N4001 or 1N5819 Schottky? Why?
  • Where should the flyback diode be placed (anode/cathode orientation)?

Step 4: ESP32 Code Logic

Fill in the missing calculations (? placeholders) in this Arduino sketch. You can test your solution on real ESP32 hardware or in the Wokwi online simulator (search for “ESP32 + LM35” templates).

// Fan controller challenge - fill in the ? placeholders
int tempPin = 34;  // ADC pin
int fanPin = 25;   // GPIO output

void loop() {
  int adcValue = analogRead(tempPin);

  // Convert ADC reading to temperature
  // LM35 outputs 10mV/°C, ESP32 ADC is 12-bit (0-4095) for 0-3.3V
  float voltage = ?;  // Calculate voltage from ADC value
  float tempC = ?;    // Convert voltage to temperature in °C

  if (tempC > 30.0) {
    digitalWrite(fanPin, HIGH);  // Turn fan ON
  } else {
    digitalWrite(fanPin, LOW);   // Turn fan OFF
  }

  delay(5000);  // Check every 5 seconds
}

Your Tasks:

  1. Draw the complete circuit schematic
  2. Select BJT or MOSFET and justify your choice
  3. Calculate all resistor values
  4. Complete the ESP32 code with correct ADC-to-temperature conversion
  5. Add hysteresis to prevent fan chattering (turn ON at 30°C, turn OFF at 28°C)

Click to reveal the solution

Step 1 Solution: Sensor Interface

LM35 can connect directly to ESP32 ADC. Max output (1.5V @ 150°C) is within ADC range (3.3V). Note: The LM35 requires a minimum supply voltage of 4V, so power it from the 5V rail (available from USB or the 12V regulator), not from 3.3V.

Circuit:

         +5V (from USB or regulated supply)
           │
        ┌──┴──┐
        │LM35 │
        └──┬──┘
           │ Vout (10mV/°C, max 1.5V)
           ├──> ESP32 ADC Pin 34 (safe: max 1.5V < 3.3V ADC range)
           │
          GND

Step 2 Solution: Transistor Selection

2N2222 Analysis:

  • Rated for 600mA max, but fan can stall at 800mA → MARGINAL, NOT RECOMMENDED
  • If we proceed: Ic = 300mA, β = 100, required Ib = 3mA
  • Base resistor: R = (3.3V - 0.7V) / 3mA = 867Ω → use 820Ω
  • Power dissipation: P = Vce(sat) × Ic = 0.2V × 0.3A = 60mW (acceptable)

IRLZ44N MOSFET Analysis (BETTER CHOICE): - Rated for 47A → easily handles 800mA stall ✓ - Power dissipation: P = I² × Rds(on) = (0.3)² × 0.022 = 2mW (excellent!) - Gate resistor: 100Ω (limits inrush current) - Pull-down: 10kΩ (keeps fan off when ESP32 boots)

Winner: MOSFET for lower power loss, higher current rating, lower GPIO load

Step 3 Solution: Protection Circuit

Diode Choice: 1N5819 Schottky is better - Forward voltage: 0.4V (vs 0.7V for 1N4001) → less energy wasted during spike discharge - Reverse recovery time: <10ns (vs 2µs for 1N4001) → better for fast PWM if added later

Placement:

         12V
          │
       [DC Fan]
          │   ┌───────┐
          │   │1N5819 │ Cathode to +12V (prevents reverse current)
          └───┤       │
              └───────┘
          │
      Drain (D)
          │
   IRLZ44N
          │
      Source (S)
          │
         GND

Anode to motor-, Cathode to motor+ (or +12V rail). When motor turns off, collapsing magnetic field tries to maintain current → current flows through diode instead of spiking MOSFET.

Step 4 Solution: Complete Circuit

                    +12V
                     │
                  [DC Fan 300mA]
                     │   ┌────────┐
                     │   │1N5819  │
                     └───┤        │
                         └────────┘
                     │
                 Drain (D)
                     │
              IRLZ44N MOSFET
                     │
                 Source (S)
                     │
                    GND


          +5V                            +3.3V
           │                               │
        ┌──┴──┐                         ┌─┴─┐
        │LM35 │                         │ESP│
        └──┬──┘                         │32 │
           │                            └─┬─┘
           ├──> Pin 34 (ADC)              │
           │                          Pin 25 (GPIO)
          GND                              │
                                      [100Ω]──> Gate (G)
                                           │
                                         [10kΩ] Pull-down
                                           │
                                          GND

Step 5 Solution: Complete Code with Hysteresis

This complete sketch runs on ESP32 hardware with Arduino framework. Upload via Arduino IDE or PlatformIO.

const int tempPin = 34, fanPin = 25;
const float onTemp = 30.0, offTemp = 28.0; // 2 °C hysteresis band

void setup() {
  pinMode(fanPin, OUTPUT);
  digitalWrite(fanPin, LOW);
  Serial.begin(115200);
}

void loop() {
  int adc = analogRead(tempPin);
  float voltage = adc * (3.3 / 4096.0);
  float tempC   = voltage / 0.01;          // LM35: 10 mV/°C

  static bool fan = false;
  if (tempC > onTemp && !fan)  { digitalWrite(fanPin, HIGH); fan = true;  }
  if (tempC < offTemp && fan)  { digitalWrite(fanPin, LOW);  fan = false; }

  Serial.printf("ADC %d | %.3fV | %.1f°C | Fan %s\n",
                adc, voltage, tempC, fan ? "ON" : "OFF");
  delay(5000);
}

Key Improvements in This Solution:

  1. Hysteresis: Prevents fan from rapidly cycling on/off at exactly 30°C
  2. State variable: Tracks fan state to implement hysteresis logic
  3. Schottky diode: Better protection with lower forward drop
  4. MOSFET choice: 40x current rating margin, 30x lower power loss than BJT
  5. Pull-down resistor: Prevents fan from turning on during ESP32 boot
  6. Serial debug: Helps verify sensor readings and fan operation

Real-World Enhancements (try these next!): - Add PWM for variable fan speed (map temperature 25-40°C to 0-100% speed) - Use exponential smoothing to filter sensor noise: temp = 0.9*temp + 0.1*newReading - Add watchdog timer to reboot ESP32 if it hangs - Log temperature data to SD card or cloud (ThingSpeak, AWS IoT)

Key Lessons:

  1. Always include flyback diodes for inductive loads
  2. Choose MOSFETs for >500mA loads (lower loss, higher rating)
  3. Hysteresis prevents chattering in threshold-based control
  4. ADC-to-physical-unit conversion requires careful calculation
  5. Pull-down resistors prevent spurious activation during boot

8.13 What’s Next

If you want to… Read this
Learn about semiconductor doping, diodes, and LEDs in depth Electronics: Doping and Diodes
Understand conductors, insulators, and material properties Electronics: Conductors and Insulators
Apply electronics knowledge to analog-to-digital conversion Analog and Digital Electronics
See electronics fundamentals in action with sensor circuits Sensor Circuits and Signals

8.14 Quick Access

Need Go To
Calculate LED resistor Calculators
Choose MOSFET vs BJT Transistor Selection
Understand component symbols Component Reference
Learn about diodes Doping & Diodes
Visual component gallery Summary & Resources

The Sensor Squad’s guide to the amazing world of electronics!

“Welcome to Electronics School!” announced Max the Microcontroller. “Today I’m going to teach you how I was born – from tiny pieces of silicon!”

Sammy the Sensor raised a hand. “But Max, you’re so smart and complicated. How can you come from a rock?” Max laughed. “Silicon IS a special rock – a semiconductor. Scientists figured out how to add tiny bits of other materials to make it conduct electricity in clever ways. That’s how they made diodes, transistors, and eventually ME!”

Lila the LED was fascinated. “Tell us more!” Max drew five lessons on the board:

Lesson 1: Electronics vs Electricity. Electricity is just power flowing, but electronics is SMART power – it can think and decide! Your light bulb just turns on, but your smart light bulb checks a schedule, reads sensors, and connects to Wi-Fi.”

Lesson 2: Materials. There are conductors (let electricity through), insulators (block it), and semiconductors (can do BOTH depending on conditions).”

Lesson 3: Doping. Scientists add special atoms to silicon to make N-type (extra electrons) and P-type (missing electrons). Put them together and you get diodes and transistors!”

Lesson 4: Transistors. These are tiny switches that I’m made of – millions of them! They can turn on and off super fast, which is how I think.”

Lesson 5: Choosing the right parts. Different jobs need different transistors, just like different sports need different shoes!”

Bella the Battery smiled. “And I power all of this!” The whole squad cheered – they were ready to learn electronics!

8.14.1 Key Words for Kids

Word What It Means
Electronics Using special materials to make smart circuits that can think and decide
Semiconductor A material that can be switched between conducting and blocking electricity
Transistor A tiny switch inside every computer chip
Diode A one-way gate for electricity
Microcontroller A tiny computer brain made of millions of transistors
Common Mistake: Using the Same Resistor for BJT and MOSFET

The Error: A developer uses a 10k ohm resistor from GPIO to the base/gate for both a BJT and a MOSFET. The BJT circuit barely turns on, while the MOSFET works perfectly.

Why: BJTs are current-controlled – a 10k ohm base resistor only provides Ib = 2.6V/10k ohm = 0.26mA, which can only switch Ic = 26mA (with beta=100). MOSFETs are voltage-controlled – with essentially zero gate current, the full 3.3V reaches the gate regardless of resistor value, so the MOSFET turns fully on.

Fix: For BJTs, use a ~1k ohm base resistor (provides ~2.6mA, enough to switch ~260mA). For MOSFETs, resistor value is less critical (100 ohm to 1k ohm), but always add a 10k ohm pull-down to prevent floating gate.

Quick Reference:

Load Current Recommended Transistor Base/Gate Resistor Pull-down Flyback Diode
<100mA 2N2222 BJT 1k ohm Not critical Yes (if inductive)
100-500mA 2N2222 or small MOSFET 1k ohm (BJT) / 100 ohm (FET) 10k ohm Yes
500mA-5A Logic-level MOSFET 100 ohm 10k ohm Yes
>5A High-current MOSFET + heatsink 10-100 ohm 10k ohm Yes

See the Incremental Example Set above for detailed calculations and worked examples.

Key Takeaway

Electronics is the bridge between raw electrical power and intelligent IoT devices. Understanding semiconductors, diodes, and transistors enables you to safely interface sensors, efficiently control actuators, optimize battery life, and debug hardware issues – skills that apply to every IoT project from prototype to production.


Total Reading Time: ~80 minutes | Difficulty Range: Beginner to Intermediate