Electronics & Circuits · Study deck
Electronics for IoT: Power and Switching
The signal calculations are correct, but an IoT device must also survive its power and load paths.
Voltage Vera is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: 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.
- 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.
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)
$$ I_B\geq\frac{I_C}{\beta_f}, \qquad R_B\leq\frac{V_{GPIO,H}-V_{BE(sat)}}{I_B}. $$.
- The relay coil connects from its load supply $V_{CC}$ to the collector, the emitter returns to ground, and a GPIO drives the base through a resistor.
- With $\beta_f=10$, require $I_B\geq6\ \mathrm{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 $V_{BE(sat)}\approx0.8\ \mathrm{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=L\,di/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 $I^2R$ 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.
- <!-- Note: This code can be run on a physical ESP32 with Arduino IDE, or simulated at wokwi.com with an ESP32 + MOSFET + motor circuit -->.
- Purpose: Ensure MOSFET is OFF when GPIO is tri-state (during boot/reset).
Major section
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.
- Logic-level MOSFETs (Vgs=3.3V) are essential for microcontroller interfacing.
- Gate resistor (100Ω) protects GPIO from gate capacitance inrush.
- Flyback diode (1N4007) is MANDATORY for inductive loads (motors, relays, solenoids).
Deck summary
Key takeaways
The collector voltage is therefore an inverted version of the control: a high input produces a low collector voltage.
- $$ I_B\geq\frac{I_C}{\beta_f}, \qquad R_B\leq\frac{V_{GPIO,H}-V_{BE(sat)}}{I_B}. $$.
- 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 are powered from the same 5V, 500 mA USB power supply. Sensor A draws 200 mA and Sensor B draws 350 mA. What will happen when both sensors are operating simultaneously?
Show answer
Answer: C In a parallel circuit, total current is the sum of individual currents: 200 + 350 = 550 mA, exceeding the 500 mA supply limit.
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
Retrieval practice
Recall check 3 of 3

Voltage Vera says: answer from memory, then check your reasoning.
Q3Place each electronics concept where it lives so you can separate the low-energy information path from the higher-current load path.
Show answer
Answer: A These boundaries keep sense input, make decision, drive power distinct so you can separate the low-energy information path from the higher-current load path.
Q4Complete 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 · In a parallel circuit, total current is the sum of individual currents: 200 + 350 = 550 mA, exceeding the 500 mA supply limit.
- D
- A · These boundaries keep sense input, make decision, drive power distinct so you can separate the low-energy information path from the higher-current load path.
- A · GPIO pins are for small signals, not motors, relays, LED strips, or other high-current loads.