Electronics & Circuits · Study deck
Electronics for IoT: Power and Switching
The signal calculations are correct, but an IoT device must survive its load path, the route that supplies current to the part being driven.
Voltage Vera is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: The load path runs from the 12 V rail through the motor and MOSFET to ground; it must be rated for stall current, not merely the lower running current.
- Explain: The control supply and coil supply may be different voltages, but this simple base-drive circuit needs the GPIO ground and transistor-emitter ground to share a reference.
- Explain: 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!).
- Explain: Taking VBE(sat)≈0.8 V gives.
Major section
BJT Transistor as a Relay Switch
The collector voltage is therefore an inverted version of the control: a high input produces a low collector voltage.
- An NPN bipolar junction transistor is a current-controlled low-side switch.
- The relay contacts remain a separate circuit and can switch an isolated load within their ratings.
- Gain varies between parts and falls in saturation.
Major section
BJT Transistor as a Relay Switch (continued)
IB≥βfIC,RB≤IBVGPIO,H−VBE(sat)..
- The relay coil connects from its load supply VCC to the collector, the emitter returns to ground, and a GPIO drives the base through a resistor.
- With βf=10, require IB≥6 mA.
- The coil is inductive.
Major section
BJT Transistor as a Relay Switch (continued)
The control supply and coil supply may be different voltages, but this simple base-drive circuit needs the GPIO ground and transistor-emitter ground to share a reference.
- Taking VBE(sat)≈0.8 V gives.
- If it is not, use a MOSFET or a driver IC rather than hoping for more transistor gain.
- When the transistor opens, v=Ldi/dt produces whatever voltage is needed to keep current flowing.
Major section
MOSFET Switch for 12V Motor
The control path runs from the ESP32 GPIO through the gate resistor to the MOSFET gate; it must establish a defined OFF state during reset and charge the gate quickly enough for the chosen switching rate.
- The photograph supplies orientation, while the datasheet remains the authority for pin order and ratings.

Major section
MOSFET Switch for 12V Motor (continued)
D1: Flyback diode (1N4007) - protects MOSFET from motor inductive kickback.
- The load path runs from the 12 V rail through the motor and MOSFET to ground; it must be rated for stall current, not merely the lower running current.
- R1: Gate resistor (100Ω) - limits gate charge current.
- Without diode: spike can reach 100-300V, destroying MOSFET.
Major section
MOSFET Switch for 12V Motor (continued)
The turn-off path is provided by the flyback diode so the motor winding's current can decay without forcing the drain voltage beyond the switch rating.
- A headline drain-current rating measured under favourable thermal conditions is not proof of a safe design, and gate-threshold voltage is only where conduction begins.
- The useful check is the datasheet's on-resistance at the available gate drive, followed by I2R loss and a thermal estimate.
- The checklist below records those decisions in the same order: switch type, electrical ratings, physical package, dissipation, gate network, protection, and finally code behaviour.
Major section
MOSFET Switch for 12V Motor (continued)
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!).
- That physical reading connects the on-resistance and junction-temperature checks to assembly, clearance, and any heatsink decision.
- Thermal result: This estimate does not establish junction temperature or heatsink need without a guaranteed on-resistance at the applied gate voltage and a verified duty cycle.
- <!-- Note: This code can be run on a physical ESP32 with Arduino IDE, or simulated at wokwi.com with an ESP32 + MOSFET + motor circuit -->.
Major section
Explore: MOSFET Thermal Calculator
The power dissipation formula from Step 3 (P=I2×Rds(on)) estimates conduction loss when the on-resistance is known at the applied gate voltage.
- Adjust the parameters below to explore conditional scenarios; the calculator does not include PWM duty cycle or drain-transition losses.
- Logic-level MOSFETs need guaranteed on-resistance at the actual GPIO gate voltage; threshold voltage alone is insufficient.
- Gate resistor (100Ω) protects GPIO from gate capacitance inrush.
Deck summary
Key takeaways
The collector voltage is therefore an inverted version of the control: a high input produces a low collector voltage.
- IB≥βfIC,RB≤IBVGPIO,H−VBE(sat)..
- The control supply and coil supply may be different voltages, but this simple base-drive circuit needs the GPIO ground and transistor-emitter ground to share a reference.
- The control path runs from the ESP32 GPIO through the gate resistor to the MOSFET gate; it must establish a defined OFF state during reset and charge the gate quickly enough for the chosen switching rate.
Retrieval practice
Recall check 1 of 3

Voltage Vera says: answer from memory, then check your reasoning.
Q1Two IoT sensors share a 5V supply rated for 500 mA. At the intended operating voltage, Sensor A requires 200 mA and Sensor B requires 350 mA. What is their combined demand relative to the supply rating?
Show answer
Answer: C At the intended 5V operating point, the parallel loads demand 200 + 350 = 550 mA, 50 mA above the supply's 500 mA rating.
Retrieval practice
Recall check 2 of 3

Voltage Vera says: answer from memory, then check your reasoning.
Q2An IoT sensor board draws 50 mA from a 3.3V supply. The designer adds an LED indicator that requires 20 mA at 2V. Using a current-limiting resistor from the 3.3V rail, what resistor value is needed for the LED?
Show answer
Answer: D see answers page
Retrieval practice
Recall check 3 of 3

Voltage Vera says: answer from memory, then check your reasoning.
Q3Q3: signal versus load powerWhat motor, lamp or relay receives the switched power in a controller circuit?
Show answer
Answer: A It is the motor, lamp, relay, or other device receiving switched power.
Q4Q4: GPIO driver decision helperComplete the GPIO load decision helper for a beginner IoT circuit:
Show answer
Answer: A GPIO pins are for small signals, not motors, relays, LED strips, or other high-current loads.
Print reference
Answers
Answer key.
- C · At the intended 5V operating point, the parallel loads demand 200 + 350 = 550 mA, 50 mA above the supply's 500 mA rating.
- D · The resistor must drop the voltage difference between the supply (3.3V) and the LED forward voltage (2.0V), which is 1.3V. Using Ohm's law: R = V/I = 1.3V / 0.02A = 65 ohms. A common mistake is using the full supply voltage (3.3V/0.02A = 165 ohms), which would under-drive the LED. In practice, the nearest standard resistor (68 ohms) would be selected, resulting in approximately 19 mA -- close enough for an indicator LED.
- A · It is the motor, lamp, relay, or other device receiving switched power.
- A · GPIO pins are for small signals, not motors, relays, LED strips, or other high-current loads.