Week 09 Fab Academy 2026 · Lab Rwanda

Input
Devices

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.

BoardESP32-S3
Analog InputVariable Resistor
Digital InputDHT Sensor
Status✓ Both Reading
Variable ResistorDHT SensorAnalog InputDigital SignalADCSerial MonitorArduino IDEESP32-S3Sensor Reading Variable ResistorDHT SensorAnalog InputDigital SignalADCSerial MonitorArduino IDEESP32-S3Sensor Reading
Overview

Introduction

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.

Analog Variable Resistor
Signal typeContinuous voltage
ESP32 pinADC GPIO
Output range0 – 4095 (12-bit)
Voltage range0 – 3.3 V
Already mounted✓ Yes
Digital DHT 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 01
Variable Resistor — Analog Input ADC · 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.
ESP32-S3 PinoutADC GPIO12-bit ADC
🖼️
Add image — board with variable resistor highlighted
Step 02
Write the Analog Read Firmware
Opened the Arduino IDE, selected the ESP32-S3 board target. Wrote a sketch that reads the ADC value every 500 ms and prints it to Serial. The raw value (0–4095) was also mapped to a voltage (0–3.3V) for easier interpretation.
analogRead()Serial.println()map()Arduino IDE
// Variable Resistor — Analog Read // Connect wiper to ADC-capable GPIO pin const int POT_PIN = 34; // Change to your ADC pin void setup() { Serial.begin(115200); Serial.println("Variable Resistor Read — Starting"); } void loop() { int rawValue = analogRead(POT_PIN); // 0 – 4095 float voltage = rawValue * (3.3 / 4095.0); // map to volts Serial.print("ADC Raw: "); Serial.print(rawValue); Serial.print(" | Voltage: "); Serial.print(voltage, 2); Serial.println(" V"); delay(500); }
Step 03
Upload & Observe Analog Readings
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 (0V), the opposite end ~4095 (3.3V), and the midpoint ~2047 (1.65V). Any deviation indicates a wiring or grounding issue.

🖼️
Add image — Serial Monitor ADC output
🖼️
Add image — hand turning the variable resistor
Sensor 02
DHT Sensor — Digital Input 1-Wire · DHT Library · Temp + Humidity
Step 04
Install the DHT Library
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 requires a 10kΩ pull-up resistor to 3.3V, which was already included in the board design.
DHT Data PinDHT11 / DHT2210kΩ Pull-up
🖼️
Add image — DHT sensor on board highlighted
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
Bonus
Reading Both Sensors Together Combined 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.
Combined Sketch 3 Values Live Output
// Combined — Variable Resistor + DHT Sensor #include <DHT.h> #define POT_PIN 34 #define DHT_PIN 4 #define DHT_TYPE DHT11 DHT dht(DHT_PIN, DHT_TYPE); void setup() { Serial.begin(115200); dht.begin(); Serial.println("Input Devices — Both Sensors Starting"); } void loop() { // --- Analog: Variable Resistor --- int raw = analogRead(POT_PIN); float voltage = raw * (3.3 / 4095.0); // --- Digital: DHT Sensor --- float humidity = dht.readHumidity(); float temperature = dht.readTemperature(); Serial.print("Pot: "); Serial.print(raw); Serial.print(" ("); Serial.print(voltage, 2); Serial.print("V)"); Serial.print(" | Temp: "); if (!isnan(temperature)) { Serial.print(temperature); Serial.print(" C"); } else Serial.print("ERR"); Serial.print(" | Hum: "); if (!isnan(humidity)) { Serial.print(humidity); Serial.print(" %"); } else Serial.print("ERR"); Serial.println(); delay(2000); }
🖼️
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.

Variable Resistor DHT Sensor Analog ADC Digital 1-Wire Arduino IDE Serial Monitor ESP32-S3 Sensor Firmware
← Week 08 · Electronics Production All Assignments →