Electronics & Circuits · Study deck

Electronics: Controller Design and Review

A fan controller joins sensing, such as reading temperature, with code and drive current, the electrical current supplied to its motor.

Voltage Vera is your guide for this deck.

Voltage Vera, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: The caption's 10 mV per degree Celsius links that output to the ADC calculation, while pin identification and thermal placement warn that the transistor-like package is not self-explanatory.
  • Explain: Its purpose is to reveal the LM35 in this fan controller is a three-lead analog sensor: supply, ground, and a voltage output that changes by 10 mV per degree Celsius.
  • Explain: 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.
  • Explain: Diode Choice: 1N5819 Schottky is better.
iotclass.org

Major section

Smart Fan Controller Design

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.

  • Its purpose is to reveal the LM35 in this fan controller is a three-lead analog sensor: supply, ground, and a voltage output that changes by 10 mV per degree Celsius.
The LM35 in this fan controller is a three-lead analog sensor: supply, ground, and a voltage output that changes by 10 mV per degree Celsius. Its transistor-like package makes pin identification and thermal placement part of the circuit design, not details the ESP32 code can repair later. Photo: Nevit Dilmen, CC BY-SA 3.0
The LM35 in this fan controller is a three-lead analog sensor: supply, ground, and a voltage output that changes by 10 mV per degree Celsius. Its transistor-like package makes pin identification and thermal placement part of the circuit design, not details the ESP32 code can repair later. Photo: Nevit Dilmen, CC BY-SA 3.0
iotclass.org

Major section

Smart Fan Controller Design (continued)

The component list below is the evidence set for those linked decisions, not a menu of interchangeable parts.

  • Photo: Nevit Dilmen, CC BY-SA 3.0 before a design claim is accepted.
  • Hint: LM35 max output is 1.5V @ 150°C.
  • Step 1 Solution: Sensor Interface: LM35 can connect directly to ESP32 ADC.
iotclass.org

Major section

Circuit note: Why the fan circuit needs the math

The mathematical gist: A GPIO is a command, not a motor supply.

  • For this chapter's 300 mA fan, a 12 mA pin would be overloaded by 25.0 times.
iotclass.org

Major section

Three paths in the fan controller

"Welcome to Electronics School!" announced the microcontroller. "Today I'm going to teach you how I was born -- from tiny pieces of silicon!".

LM35 output → ESP32 measurement; ESP32 GPIO → transistor control; 12 V supply → fan → transistor → return. The GPIO does not carry motor current.

Three paths, three electrical jobs
SenseLM35 output → ESP32 measurement
CommandESP32 GPIO → transistor control
Power12 V supply → fan → transistor → return
LM35 output → ESP32 measurement; ESP32 GPIO → transistor control; 12 V supply → fan → transistor → return. The GPIO does not carry motor current.
iotclass.org

Major section

BJT vs MOSFET Resistors

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

Why it matters

For MOSFETs, resistor value is less critical (100 ohm to 1k ohm), but always add a 10k ohm pull-down to prevent floating gate.

iotclass.org

Deck summary

Key takeaways

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.

  • The component list below is the evidence set for those linked decisions, not a menu of interchangeable parts.
  • The caption's 10 mV per degree Celsius links that output to the ADC calculation, while pin identification and thermal placement warn that the transistor-like package is not self-explanatory.
  • The mathematical gist: A GPIO is a command, not a motor supply.
iotclass.org

Retrieval practice

Recall check 1 of 4

Voltage Vera says: answer from memory, then check your reasoning.

Q1You need to switch a 12V motor whose worst-case current is 1.5A from an ESP32 GPIO (3.3V output, max 12mA), including PWM speed control. Which component is MOST appropriate after checking its 3.3V gate-drive rating?

AUse a 2N2222 BJT with a 1 kΩ base resistor because it can switch the 1.5 A motor load.
BA 2N3906 PNP high-side switch driven directly from 3.3 V GPIO
CA rated logic-level N-MOSFET with flyback diode for 1.5 A PWM
DA 3.3 V relay coil with contacts unsuited to PWM speed control
Show answer

Answer: C see answers page

iotclass.org

Retrieval practice

Recall check 2 of 4

Voltage Vera says: answer from memory, then check your reasoning.

Q2An ESP32 GPIO pin outputs 3.3V and can source a maximum of 12 mA. A designer connects it directly to a 12V relay coil that requires 80 mA. What will happen, and what is the correct interface approach?

AA logic-level buffer powered at 3.3V would provide enough drive for the relay.
BThe GPIO is overloaded and the relay may not actuate; use a rated transistor driver with flyback protection.
CThe relay will work but at reduced holding force due to the lower voltage
DAdding a resistor in series will limit the current to a safe level while still activating the relay
Show answer

Answer: B The GPIO cannot provide the coil's rated 12V and 80mA.

iotclass.org

Retrieval practice

Recall check 3 of 4

Voltage Vera says: answer from memory, then check your reasoning.

Q3Two resistors measured at 10k ohms each divide an ideal 3.3V source to 1.65V at a high-impedance ADC input. Replacing that source with a 3.3V sensor whose output impedance is 1k ohm makes the measured divider output about 1.57V. What caused the discrepancy?

AThe resistors have a 10% tolerance, so 1.50V is within expected range
BThe ADC input draws current that loads the divider and changes the output voltage
CThe sensor's 1k ohm output impedance adds in series with the upper 10k resistor.
DTemperature drift of the resistor values changed the divider ratio
Show answer

Answer: C The sensor's 1k ohm output impedance adds to the upper 10k ohm arm.

iotclass.org

Retrieval practice

Recall check 4 of 4

Voltage Vera says: answer from memory, then check your reasoning.

Q4Q4: material to rated load pathWhat semiconductor junction conducts forward current while blocking reverse current within ratings?

ADiode behavior
BSemiconductor material
CTransistor driver
DDatasheet check
Show answer

Answer: A The junction conducts forward current and blocks reverse current within rated limits.

Q5Q5: GPIO load decision helperComplete the GPIO-to-load safety helper for an electronics overview:

Aneeds_driver = load_current_ma > 12
Bneeds_driver = load_current_ma < 12
Cneeds_driver = is_inductive == False
Dneeds_driver = load_current_ma + 12
Show answer

Answer: A A GPIO pin is a signal source, not a power supply.

iotclass.org

Print reference

Answers

Answer key.

  1. C · Logic-level N-channel MOSFET is the best choice for several reasons: (1) it can handle 1.5A with margin, (2) low Rds(on) keeps conduction loss low, (3) gate current is essentially zero in steady state versus several milliamps for a BJT, and (4) it can be driven directly from a microcontroller only if the datasheet supports low Rds(on) at the available gate voltage. Always check Rds(on) at your actual gate voltage, not just the 10V headline spec.
  2. B · The GPIO cannot provide the coil's rated 12V and 80mA.
  3. C · The sensor's 1k ohm output impedance adds to the upper 10k ohm arm.
  4. A · The junction conducts forward current and blocks reverse current within rated limits.
  5. A · A GPIO pin is a signal source, not a power supply.
iotclass.org