Electronics adds intelligence to electricity. While electrical devices simply use power, electronic devices use semiconductors (transistors, diodes) to actively control current flow, enabling microcontrollers to read sensors, make decisions, and drive actuators in every IoT system.
9.1 Learning Objectives
By the end of this section, you will be able to:
Classify Semiconductor Materials: Distinguish conductors, insulators, and semiconductors by their electrical properties
Differentiate N-type and P-type: Describe doping processes and predict semiconductor behavior based on impurity type
Analyze Diode Operation: Trace one-way current flow through PN junctions and select diodes for protection circuits
Compare Transistor Types: Evaluate BJT versus FET transistors and justify selection for specific IoT applications
Design Switch Circuits: Calculate component values for transistor-based digital switches in IoT devices
For Beginners: Electronics is the “Brain” of IoT
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.”
Electronics is like having a super-smart brain that can make decisions about electricity!
9.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!”
9.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
9.1.3 Try This at Home!
Play the Transistor Game!
One person is the “Microcontroller” (the boss who gives quiet commands)
One person is the “Transistor” (the gatekeeper)
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!
9.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
Why 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.
Key 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
Key Takeaway
In one sentence: Transistors are tiny electronically-controlled switches that bridge the gap between low-power microcontroller signals and high-power real-world loads–mastering this concept unlocks all IoT hardware design.
Remember this rule: Always check three things before connecting a load to a GPIO pin–required current (does it exceed GPIO limits?), required voltage (does it match logic level?), and load type (inductive loads need flyback diodes).
9.3 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.
9.3.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:
Analog to digital signal flow in IoT systems
Figure 9.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.
Variant View: Signal Processing Domain Boundaries
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.
Figure 9.2: Domain boundary view showing signal transformations and error sources at each processing stage.
Key Stages Explained:
Physical → Sensor: Environmental changes (temperature rises from 20°C to 25°C) are converted to electrical signals
Analog Signal: Continuous voltage proportional to physical quantity (e.g., 10mV per °C)
Signal Conditioning: Amplify weak signals (µV → mV), filter noise, level shift to ADC input range
ADC Conversion: Sample analog voltage at regular intervals, quantize to nearest digital value
Digital Processing: Microcontroller applies calibration, averages readings, detects thresholds
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.0°C → MQTT publishes value
9.4 Interactive Electronics Calculators
Before diving into semiconductors, let’s master the practical calculations you’ll use daily in IoT development.
9.4.1 Ohm’s Law Calculator
Ohm’s Law (V = I x R) is the foundation of all circuit analysis. Use this calculator and reference when designing your IoT circuits.
Using the Ohm’s Law Calculator
Common IoT Applications:
1. LED Current Limiting:
Supply voltage - LED forward voltage = voltage across resistor
{let result;if (ohm_solve_for ==="Voltage (V)") {const v = (ohm_i_ma /1000) * ohm_r;const p = v * (ohm_i_ma /1000); result =md`**Ohm's Law Result:** V = I × R = ${(ohm_i_ma /1000).toFixed(4)} A × ${ohm_r} Ω = **${v.toFixed(3)} V**- Power: P = V × I = **${(p *1000).toFixed(1)} mW**`; } elseif (ohm_solve_for ==="Current (I)") {const i = ohm_v / ohm_r;const p = ohm_v * i; result =md`**Ohm's Law Result:** I = V / R = ${ohm_v.toFixed(2)} V / ${ohm_r} Ω = **${(i *1000).toFixed(2)} mA**- Power: P = V × I = **${(p *1000).toFixed(1)} mW**`; } else {const r = ohm_v / (ohm_i_ma /1000);const p = ohm_v * (ohm_i_ma /1000); result =md`**Ohm's Law Result:** R = V / I = ${ohm_v.toFixed(2)} V / ${(ohm_i_ma /1000).toFixed(4)} A = **${r.toFixed(1)} Ω**- Power: P = V × I = **${(p *1000).toFixed(1)} mW**`; }return result;}
9.4.2 LED Resistor Calculator
LEDs are everywhere in IoT - status indicators, displays, and debugging. This tool calculates the perfect current-limiting resistor.
Show code
viewof supply_voltage = Inputs.range([1.8,12], {value:3.3,step:0.1,label:"Supply Voltage (V)"})viewof led_forward_voltage = Inputs.range([1.0,4.0], {value:2.0,step:0.1,label:"LED Forward Voltage (V)"})viewof led_current_ma = Inputs.range([1,100], {value:20,step:1,label:"Desired LED Current (mA)"})
Show code
{const v_resistor = supply_voltage - led_forward_voltage;if (v_resistor <=0) {returnmd`**Error:** Supply voltage (${supply_voltage.toFixed(1)} V) must be greater than LED forward voltage (${led_forward_voltage.toFixed(1)} V). Increase supply voltage or choose a lower Vf LED.`; }const r_exact = v_resistor / (led_current_ma /1000);const e12 = [10,12,15,18,22,27,33,39,47,56,68,82];let r_standard =Infinity;for (let mult of [1,10,100,1000,10000]) {for (let val of e12) {let r = val * mult;if (r >= r_exact && r < r_standard) r_standard = r; } }const actual_current = v_resistor / r_standard *1000;const power_mw = v_resistor * actual_current;returnmd`**Results:**- Voltage across resistor: **${v_resistor.toFixed(2)} V**- Exact resistance needed: **${r_exact.toFixed(1)} Ω**- Nearest standard resistor (E12): **${r_standard} Ω**- Actual LED current with ${r_standard} Ω: **${actual_current.toFixed(1)} mA**- Resistor power dissipation: **${power_mw.toFixed(1)} mW** ${power_mw >250?"(⚠ exceeds ¼W rating!)":"(within ¼W rating)"}`;}
9.4.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.
{const vout = vin_divider * r2_divider / (r1_divider + r2_divider);const ratio = r2_divider / (r1_divider + r2_divider);const current_ua = vin_divider / (r1_divider + r2_divider) *1e6;const power_uw = vin_divider * vin_divider / (r1_divider + r2_divider) *1e6;returnmd`**Results:**- Output Voltage (Vout): **${vout.toFixed(3)} V**- Division Ratio: **${ratio.toFixed(4)}** (${(ratio *100).toFixed(1)}%)- Current through divider: **${current_ua.toFixed(1)} µA**- Total power dissipation: **${power_uw.toFixed(1)} µW**- ${vout <=3.3?"✓ Safe for 3.3V ADC input":"⚠ Exceeds 3.3V — not safe for ESP32 ADC"}`;}
9.4.4 Battery Life Calculator
Understanding battery life is critical for IoT devices. This tool calculates runtime based on current consumption and sleep modes.
Show code
viewof battery_mah = Inputs.range([100,10000], {value:2200,step:100,label:"Battery Capacity (mAh)"})viewof active_current_ma = Inputs.range([1,500], {value:80,step:1,label:"Active Mode Current (mA)"})viewof sleep_current_ua = Inputs.range([1,1000], {value:10,step:1,label:"Sleep Mode Current (µA)"})viewof active_seconds = Inputs.range([1,300], {value:5,step:1,label:"Active Duration per Cycle (s)"})viewof sleep_seconds = Inputs.range([1,3600], {value:60,step:1,label:"Sleep Duration per Cycle (s)"})
Show code
{const cycle_s = active_seconds + sleep_seconds;const duty = active_seconds / cycle_s;const avg_ma = active_current_ma * duty + (sleep_current_ua /1000) * (1- duty);const hours = battery_mah / avg_ma;const days = hours /24;const months = days /30.44;const years = days /365.25;let runtime_str;if (years >=1) runtime_str =`${years.toFixed(1)} years`;elseif (months >=1) runtime_str =`${months.toFixed(1)} months`;elseif (days >=1) runtime_str =`${days.toFixed(1)} days`;else runtime_str =`${hours.toFixed(1)} hours`;returnmd`**Results:**- Duty cycle: **${(duty *100).toFixed(1)}%** active- Average current: **${avg_ma.toFixed(3)} mA**- Estimated battery life: **${runtime_str}** (${hours.toFixed(0)} hours)- ${avg_ma <0.05?"✓ Excellent for coin cell deployment": avg_ma <2?"✓ Good for AA battery deployment":"⚠ Consider longer sleep intervals for battery longevity"}`;}
9.4.5 IoT Device Power Supply Architecture
Now that you can estimate battery life, let’s examine how power flows through your IoT device and where optimization opportunities exist:
IoT device power supply architecture
Figure 9.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.
9.4.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.
Figure 9.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:
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
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
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
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
Battery 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.005mA, 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 50ms-2s (spreading factor dependent)
Strategy: Collect 10-100 readings, transmit once vs transmit each reading
3. Real-World Targets:
Coin cell (CR2032): 0.005-0.02mA average → 1-5 years
AA batteries (2×): 0.05-0.5mA average → 6 months-5 years
Rechargeable (daily charging): <100mA average → 20+ hours
Solar powered: Match average consumption to solar generation (typically 5-50mA)
Check Your Understanding: Power Budgeting
9.5 Knowledge Check
Quiz: Electronics Introduction
Worked Example: Designing a MOSFET Switch for a 12V Motor
Scenario: You need to control a 12V DC motor (stall current: 2A) from an ESP32 GPIO pin (3.3V output, 12mA max). Design the transistor switching circuit.
Step 1: Choose Transistor Type
BJT vs MOSFET comparison:
BJT (2N2222): Current-controlled, max Ic ≈ 0.8A (can’t handle 2A); even for a higher-rated BJT, base current = Ic/β ≈ 2A/100 = 20mA (exceeds GPIO limit!)
MOSFET (IRLZ44N): Voltage-controlled, gate current ≈ 0µA (perfect for GPIO)
Select: N-channel logic-level MOSFET (IRLZ44N)
Step 2: Verify MOSFET Specifications
Parameter
IRLZ44N Spec
Requirement
Status
Vds (drain-source voltage)
55V
12V motor
✓ Safe
Id (continuous drain current)
47A
2A motor
✓ Massive headroom
Vgs(th) (gate threshold)
1-2V
3.3V GPIO
✓ Fully on at 3.3V
Rds(on) @ Vgs=4.0V
~0.035Ω
Low resistance
✓ Minimal voltage drop (note: 0.022Ω spec is at Vgs=10V; at 3.3V Rds(on) is higher)
Package
TO-220
Through-hole
✓ Easy to prototype
Step 3: Calculate Power Dissipation
With motor running at 2A (using Rds(on) ≈ 0.050Ω at Vgs=3.3V, worst case): - Voltage drop: V = I × Rds(on) = 2A × 0.050Ω = 0.10V (negligible) - Power dissipation: P = I² × Rds(on) = (2A)² × 0.050Ω = 0.20W
At room temperature (25°C): - Thermal resistance: 62.5°C/W (TO-220 without heatsink) - Temperature rise: 0.20W × 62.5°C/W = 12.5°C - Junction temperature: 25 + 12.5 = 37.5°C (well below 175°C max)
No heatsink needed!
Step 4: Design Gate Drive Circuit
Components needed:
R1: Gate resistor (100Ω) - limits gate charge current
R2: Pull-down resistor (10kΩ) - ensures MOSFET off when GPIO is floating
D1: Flyback diode (1N4007) - protects MOSFET from motor inductive kickback
Orientation: Cathode (stripe) to 12V, anode to motor/drain
Step 6: Arduino Code Example
constint MOTOR_PIN =25;// GPIO25 on ESP32void setup(){ pinMode(MOTOR_PIN, OUTPUT); digitalWrite(MOTOR_PIN, LOW);// Motor off initially}void loop(){// Turn motor on digitalWrite(MOTOR_PIN, HIGH);// 3.3V to MOSFET gate delay(2000);// Run for 2 seconds// Turn motor off digitalWrite(MOTOR_PIN, LOW);// 0V to gate, MOSFET off delay(1000);// Off for 1 second}
Step 7: Verification Checklist
Check
Expected
Measured
Status
GPIO voltage HIGH
3.3V
3.28V
✓
Gate voltage when ON
3.3V
3.27V
✓
Gate voltage when OFF
0V
0.01V
✓ (pull-down working)
Motor voltage when ON
12V
11.90V
✓ (~0.1V drop across MOSFET at Vgs=3.3V)
Motor current
2A max
1.8A running
✓ (below stall current)
MOSFET temperature
<50°C
32°C
✓ (minimal heating)
Step 8: Common Mistakes to Avoid
Mistake
Consequence
Fix
❌ No gate resistor
GPIO inrush current spike damages ESP32
✓ Add 100Ω gate resistor
❌ No pull-down resistor
Motor runs randomly during ESP32 boot
✓ Add 10kΩ pull-down
❌ No flyback diode
MOSFET fails after few switching cycles
✓ Add 1N4007 across motor
❌ Using standard MOSFET (not logic-level)
Requires 10V gate drive, won’t fully turn on
✓ Use logic-level MOSFET (Vgs=3.3V)
❌ P-channel MOSFET for low-side switch
Requires negative gate voltage
✓ Use N-channel for low-side
Explore: MOSFET Thermal Calculator
The power dissipation formula from Step 3 above (\(P = I^2 \times R_{ds(on)}\)) determines whether your MOSFET needs a heatsink. Adjust the parameters below to explore different scenarios:
1. Treating All Electronic Components as Interchangeable
Resistors, capacitors, inductors, diodes, and transistors have fundamentally different electrical behaviors. Substituting a capacitor where a resistor is needed, or using an NPN transistor circuit topology for a PNP device, produces circuits that don’t work. Always identify the specific component type, package, and electrical parameters required before substitution.
2. Ignoring Component Polarity for Polarized Components
Electrolytic capacitors, LEDs, diodes, and transistors are polarized — they only work correctly in one orientation. Reversing an electrolytic capacitor causes it to fail (and sometimes explosively). Reversing an LED causes it to block current (no light). Always verify polarity markings (stripe on diode, stripe on capacitor, flat side of LED) before inserting components.
3. Confusing Schematic Symbols with Physical Component Appearance
Schematics use standardized symbols that bear no resemblance to the actual physical component. An NPN transistor symbol (triangle with arrow) looks nothing like a TO-92 plastic package. An op-amp symbol (triangle) doesn’t look like a DIP-8 IC. Always translate schematic symbols to component identifiers and then to physical pinouts via the datasheet — never guess from the symbol alone.
4. Not Checking Component Specifications Against Operating Conditions
A capacitor rated 16 V in a 12 V circuit seems fine, but voltage ratings should be derated by 50% for reliability: use 25 V or 35 V capacitors in a 12 V circuit. Similarly, transistors rated 200 mA used at 190 mA run hot and fail early. Apply 50% derating to voltage, current, and power ratings as standard engineering practice.
Label the Diagram
9.8 What’s Next
If you want to…
Read this
Learn how electronic components work at the circuit level