Grade 9 · From USB to Field System: ESP32 water quality
Turbidity and voltage dividers
Follow the student handout to build, test and document this stage of the water-quality system.
Prepared lesson material. Start this task when your teacher introduces it; it is not currently assigned homework.
For this lesson
Read the handout text online
Lesson 8: Turbidity and Voltage Dividers
Build, measure, and protect GPIO2
Grade 9 MYP Design | From USB to Field System
| Name: __________________ | Class / team: __________________ | Date: __________________ |
| Today’s goals • Power the turbidity board from 5V. • Construct and verify a resistor divider. • Read the safe divided signal on GPIO2. |
Key vocabulary
| Term | Working definition |
| turbidity | |
| analog output | |
| voltage divider | |
| raw signal | |
| measurement point | |
| ground | |
| ratio |
| Do not skip the measurement gate GPIO2 stays disconnected until the divider point has been measured below 3.3V. |
1. Wiring netlist
| LM2596.OUT+ (5V) -> TURBIDITY.+LM2596.OUT- -> TURBIDITY.-TURBIDITY switch -> A (analog)TURBIDITY.A/D -> 10kΩ -> DIVIDER_POINTDIVIDER_POINT -> 20kΩ -> GNDDIVIDER_POINT -> ESP32.GPIO2 [ONLY AFTER VOLTAGE CHECK] |
2. Resistor check
| Resistor | Color bands or measured resistance | Position |
| 10kΩ | A/D to divider point | |
| 20kΩ | Divider point to GND |
3. Multimeter gate
| Measurement | Black probe | Red probe | Expected | Measured | Pass? |
| Sensor power | GND | Turbidity + | About 5V | ||
| Raw signal | GND | A/D | 0–about 4.5V | ||
| Safe divider | GND | Divider point | Below 3.3V |
4. Calculation
The divider output fraction is 20k ÷ (10k + 20k) = ____________ of the raw signal.
Expected divider output when raw A/D = 4.5V: __________________________
5. Test code
| #define TURBIDITY_PIN 2const float DIVIDER_MULTIPLIER = 1.5;void setup() { Serial.begin(115200); analogReadResolution(12); analogSetPinAttenuation(TURBIDITY_PIN, ADC_11db); Serial.println("raw,gpio_V,estimated_sensor_V");}void loop() { int raw = analogRead(TURBIDITY_PIN); float gpioV = raw * (3.3 / 4095.0); float sensorV = gpioV * DIVIDER_MULTIPLIER; Serial.print(raw); Serial.print(','); Serial.print(gpioV, 3); Serial.print(','); Serial.println(sensorV, 3); delay(1000);} |
6. Explain the 20kΩ resistor
Why does the 20kΩ resistor connect from the GPIO2 point to ground? Why is a 10kΩ series resistor alone not the same thing?