Sensors & Measurement · Study deck

Sensor Circuits: Switching and Interface Safety

A GPIO pin can command a load but cannot safely feed it.

Physics Phoebe is your guide for this deck.

sensorcircuits
Physics Phoebe, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: The design sequence is always the same: (1) convert the sensor's electrical change into a voltage the ADC can read, (2) filter noise before the ADC, (3) amplify or switch the output signal if needed.
  • Explain: The sensor must detect rain onset within 5 seconds so the mower can return to its charging station before the wet grass causes wheel slippage and mowing quality degradation.
  • Explain: Step 3: Design the return-to-station transistor driver: When rain is detected, the MCU must activate a high-current relay (500 mA coil) to engage the homing navigation.
iotclass.org

Major section

Learning Points

Observe:: Start with Current Amplification: Small base current (~1mA) controls large collector current (~20mA).

  • Current Gain (beta):: A small base current controls a larger collector current.
  • For example, a transistor with beta near 100 can let 0.1 mA at the base control about 10 mA through the load.

Why it matters

In a real design, add margin because beta varies strongly between individual transistors and operating conditions.

iotclass.org

Major section

Learning Points

Observe:: Start with Current Limiting: Resistor prevents excessive current that would destroy LED.

  • Ohm's Law gives 150 Ohm, and 150 Ohm or 220 Ohm are common safe choices.

Numbers to remember

150 OhmOhm's Law gives 150 Ohm
220 Ohmand 150 Ohm or 220 Ohm are common safe choices.
iotclass.org

Major section

For Kids: Meet the Sensor Squad!

Temperature Terry was teaching a class about sensor circuits, and the whole squad was paying attention!

  • When I'm an LDR (light sensor), my resistance changes with light, so the voltage in the middle changes too!".
  • The resistor is like the narrow path, and the capacitor is like the sponge.

Key terms

When rain
When rain is detected, the MCU must activate a high-current relay (500 mA coil) to engage the homing navigation.

Numbers to remember

100 msand can activate the homing relay within 100 ms of rain detection.
iotclass.org

Major section

For Kids: Meet the Sensor Squad! (continued)

My GPIO pins are like a small child -- they can push a light doorbell button (small current), but they can't push open a heavy door (big current).

  • Lila here needs exactly the right amount of current -- too much and she burns out!
  • The current-limiting resistor is like a speed bump on a road.
  • Scenario:: Husqvarna is designing a rain detection circuit for the Automower 450X robotic lawnmower.
iotclass.org

Major section

For Kids: Meet the Sensor Squad! (continued)

"And that's it!" Sammy concluded. "Four simple building blocks, and you can connect almost any sensor to any microcontroller.

  • The sensor must detect rain onset within 5 seconds so the mower can return to its charging station before the wet grass causes wheel slippage and mowing quality degradation.
  • Rain sensor: Resistive rain sensor board (exposed PCB traces), resistance varies with wetness.
  • Step 1: Design the voltage divider: The rain sensor is a variable resistor.
  • This provides good voltage range (3.15V to 0.58V across rain conditions) while keeping current well under the 0.5 mA budget.
iotclass.org

Major section

For Kids: Meet the Sensor Squad! (continued)

Step 2: Design the RC noise filter: The motor EMI noise at 20 kHz must be filtered.

  • Step 3: Design the return-to-station transistor driver: When rain is detected, the MCU must activate a high-current relay (500 mA coil) to engage the homing navigation.
  • All four fundamental circuit patterns (voltage divider, RC filter, transistor switch, and protection diode) are used in a single practical design.
  • The design sequence is always the same: (1) convert the sensor's electrical change into a voltage the ADC can read, (2) filter noise before the ADC, (3) amplify or switch the output signal if needed.
iotclass.org

Major section

Divider Resistor Range Mismatch

For a thermistor divider, the fixed resistor should be near the sensor's midrange resistance.

  • If too different, the voltage swing across the operating temperature range is compressed and ADC resolution is wasted.
iotclass.org

Deck summary

Key takeaways

Observe:: Start with Current Amplification: Small base current (~1mA) controls large collector current (~20mA).

  • Observe:: Start with Current Limiting: Resistor prevents excessive current that would destroy LED.
  • Temperature Terry was teaching a class about sensor circuits, and the whole squad was paying attention!
  • My GPIO pins are like a small child -- they can push a light doorbell button (small current), but they can't push open a heavy door (big current).
  • "And that's it!" Sammy concluded. "Four simple building blocks, and you can connect almost any sensor to any microcontroller.
iotclass.org

Retrieval practice

Recall check 1 of 4

Physics Phoebe says: answer from memory, then check your reasoning.

Q1You want to drive a 12V DC motor that draws 200mA using an ESP32 GPIO (3.3V, 12mA max) and a 2N2222 transistor (beta=100). What base resistor value ensures the transistor is fully saturated?

A260 ohms - just enough for 10mA base current
B1.3k ohms - provides 2mA base current for 200mA collector
C10k ohms - limits current to protect the GPIO
D100 ohms - maximum base current for fastest switching
Show answer

Answer: B Correct!

iotclass.org

Retrieval practice

Recall check 2 of 4

Physics Phoebe says: answer from memory, then check your reasoning.

Q2You need to drive a blue LED (forward voltage 3.2V, rated current 20mA) from a 5V supply. What resistor value should you use?

A90 ohms - calculated as (5V-3.2V)/20mA
B250 ohms - calculated as 5V/20mA
C160 ohms - calculated as 3.2V/20mA
DNo resistor needed - the LED has internal resistance
Show answer

Answer: A Correct!

iotclass.org

Retrieval practice

Recall check 3 of 4

Physics Phoebe says: answer from memory, then check your reasoning.

Q3An LDR (200 ohm in bright light, 10 kohm in dark) is placed as R1 (top) in a voltage divider with a 10 kohm fixed resistor R2 (bottom) and 3.3V supply. What happens to the output voltage at the midpoint as it gets darker?

AOutput voltage decreases from 3.24V toward 1.65V
BOutput voltage increases from 3.24V toward 3.3V
COutput voltage stays constant at 1.65V regardless of light
DOutput voltage oscillates between 0V and 3.3V
Show answer

Answer: A Correct!

iotclass.org

Retrieval practice

Recall check 4 of 4

Physics Phoebe says: answer from memory, then check your reasoning.

Q4Place each sensor circuit where it lives in the signal chain so you can choose whether to convert, condition, decide, or protect before the ADC.

AVoltage Divider
BWheatstone Bridge
CAmplifier (Op-Amp)
DLow-Pass Filter
EComparator
FProtection Circuit (TVS/Clamp)
Show answer

Answer: A The signal chain separates resistive conversion, analogue conditioning, and protection so you can choose a circuit for the fault or measurement job it actually performs.

iotclass.org

Print reference

Answers

Answer key.

  1. B · Correct!
  2. A · Correct!
  3. A · Correct!
  4. A · The signal chain separates resistive conversion, analogue conditioning, and protection so you can choose a circuit for the fault or measurement job it actually performs.
iotclass.org