TinySkiff ESP32-S3 Lab · Day 18 of 30

Turn heat into
a number

Today you build a thermometer. A thermistor changes its resistance as the air around it warms or cools, and the ESP32-S3 reads that change and prints the temperature once a second. Pinch the little bead and watch the number climb — the same sensing that tells a skipper the engine room is running warm.

About 25 minutesArduino firstMicroPython optionalNo electronics assumed
Agent assist code TSK-DAY18-THERMOMETER

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

Six things, nothing more. 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 photo of a bead thermistor with two long legs.
Manual photo

Thermistor

A small bead whose resistance falls as it warms — today's sensor.

Official manual photo of a resistor with coloured value bands.
Manual photo

10 kΩ resistor

The steady half of the divider that turns resistance into voltage.

Official manual image of a jumper wire.
Manual photo

3 jumper wires

Temporary, solder-free connections.

Official manual screenshot of the Arduino IDE interface.
Manual screenshot

Arduino IDE

Uploads code 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. Two parts in a line make the divider; one wire taps its midpoint.

Official Freenove circuit — C Tutorial, Chapter 12 (Thermistor), page 123.
10 kΩ resistor leg 3.3V Feeds the divider from a steady 3.3 volts.
Divider midpoint GPIO 1 The ADC pin reads the voltage where resistor meets thermistor.
Thermistor far leg GND Completes the divider's path back to zero volts.

Check before power. The thermistor has no polarity — either leg can face either way — but the midpoint wire must land on GPIO 1. 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 / 10 done
  1. Seat the ESP32-S3 on the GPIO extension board and keep USB unplugged while you wire.

  2. Push the thermistor into the breadboard with its two legs in separate rows.

  3. Place the 10 kΩ resistor so one leg shares a row with one thermistor leg — that shared row is the divider's midpoint.

  4. Run a jumper from 3.3V to the resistor's free leg.

  5. Run a jumper from the midpoint row to GPIO 1.

  6. Run a jumper from the thermistor's free leg to GND.

  7. Compare every wire to the chart, then plug in USB.

  8. Open Sketch_12.1_Thermometer.ino in Arduino IDE and upload it.

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

  10. Pinch the thermistor's bead between two fingers and watch the temperature climb.

Degrees on deck.

Your board is reading real temperature once a second. Head to Test & debug to confirm the numbers make sense.

04 Read just enough code

Read the code

The whole loop is four working lines — a chain that walks from a raw ADC count to volts, to ohms, to degrees. Switch to MicroPython if you'd rather see the same chain in Python; the wiring never changes.

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

void loop() {
  int adcValue = analogRead(PIN_ANALOG_IN);                       //read ADC pin
  double voltage = (float)adcValue / 4095.0 * 3.3;                // calculate voltage
  double Rt = 10 * voltage / (3.3 - voltage);                     //calculate resistance value of thermistor
  double tempK = 1 / (1 / (273.15 + 25) + log(Rt / 10) / 3950.0); //calculate temperature (Kelvin)
  double tempC = tempK - 273.15;                                  //calculate temperature (Celsius)
  Serial.printf("ADC value : %d,\tVoltage : %.2fV, \tTemperature : %.2fC\n", adcValue, voltage, tempC);
  delay(1000);
}
analogRead(PIN_ANALOG_IN)Reads the divider midpoint on GPIO 1 as a number from 0 to 4095.
double Rt = 10 * voltage / (3.3 - voltage)Works the divider maths backwards to recover the thermistor's resistance in kilo-ohms.
log(Rt / 10) / 3950.0The B-equation — B is 3950 for this bead — maps that resistance onto temperature in Kelvin; subtracting 273.15 lands it in Celsius.

05 Understand, don't memorise

Four lines from heat to degrees

The sketch walks one chain, once a second. Each line hands its answer to the next — count to volts, volts to ohms, ohms to degrees.

Read

ADC in

analogRead samples the midpoint and returns a count from 0 to 4095.

Volts

Count → volts

Dividing by 4095 and scaling by 3.3 gives the real voltage at the pin.

Ohms

Volts → ohms

The divider maths recovers the thermistor's resistance from that voltage.

Degrees

Ohms → degrees

The B-equation with B 3950 turns resistance into Kelvin and then Celsius.

The chain ADC count → voltsohmsdegrees

Why resistance moves

A thermistor is made of a material whose electrons flow more freely as it warms, so its resistance drops as temperature rises. At 25 °C this bead sits near 10 kΩ.

What the 10 kΩ partner does

The ADC measures voltage. Stacking the fixed resistor above the thermistor makes a divider whose midpoint voltage tracks the changing resistance — the translation the pin can actually read.

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 value : 2185, Voltage : 1.76V, Temperature : 22.00CADC value : 2100, Voltage : 1.69V, Temperature : 23.85CADC value : 2048, Voltage : 1.65V, Temperature : 24.99C

A steady room line first — somewhere around 20 to 26 °C. Pinch the bead and the temperature climbs a few degrees; let go and it eases back down.

If it doesn't
  • Temperature wildly wrong — near -273 or nan? Check the midpoint wire on GPIO 1 and that the 10 kΩ resistor is in the divider.
  • Values frozen while you pinch? Reseat the thermistor's legs — one has likely lifted out of its row.
  • Garbled text? Set Serial Monitor to 115200 baud to match the sketch.
  • Upload fails? Swap in a data-capable USB cable.

07 Make the idea yours

Try this: keep a temperature log

Same working circuit, one new habit: treating a live number as data worth recording. It fits inside today's 25 minutes.

Morning vs evening

Note the room reading when you start the day and again after dark. A degree or two of drift is real weather moving through your space.

Add Fahrenheit

Add double tempF = tempC * 1.8 + 32; after the Celsius line and print it too — one more field in the printf.

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-DAY18-THERMOMETER

How the agent should behave: guide one physical connection at a time, wait for you to confirm, read the printed numbers to diagnose the divider, and always check wiring, board, port, and USB before changing code.

Field note

Shortcut

Prompt copied