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

2 pages · Use the handout for the complete instructions, examples and response spaces.

Read the handout text online

For diagrams, visual examples and the full layout, open the handout above.

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

TermWorking 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

ResistorColor bands or measured resistancePosition
10kΩA/D to divider point
20kΩDivider point to GND

3. Multimeter gate

MeasurementBlack probeRed probeExpectedMeasuredPass?
Sensor powerGNDTurbidity +About 5V
Raw signalGNDA/D0–about 4.5V
Safe dividerGNDDivider pointBelow 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?