TinySkiff ESP32-S3 Lab · Day 13 of 30

Read a knob
as a number

Today the board learns to measure. You wire a rotary potentiometer — a knob that dials a voltage — to GPIO 1, and the ESP32-S3's ADC turns that voltage into a number between 0 and 4095. Open Serial Monitor and the number follows your hand.

About 20 minutesArduino firstMicroPython optionalNo electronics assumed
Agent assist code TSK-DAY13-ADC

Hand this to an agent so it can pull the lesson packet and coach you step by step.

01 First, know the pieces

What you need

Five things, one of them new. Tap Define on any part you haven't met — the answer opens as a field note you can read and dismiss without losing your place.

Official manual photo of the ESP32-S3 development board.
Manual photo

ESP32-S3 board

The brain that runs your uploaded sketch.

Official manual image of the ESP32-S3 GPIO extension board.
Manual photo

GPIO extension board

Spreads the pins into rows you can reach and label.

Official manual illustration of a rotary potentiometer with rotation arrows and its three pins labelled 1, 3, and 2.
Manual illustration

Rotary potentiometer

The knob — a resistor track with a sliding tap.

Official manual image of a jumper wire.
Manual photo

3 jumper wires (M/M)

Temporary, solder-free connections.

Official manual screenshot of the Arduino IDE interface.
Manual screenshot

Arduino IDE

Uploads the sketch and opens Serial Monitor.

02 Make the physical circuit

Chart the circuit

The official Freenove diagram is your chart — schematic on top, the same circuit built on a breadboard below. Click it to enlarge. Three wires today, and each row below tells you where one goes and why.

Official Freenove circuit — C Tutorial, Chapter 8 (AD Converter), page 96.
Pot outer pin 1 3.3V Feeds one end of the knob's track with full voltage.
Pot outer pin 2 GND Holds the other end of the track at zero volts.
Pot middle pin 3 GPIO 1 The wiper delivers the in-between voltage for the ADC to read.

Keep the pot on 3.3V. GPIO 1 is built to read voltages up to 3.3V, so power the potentiometer from the 3.3V pin — the 5V pin would push the wiper past that limit. Unplug USB before you move any wire.

03 One action at a time

Build it

This is the main path — you can finish the day without opening a single field note. Tap each step as you go to keep your place.

0 / 8 done
  1. Seat the ESP32-S3 on the GPIO extension board and keep USB unplugged while you wire.

  2. Push the potentiometer into the breadboard so each of its three pins has its own row.

  3. Run a jumper from one outer pin to 3.3V and a second jumper from the other outer pin to GND.

  4. Run the third jumper from the middle pin (pin 3) to GPIO 1.

  5. Compare every wire to the chart before you plug in USB.

  6. Open Sketch_08.1_ADC.ino in Arduino IDE and upload it.

  7. Open Serial Monitor and set the baud rate to 115200.

  8. Turn the knob slowly from one end to the other and watch the numbers sweep.

The board can feel a dial.

Turn the knob and the numbers follow your hand. Head to Test & debug to confirm the full sweep.

04 Read just enough code

Read the code

The working part of the sketch is four lines, five times a second — read the pin, do one line of arithmetic, print, wait. Switch to MicroPython if you'd rather see the same idea in Python — the wiring never changes.

Sketch_08.1_ADC.ino
#define PIN_ANALOG_IN  1
void setup() {
  Serial.begin(115200);
}

void loop() {
  int adcVal = analogRead(PIN_ANALOG_IN);
  double voltage = adcVal / 4095.0 * 3.3;
  Serial.printf("ADC Val: %d, \t Voltage: %.2fV\r\n", adcVal, voltage);
  delay(200);
}
analogRead(PIN_ANALOG_IN)Samples the voltage on GPIO 1 and returns a number from 0 to 4095.
adcVal / 4095.0 * 3.3Converts the reading back into volts — 4095.0 is the top reading, so a full turn lands exactly on 3.30V.
Serial.printf("ADC Val: %d, \t Voltage: %.2fV\r\n", adcVal, voltage)Prints the raw reading and the voltage on one line, five times a second.

05 Understand, don't memorise

Voltage in, number out

Two ideas meet today. The potentiometer turns position into voltage, and the ADC turns voltage into a number your code can hold.

Turn

Wiper slides

The knob moves a contact along a track between 3.3V and ground.

Divide

Voltage settles

The middle pin sits at a voltage that matches the knob's position.

Sample

ADC measures

analogRead converts that voltage into a number from 0 to 4095.

Report

Serial prints

The sketch sends the reading and the voltage up the USB cable five times a second.

The conversion voltage = reading ÷ 4095 × 3.3

Why the top is 4095

Twelve bits give 4096 steps numbered 0 through 4095 — so 4095 means the pin sees the full 3.3V, and the code divides by 4095.0 to match.

The knob is a voltage divider

The track splits 3.3V along its length and the wiper taps off the share at its position — a divider you adjust by hand.

06 Know it worked

Test & debug

Success and recovery sit side by side, so you never have to go hunting when something looks off.

What you should see
Serial Monitor115200 baud
ADC Val: 0, Voltage: 0.00VADC Val: 2048, Voltage: 1.65VADC Val: 4095, Voltage: 3.30V

The values track the knob — one end reads near 0, the other near 4095, and every position between prints its own pair.

If it doesn't
  • Stuck at 0 or 4095? Check the middle-pin wire on GPIO 1, then the two outer pins on 3.3V and GND.
  • Garbled or random characters? Set Serial Monitor to 115200 baud to match the sketch.
  • Blank monitor? Confirm the right board and port, then swap in a data-capable USB cable.
  • Reading jitters by a few counts? That's normal for a real ADC — judge by the whole sweep.

07 Make the idea yours

Try this: chart your knob

Same working circuit, one new habit: reading the world through numbers. It fits inside today's 20 minutes.

Find the midpoint

Turn the knob until the reading sits near 2048 — half of 4095. Check the shaft — is it pointing halfway round?

Map the sweep

Pick three positions — a quarter turn, halfway, three quarters — and write down the reading at each. Then hold one position still and watch how steady the number stays.

Logbook

08 Learn it with a hand on the tiller

Coach me through it

Every lesson ships with a code and a machine-readable packet, so an agent can guide you with full context.

Lesson code

TSK-DAY13-ADC

How the agent should behave: guide one wire at a time, wait for you to confirm, explain terms on request, and always check wiring, board, port, and baud rate before changing code.

Field note

Shortcut

Prompt copied