ESP32 & analog: the world is more than on and off
420-302-VA · WEEK 8 · FALL 2026

Utility · sources and further reading

Resources

The canonical sources behind this hub: MicroPython's own documentation for everything you type, the chip maker for the silicon, and the encyclopedia for the signal theory. Same rule as every week: when a random tutorial disagrees with these, these win, and for board-specific questions the quick reference is this week's pinout.xyz.

Reference documents

DocumentUse it forNature
MicroPython: ESP32 quick referenceThis week's settling authority: pins, ADC, PWM, timers, every peripheral with working snippets; bookmark it beside the benchOfficial (MicroPython)
MicroPython: ESP32 tutorialGetting started end to end, firmware flashing included, the long-form version of the flashing stepsOfficial (MicroPython)
machine module · machine.ADC · machine.PWMThe precise API contracts: constructors, methods, the attenuation constants, read_u16/read_uv, duty_u16; class documentation you can now read fluently after Week 6Official (MicroPython)
MicroPython firmware downloadsThe firmware itself, per board, for the manual route or for home machines; Thonny fetches from the same sourceOfficial (MicroPython)
Espressif: ESP32The silicon's maker: specifications, datasheet and technical reference for anyone who wants the registers under machineManufacturer
ThonnyThe editor, same as Week 4, now wearing its MicroPython hat; home installationProject site
ESP32 · MicrocontrollerWhat the chip and its species are, with history and contextEncyclopedic
ADC · Quantization · Nyquist–Shannon theoremThe measurement theory behind the staircase figure, at full depthEncyclopedic
Voltage divider · PhotoresistorThe circuit and the sensor, derivations and device physics includedEncyclopedic
PWM · Hysteresis · PID controllerThe actuation and control concepts, from this week's previews to well past Week 10's needsEncyclopedic

Background reading, matched to the stages

StageRead this for the ideas behind it
Meet the ESP32The microcontroller article for the species; the official tutorial as the second telling of flashing and first steps; Espressif's page for the chip's full feature list
Analog inThe ADC article through "resolution"; quantization for the error floor; the machine.ADC page for attenuation and the read family, nonlinearity notes included
Analog outThe PWM article's duty-cycle sections; hysteresis in control applications for the deadband idea at depth
Assignment 2The PID article's overview and "manual tuning" sections, read for shape, not memorization; Week 10 does the rest

A note on board variants

"ESP32" names a family: beside the classic chip in your kit live the S2, S3, C3 and others, differing in cores, radios and pin maps. The course's board is the classic ESP32 DevKit, and this hub's pin numbers and snippets target it; the MicroPython docs flag variant differences inline where they exist. If a home board is a cousin, the concepts transfer completely, the pin numbers may not, and the quick reference plus the board's own markings settle it.

Practice

  • Paper drills. Divider voltages for given LDR values; step sizes for 8-, 10- and 12-bit converters; duty values to percent and back. Each is one formula and thirty seconds; the final in Week 13 likes all three.
  • REPL experiments. The quick reference is a menu: the chip's touch pins, its internal temperature sensor, a second PWM channel, deep sleep. Fifteen minutes of play per week keeps the board familiar instead of ceremonial.
  • Refactor onto the board. Port a Week 4 ladder script to machine: the construct-for-construct translation is the fastest way to feel how little actually changed.
  • Trace with hardware columns. Trace the hysteresis night light through a dusk scenario: columns for the reading, the mode and the LED. Control bugs live exactly where those columns disagree.
  • Work the brief. The highest-value practice this week is the A2 second pass: every verification row drafted is revision, rehearsal and progress at once.

Glossary

TermMeaning
Microcontroller (MCU)A single-chip computer, processor, memory, storage and peripherals together, running one program with no OS.
Single-board computer (SBC)A full computer on one board, the Pi: operating system, filesystem, services.
FirmwareThe program in a device's flash, its entire behaviour from power-on.
FlashingWriting firmware into that flash memory; for us, a once-per-board Thonny operation.
Serial / UARTThe byte-stream link between laptop and board over USB, carried by the bridge chip; the REPL's road.
ADCAnalog-to-digital converter: voltage in, number out.
ResolutionThe converter's bit depth: N bits means 2N distinguishable levels.
Step sizeV_ref / 2N: the voltage width of one count.
Quantization errorThe rounding to the nearest level, at most half a step; the price of finiteness, not a fault.
SamplingMeasuring at discrete instants; the rate bounds what changes are visible.
AttenuationThe ESP32 ADC's input scaling; ATTN_11DB spans roughly the full 0 to 3.3 V.
Voltage dividerSeries resistances splitting a supply in proportion; the bridge from resistance to voltage.
LDR / photoresistorA resistor whose value falls with illumination; large, cheap, nonlinear, calibrated rather than computed.
CalibrationMapping raw counts to meaning via measured anchors; configuration, documented in the repo.
PWMFast on/off switching whose on-fraction sets the delivered average.
Duty cycleThat on-fraction, 0 to 100%; duty_u16 expresses it as 0 to 65535.
Setpoint / process variable / errorThe target, the measurement, and their difference, the vocabulary of every control loop.
Open / closed loopActing without measuring the result, versus correcting on the measured result.
HysteresisTwo thresholds with a deadband, so decisions do not chatter at a boundary.
PIDThe proportional-integral-derivative control law: now, the past, the trend, each weighted.
TelemetryMeasurements reported away from where they were taken; this week a printed line, next week a network message.

← Troubleshoot · Start here · Week 7 hub · Week 4 hub