Sensors & Measurement · Study deck
Sensor Circuits: Switching and Interface Safety
A GPIO pin is a software-controlled signal pin.
Physics Phoebe is your guide for this deck.
After studying this chapter
Learning objectives
You will be able to:
- Explain: 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).
- Explain: Step 3: Design the return-to-station transistor driver: When rain is detected, the MCU activates an illustrative 20 mA relay coil to signal the controller.
- Explain: This provides good voltage range (3.15V to 0.58V across rain conditions) while keeping current well under the 0.5 mA budget.
- Explain: Step 2: Design the RC noise filter: The motor EMI noise at 20 kHz must be filtered.
Major section
Learning Points
Current Amplification: Small base current (~1mA) controls large collector current (~20mA).
- Switching Action: Transistor acts as electronic switch (ON/OFF).
- 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.
Major section
Learning Points (continued)
Efficiency: Saturation can reduce transistor power loss.
- Current Amplification: A GPIO limited to about 12 mA can switch a 500 mA load through a suitably rated driver; size base drive from the transistor's saturation data, not active-region gain alone.
- Separate Load Supply: The load can have its own supply if the grounds and ratings are handled correctly.
- Protection: A suitably rated driver and flyback path protect the controller.
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.
- Lila here needs exactly the right amount of current -- too much and she burns out!
Major section
For Kids: Meet the Sensor Squad! (continued)
Rain sensor: Resistive rain sensor board (exposed PCB traces), resistance varies with wetness.
- 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).
- The current-limiting resistor is like a speed bump on a road.
- MCU: ESP32, 3.3V GPIO, 12-bit ADC; usable input range depends on attenuation and calibration.
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.
- Illustrative scenario: A robotic mower needs to detect rain onset within 5 seconds and signal its controller to return to a charging station.
- Step 1: Design the voltage divider: The rain sensor is a variable resistor.
- The rain signal changes slowly (seconds), so a low cutoff frequency is acceptable.
Major section
For Kids: Meet the Sensor Squad! (continued)
This provides good voltage range (3.15V to 0.58V across rain conditions) while keeping current well under the 0.5 mA budget.
- Step 2: Design the RC noise filter: The motor EMI noise at 20 kHz must be filtered.
- With the 47 kOhm/10 kOhm divider connected directly, its 8.25 kOhm Thevenin resistance adds to the filter resistance: the effective time constant is about 18.25 ms and the cutoff about 8.72 Hz.
- Step 3: Design the return-to-station transistor driver: When rain is detected, the MCU activates an illustrative 20 mA relay coil to signal the controller.
Deck summary
Key takeaways
Current Amplification: Small base current (~1mA) controls large collector current (~20mA).
- Efficiency: Saturation can reduce transistor power loss.
- Temperature Terry was teaching a class about sensor circuits, and the whole squad was paying attention!
- Rain sensor: Resistive rain sensor board (exposed PCB traces), resistance varies with wetness.
- "And that's it!" Sammy concluded. "Four simple building blocks, and you can connect almost any sensor to any microcontroller.
Retrieval practice
Recall check 1 of 4

Physics Phoebe says: answer from memory, then check your reasoning.
Q1You want to switch a 200mA motor from a 3.3V GPIO assumed to supply at most 12mA, using a 2N2222 transistor. Which conclusion about a beta=100 estimate is justified?
Show answer
Answer: B see answers page
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?
Show answer
Answer: B R = (Vsupply - Vf) / If = (5V - 3.2V) / 0.02A = 90 ohms. Use the nearest standard value like 100 ohms.
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?
Show answer
Answer: D Vout = 3.3V x R2/(R1+R2). Bright: 3.3 x 10k/10.2k = 3.24V. Dark: 3.3 x 10k/20k = 1.65V. Higher R1 means more voltage drops across the LDR, leaving less at the output.
Retrieval practice
Recall check 4 of 4

Physics Phoebe says: answer from memory, then check your reasoning.
Q4What turns a changing sensor resistance into a measurable node voltage?
Show answer
Answer: D It turns one changing resistance into a measurable node voltage.
Print reference
Answers 1 of 2
Answer key.
- B · 200mA/100 = 2mA is an active-region estimate; (3.3V-0.7V)/2mA = 1.3kohm. The P2N2222A data sheet tests saturation at a forced ratio of 10, requiring about 20mA for 200mA, beyond the assumed 12mA GPIO budget. Use a suitable MOSFET or driver for this motor.
- B · R = (Vsupply - Vf) / If = (5V - 3.2V) / 0.02A = 90 ohms. Use the nearest standard value like 100 ohms.
Print reference
Answers 2 of 2
Answer key.
- D · Vout = 3.3V x R2/(R1+R2). Bright: 3.3 x 10k/10.2k = 3.24V. Dark: 3.3 x 10k/20k = 1.65V. Higher R1 means more voltage drops across the LDR, leaving less at the output.
- D · It turns one changing resistance into a measurable node voltage.