Skip to content

The Four-Question Module Selection Framework

The Four-Question Module Selection Framework

Choosing an electronic module is not about memorising part lists — it is about answering four fixed questions. This section gives you a reusable decision framework. By the end, you will be able to:

  • Judge in minutes whether any module can be connected to your board
  • Classify modules by signal type (digital input, analogue, 1-Wire, I2C, SPI, UART, PWM)
  • Decide whether a 3.3 V / 5 V level shift is required, and where it belongs
  • Turn the result into a table that goes straight into a BOM and a quotation

Before starting this section, make sure you:

  • Know what GPIO, ADC, I2C, SPI and UART mean (see Chapter 01)
  • Have an ESP32-series dev board and a few jumper wires at hand
  • Know how your board is powered (USB 5 V or battery 3.3 V / 4.2 V)

Answer these in order before touching any module:

Question Answer you need Cost of getting it wrong
1. What is it Part category and physical principle (resistance change, charge, infrared radiation, echo timing…) You cannot migrate to another part number
2. How does it work External conditions it requires: supply voltage, pull-ups, divider network, timing, warm-up window Wiring looks right, yet no reading appears
3. What signal does it output High/low level, PWM, analogue voltage, 1-Wire timing, I2C/SPI/UART frame Wrong pin choice, wrong driver library
4. How does it reach the MCU Which peripheral it occupies, how many pins, level shifting needed, bus sharing Hardware respin, sometimes a destroyed board

Questions 1 and 2 decide whether you can measure anything at all. Questions 3 and 4 decide whether it stays reliable once connected. Most tutorials only cover 3 and 4 — which is exactly why copied code fails to reproduce.

Digital input: buttons, limit switches, hall sensors, IR receiver data pin, PIR motion sensors. They take one GPIO input; watch for pull-up/pull-down configuration and debounce.

Analogue: potentiometers, NTC thermistors, LDR photoresistors, MQ-series gas sensors, flame sensors, photodiodes. They output a voltage, so they must go through a divider network into the ADC.

1-Wire: DS18B20 temperature sensors and similar addressable devices. One data line plus a 4.7 kΩ pull-up; the driver library handles the timing.

I2C: BH1750 (0x23), BME280 (0x76/0x77), SSD1306 OLED (0x3C), MPU6050 (0x68), VL53L0X laser rangefinder. Two wires, many devices, distinguished by address; bus pull-ups are usually already on the breakout board.

SPI: colour TFT displays (ILI9341, ST7789), SD cards, some Ethernet modules. Fast but pin-hungry — pin budget and chip select are the main constraints.

UART: GPS modules, Bluetooth modules, and “finished sensor boards” that hide a complex protocol behind a serial port. Two pins, the least effort to integrate.

PWM / timing-critical output: servos (50 Hz pulse width), passive buzzers, WS2812 addressable LEDs. These are outputs with strict waveform requirements, not inputs.

  • ESP32, ESP32-S3 and ESP32-C3 GPIO are not 5 V tolerant. Anything that outputs a 5 V logic level (HC-SR04 Echo pin, a 5 V Arduino-class board, the opto side of some relay modules) must be divided down or level-shifted before it reaches an ESP32 pin.
  • The other direction is usually fine — driving a nominally 5 V device with a 3.3 V output. The risk is threshold margin: WS2812B specifies VIH ≈ 0.7 × VDD, i.e. about 3.5 V at 5 V supply, which a 3.3 V signal does not reliably clear. Use a one-way level shifter, or run the LEDs from 3.3 V.
  • ADC range limits: on the original ESP32 the ADC is non-linear near full scale and the pin voltage must never exceed 3.3 V (attenuation settings cover part of the range). Measuring anything above 3.3 V requires an external divider, and the ratio must appear in your conversion code.
  • A pitfall unique to the original ESP32: ADC2 cannot be used while Wi-Fi is active. Analogue sampling on ADC2 pins returns nothing useful once the radio is up. Prefer ADC1 pins (the GPIO32–39 family), and re-check the pin map in the datasheet when moving to S3 / C6 / P4.

The first two bullets are hard rules in our prototyping stage — breaking either can kill a board. The last two decide whether your readings can be trusted.

The selection table: four questions as a deliverable

Section titled “The selection table: four questions as a deliverable”

The output of this framework is a table. In our projects it is the first technical deliverable, with fixed columns:

Module Function Signal type Peripheral Pins Supply Level shift Pull-up / divider Notes
Button Start / stop Digital input GPIO input 1 3.3 V No Internal pull-up + software debounce Contact bounce ≈ 5–10 ms
NTC thermistor Temperature Analogue ADC 1 3.3 V No Divider with fixed resistor Calibrate B-value or use lookup table
DS18B20 Precise temperature 1-Wire GPIO 1 3.3 V / 5 V Required if powered at 5 V 4.7 kΩ pull-up Multiple sensors can share one line
BH1750 Ambient light level I2C I2C 2 3.3 V No On-board pull-ups Address 0x23
HC-SR04 Distance Digital (Trig/Echo) GPIO 2 5 V Echo must be divided — Roughly 2 cm – 4 m range
MQ-2 Smoke and combustible gas Analogue + digital ADC + GPIO 2–3 5 V Digital output needs dividing Heater draws real current Raw value ≠ concentration; calibration required
SG90 servo Angle output PWM GPIO + timer 1 5 V (separate supply) Common ground required — Stall current spikes need their own supply

This table becomes the BOM and the wiring sheet, and it is also how a customer tells whether you design or merely copy.

Self-test: fill the four questions for three modules

Section titled “Self-test: fill the four questions for three modules”

Take three modules at hand (suggested: one button, one analogue device, one I2C device) and fill the template below. An empty cell means you do not own that part yet.

Module name:
1. What is it:
2. How does it work (supply, required external parts):
3. What signal does it output (level / analogue / timing / protocol):
4. How does it reach the MCU (peripheral, pins, level shift, pull-up or divider):
Alternative part numbers:
Risk of shipping without selection work:

Pass criteria:

Check Expected result Verified
Question 4 names concrete GPIO numbers e.g. GPIO4 input, GPIO32 (ADC1)
Level-shifting requirement stated explicitly Any 5 V output must list a shifting scheme
I2C device: address plus conflict-check method e.g. 0x23, confirmed by an I2C scanner
Analogue device: divider ratio and formula e.g. raw × 3.3 / 4096 × (R1+R2)/R2

With a button and an NTC in a minimal readable system, power-on should show:

Terminal window
# Serial monitor at 115200
Button pressed -> state goes 1 to 0 (internal pull-up)
No further flips within 200 ms after release (debounce works)
Warm the NTC by hand -> ADC value rises monotonically, no step jumps

If readings jump, check supply and common ground before you blame the code.

Issue 1: module does nothing, although the code is the official example

Section titled “Issue 1: module does nothing, although the code is the official example”

Symptoms: library compiles, but there is no output, or the value is constant.

Possible causes:

  • Question 2 was skipped — the module’s external conditions were never provided (pull-up, divider, heater warm-up, enable pin)
  • Power and data pins swapped (many breakout boards place VCC/GND at the far end)
  • I2C address differs from the example (the same chip ships at different addresses on different boards)

Solutions:

  1. Run a bus scan first (I2C scanner, UART loopback, GPIO level readout) to confirm the physical layer
  2. Open the schematic of that breakout board and check whether pull-ups or a level shifter are already fitted
  3. MQ-series sensors need 24 h or more of warm-up before the baseline is stable — do not call that a defect

Issue 2: works standalone, analogue readings die once Wi-Fi connects

Section titled “Issue 2: works standalone, analogue readings die once Wi-Fi connects”

Symptoms: ADC is fine while offline; after joining a network the values are 0 or frozen.

Possible cause: ADC2 conflicts with the Wi-Fi radio on the original ESP32.

Solutions:

  1. Move the sampling pin into the ADC1 group
  2. If the pin cannot move, use an external ADC (ADS1115 over I2C, 16-bit — it also fixes range and noise)
  3. When moving to S3 / C6 / P4, re-check that chip’s pin map instead of reusing original-ESP32 habits

Issue 3: it reads fine but the board occasionally hangs or reboots

Section titled “Issue 3: it reads fine but the board occasionally hangs or reboots”

Symptoms: the board restarts when a servo or relay acts, or locks up after tens of minutes.

Possible causes:

  • Actuator inrush collapses the supply (servo stall current can reach hundreds of milliamps)
  • Inductive loads (relays, motors) kick back into the supply rail
  • A 5 V device sharing supply with a 3.3 V board, causing brown-out reset

Solutions:

  1. Power actuators separately and tie common ground with the controller; never take that current from the board’s 3.3 V pin
  2. Add a flyback diode across relay coils; isolate motor drivers from the MCU with an optocoupler or level shifter
  3. Once supplies are split, record it in the wiring sheet as a permanent “power domain” column
  • ✅ Do: fill the four-question table before writing code; if a cell is empty, do not place the order
  • ✅ Do: keep “level shift required?” and “power domain” as fixed columns in every wiring sheet, so the rules accumulate
  • ✅ Do: prefer an I2C digital-output variant over a bare analogue part (BH1750 rather than a raw LDR) to avoid calibration work
  • ✅ Do: list at least one alternate part number per module, so a supply interruption does not restart the design
  • ❌ Don’t: feed a 5 V output straight into an ESP32 pin (neither original nor S3/C3 is 5 V tolerant)
  • ❌ Don’t: power actuators from the dev board’s 3.3 V / 5 V header pin
  • ❌ Don’t: copy pin numbers from an example without re-checking them on your specific board (the same chip is wired out very differently across boards)

Key points of this section:

  1. Four questions: what it is / how it works / what signal it outputs / how it reaches the MCU. The first two decide measurability, the last two decide long-term reliability
  2. Seven signal classes: digital input, analogue, 1-Wire, I2C, SPI, UART, PWM output — these cover practically every common module
  3. Level rules: ESP32 GPIO is not 5 V tolerant; a 5 V output must be divided or shifted, and driving 5 V devices from 3.3 V depends on threshold margin
  4. Original-ESP32 pitfall: ADC2 cannot be used with Wi-Fi — sample on ADC1
  5. The selection table is a deliverable: fixed columns (function, signal type, peripheral, pin count, supply, level shift, pull-up/divider, alternates) feed straight into BOM and quotation

The next sections go module by module, starting with digital inputs: buttons, joysticks and debounce.


Building a commercial IoT product?

We provide ESP32 ODM design-to-manufacturing services. From prototype to production — the team behind this tutorial can build it with you.

💡 Mention tutorial.imagrove.com in your Alibaba chat with us — get 10% off your custom project quote.

Talk to us →

First published attutorial.imagrove.com/sensor-module-selection/01-the-four-question-module-selection-framework/Please credit Imagrove and link back to this page when quoting or republishing.

Questions or issues with this tutorial?

Sign in with GitHub to leave a comment. If a step fails for you, tell us — we verify it and update the tutorial.