Reading analog and digital sensor data from the custom ESP32-S3 board — a variable resistor for analog input and a DHT sensor for digital temperature and humidity.
Input Devices week is about making a microcontroller board listen to the world — reading real physical signals and turning them into usable data. On my custom ESP32-S3 board, I had already mounted two input devices during Electronics Production week: a variable resistor for analog input and a DHT sensor for digital input.
This week I wrote firmware to read both sensors, observed their signals on the Serial Monitor, and understood the fundamental difference between how analog and digital inputs work at the hardware and software level.
AnalogVariable Resistor
Signal typeContinuous voltage
ESP32 pinADC GPIO
Output range0 – 4095 (12-bit)
Voltage range0 – 3.3 V
Already mounted✓ Yes
DigitalDHT Sensor
Signal type1-Wire digital
ESP32 pinDigital GPIO
MeasuresTemp + Humidity
ProtocolSingle-wire serial
Already mounted✓ Yes
This Week
Assignments
Group Assignment Probe an input device's analog levels and digital signals.
As a group, we used an oscilloscope and multimeter to observe real signal behavior — measuring the continuous voltage output from a potentiometer as it was turned, and capturing the single-wire data bursts from a DHT sensor to understand the digital timing protocol.
Individual Assignment Measure something: add a sensor to a microcontroller board that you have designed and read it.
For my individual work, I wrote firmware for the custom ESP32-S3 board to read both the variable resistor (analog ADC) and the DHT sensor (digital 1-wire) and print live readings to the Serial Monitor.
Concepts
Analog vs Digital Input
Understanding the difference between how these two sensors communicate with the microcontroller is fundamental to embedded systems design.
〰️
Analog Signal
The variable resistor outputs a continuous voltage between 0 and 3.3V depending on its position. The ESP32-S3's built-in 12-bit ADC converts this voltage into a number from 0 to 4095, which the firmware reads with analogRead().
📶
Digital Signal
The DHT sensor encodes temperature and humidity as a timed sequence of high and low pulses on a single wire. The DHT library decodes this timing protocol and returns structured values — no analog-to-digital conversion needed.
🖥️
Serial Monitor
Both sensors output their readings over USB to the Arduino IDE Serial Monitor — the primary tool for verifying sensor data in real time without any external display hardware.
Process
Step-by-Step
Both sensors were already physically mounted on the board from Electronics Production week, so this week was purely about firmware — writing, uploading, and verifying the code for each input type.
Sensor 01Variable Resistor — Analog InputADC · GPIO · analogRead()
Step 01
Identify the ADC Pin
Checked the ESP32-S3 schematic from Electronics Design week to confirm which GPIO pin the variable resistor wiper is connected to. The ESP32-S3 has a 12-bit ADC on several GPIO pins — the wiper output of the resistor divider feeds directly into one of these ADC-capable pins. the variable resistor is connected to pin 35.
ESP32-S3 PinoutADC GPIO12-bit ADC
Step 02
Write the Analog Read Firmware
Opened the Arduino IDE, selected the ESP32 dev module board target. Wrote a sketch that reads the ADC value every 200 ms and prints it to Serial. The raw value (0–4095) was also mapped to 180 Degrees (0–180) for easier interpretation.
Uploaded the sketch using the BOOT + EN button sequence. Opened the Serial Monitor at 115200 baud. Slowly turned the variable resistor through its full range and watched the ADC value sweep from near 0 to near 4095, with voltage tracking from 0 to 3.3V in real time.
Serial Monitor115200 BaudLive ADC Values
Expected behavior: Rotating the resistor to one end should give ~0 (0 Deg), the opposite end ~4095 (180 Deg), and the midpoint ~2047 (90 Deg). Any deviation indicates a wiring or grounding issue.
Opened the Arduino IDE Library Manager and searched for DHT sensor library by Adafruit. Installed it along with the Adafruit Unified Sensor dependency. This library handles the timing-critical single-wire protocol automatically, so the firmware only needs to call simple read functions.
Library ManagerAdafruit DHTUnified Sensor
🖼️
Add image — Library Manager DHT install
Step 05
Identify the DHT Data Pin & Type
Referred back to the board schematic to confirm the GPIO pin connected to the DHT sensor's data line, and verified whether the sensor is a DHT11 or DHT22 — they use the same protocol but the library constant differs between them. The data pin is connected to GPIO 14, which was already included in the board design.
DHT Data PinDHT11 / DHT22GPIO
Step 06
Write the DHT Read Firmware
Wrote a sketch that initializes the DHT sensor and reads temperature and humidity every 2 seconds — the minimum polling interval required by the DHT protocol. Both values are printed to the Serial Monitor with clear labels.
DHT.hreadTemperature()readHumidity()Serial Output
// DHT Sensor — Digital Read
// Temperature & Humidity
#include <DHT.h>
#define DHT_PIN 4 // Change to your data pin
#define DHT_TYPE DHT11 // DHT11 or DHT22
DHT dht(DHT_PIN, DHT_TYPE);
void setup() {
Serial.begin(115200);
dht.begin();
Serial.println("DHT Sensor Read — Starting");
}
void loop() {
delay(2000); // DHT needs min 2s between reads
float humidity = dht.readHumidity();
float temperature = dht.readTemperature(); // Celsius
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" °C | Humidity: ");
Serial.print(humidity);
Serial.println(" %");
}
Step 07
Upload & Observe DHT Readings
Uploaded the sketch and opened the Serial Monitor at 115200 baud. Confirmed temperature and humidity values appeared every 2 seconds and were reasonable for the room environment. Breathed lightly on the sensor to verify the humidity reading responded — a quick real-world sanity check.
Serial MonitorTemperature °CHumidity %Live Readings
Result: Temperature and humidity readings updated every 2 seconds and responded correctly to changes in the environment — confirming the DHT sensor, data pin, pull-up resistor, and library are all working correctly.
🖼️
Add image — Serial Monitor DHT output
🖼️
Add image — DHT sensor on board close-up
BonusReading Both Sensors TogetherCombined sketch · single Serial output
Step 08
Combined Firmware — Both Sensors
Merged both sketches into a single firmware that reads and prints the variable resistor value and the DHT temperature and humidity in one loop. This gives a live dashboard of all three measurements simultaneously in the Serial Monitor.
Add image — Serial Monitor with all three readings
Results
Measurements
ADC Resolution
12bit
ADC Range
0 – 4095
Voltage Range
0 – 3.3V
DHT Poll Rate
2s
Analog Status
✓ Reading
Digital Status
✓ Reading
Takeaways
Conclusion
This week made the distinction between analog and digital inputs very concrete. The variable resistor gives a smooth, continuous voltage that the ESP32-S3's ADC converts into a 12-bit number — simple to read but sensitive to noise and supply voltage variation. The DHT sensor communicates through a precise timing protocol that the library handles, delivering clean, calibrated temperature and humidity values over a single wire.
Having both sensors already mounted from Electronics Production week meant all the focus could go into firmware — understanding what analogRead() actually returns and what the DHT library is doing under the hood when it decodes those 1-wire pulses.