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 whose conductivity can be engineered; silicon becomes useful for electronics because doping changes how charge moves through it.
  • Diode: A one-way device built from a PN junction; used for rectification, protection, LEDs, and the internal building blocks of more complex devices.
  • Transistor: A controllable semiconductor switch or amplifier; BJTs use base current, while MOSFETs use gate voltage.
  • Logic-level MOSFET: The default IoT power-switching device when a microcontroller must control relays, motors, solenoids, or LED strips without overstressing GPIO pins.
  • Driver circuit: The interface between a low-power controller and a higher-power load; typically includes a transistor, resistor network, and protection components such as a flyback diode.
  • Datasheet-first design: Good electronics decisions come from checking voltage, current, power, and switching requirements against the component datasheet instead of relying on generic part names.

8.2 Overview

This book is the bridge between basic electricity and practical IoT hardware design. It explains what semiconductors are, how diodes and transistors behave, and how to choose safe switching circuits when a microcontroller needs to control real loads.

Use this page as a guide, not as the main teaching chapter. The detailed explanations, examples, and checks live in the five linked sections below.


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 need the vocabulary and first design habits before touching transistor or switching circuits.


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: material behavior, passive components, voltage dividers, decoupling, current limiting, and rating checks


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: This is the theory chapter that explains why silicon devices behave the way they do.


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: This is the selection chapter for real GPIO-to-load interfaces.


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: Use this last, after the main sections, for review, troubleshooting, and quick lookup.


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 To Use This Book


8.6 How It Works: Building a Smart Light from Silicon

From Raw Silicon to a Smart LED Light

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

Stage What It Does
Wall AC Supplies energy to the device
Diode rectifier Converts AC into pulsing DC
Voltage regulator Produces safe DC rails for electronics
Battery backup Keeps the device alive during short outages
ESP32 and Wi-Fi module Process the control logic and communicate wirelessly
GPIO output Sends a low-power control signal
MOSFET Uses that small GPIO signal to switch the LED load
LED + resistor Produces light while the resistor limits current

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.7 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.8 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.9 Incremental Example Set: Transistor Switching Circuits

Controlling Loads with Transistors

8.9.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

Wiring map:

Node Connects To Purpose
+5V supply LED and current-limiting resistor path Provides LED power
LED/resistor negative side 2N2222 collector Lets the transistor switch the LED current
2N2222 emitter GND Completes the low-side current path
ESP32 GPIO (3.3V) 1kΩ resistor, then 2N2222 base Provides the small base current that turns the transistor ON
LED current path About 100mA when ON GPIO controls a larger current safely through the transistor

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 (OK)


8.9.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)

Wiring map:

Node Connects To Purpose
+12V supply Relay coil positive side Provides coil power
Relay coil negative side 2N7000 drain MOSFET switches the coil current
2N7000 source GND Low-side switch reference
ESP32 GPIO (3.3V) 100Ω resistor, then MOSFET gate Controls the relay
MOSFET gate 10kΩ pull-down to GND Keeps relay OFF during boot/reset
1N4001 flyback diode Across relay coil, cathode to +12V Protects MOSFET from inductive voltage spikes

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 (OK; verify Vgs(th) max for your specific device, because 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 (OK)


8.9.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

Wiring map:

Node Connects To Purpose
+12V supply DC motor positive side Provides motor power
DC motor negative side IRLZ44N drain MOSFET switches motor current
IRLZ44N source GND Low-side switch reference
ESP32 PWM pin 100Ω resistor, then MOSFET gate Controls motor speed by PWM
MOSFET gate 10kΩ pull-down to GND Keeps motor OFF during boot/reset
1N5819 Schottky diode Across motor, cathode to +12V Handles motor flyback current during switching

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 is minimal due to ultra-low Rds(on) (OK)

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.9.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.10 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.11 Knowledge Check

Quiz: Electronics Fundamentals

8.12 See Also

Related Content Across Modules

Within This Module (Physical World):

Fundamentals (Module 1):

Engineering & Power (Module 9):

Real-World Examples:

8.13 Try It Yourself: Design a Smart Fan Controller

Temperature-Activated Fan Circuit

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

Study the conversion lines in this Arduino sketch, then modify the program to add hysteresis. You can test your solution on real ESP32 hardware or in the Wokwi online simulator (search for “ESP32 + LM35” templates).

// Fan controller challenge: verify the conversion and add hysteresis
const int tempPin = 34;  // ADC pin
const int fanPin = 25;   // GPIO output
const float adcReferenceV = 3.3;
const float adcMaxCount = 4095.0;
const float lm35VoltsPerC = 0.010;

void setup() {
  pinMode(fanPin, OUTPUT);
  digitalWrite(fanPin, LOW);
}

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 = (adcValue / adcMaxCount) * adcReferenceV;
  float tempC = voltage / lm35VoltsPerC;

  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. Explain the ADC-to-temperature conversion in the starter code
  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.

Wiring map:

LM35 Pin / Node Connects To Note
VCC +5V from USB or regulated supply LM35 needs at least about 4V
Vout ESP32 ADC Pin 34 Output is 10mV/°C, max about 1.5V, safe for the ESP32 ADC
GND Common ground ESP32 and sensor must share ground

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 (OK) - 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:

Component Node Connects To
Fan positive side +12V
Fan negative side IRLZ44N drain
1N5819 cathode Fan positive side / +12V
1N5819 anode Fan negative side / MOSFET drain
IRLZ44N source 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

Subsystem Connection
Fan power +12V → DC fan positive side
Fan switch path DC fan negative side → IRLZ44N drain → IRLZ44N source → GND
Flyback protection 1N5819 across fan, cathode to +12V and anode to MOSFET drain
Temperature sensor power +5V → LM35 VCC, LM35 GND → common ground
Temperature signal LM35 Vout → ESP32 ADC Pin 34
Motor-control signal ESP32 Pin 25 → 100Ω resistor → IRLZ44N gate
Boot safety 10kΩ pull-down from IRLZ44N gate to 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 / 4095.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.14 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.15 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.15.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 DC gate current, the gate resistor does not set steady-state gate voltage. The MOSFET is suitable only if its datasheet gives low Rds(on) at the available GPIO voltage.

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