ESP32-WROOM-32
ESP32 Handheld Ultrasonic Distance Meter
Aperçu
A compact handheld USB-powered distance meter built with an ESP32, an HC-SR04 ultrasonic sensor, a 16x2 I2C LCD, and a unit-switching push button.
Architecture système
- POWER → MCUPowerPower supply
Nomenclature
| Référence | Type | Composant | Fabricant | Boîtier | Qté | Fiche technique | Correspondance |
|---|---|---|---|---|---|---|---|
| UJ31-CH-314-SMT-TR | POWER | USB-C Power Jack Power input | Same Sky | - | 1 | Correspondant | |
| ESP32-WROOM-32 | MCU | ESP32-WROOM-32 Main controller | Espressif Systems | Reel | 1 | Correspondant | |
Afficher les 1 alternatives étudiéesprojects.detail.aiVerified | |||||||
Guide de fabrication
Procurement & Preparation
- Source all required electronic components including the ESP32-WROOM-32 module, HC-SR04 ultrasonic sensor, 16x2 I2C LCD display, push button, and UJ31-CH-314-SMT-TR USB-C power jack.
- Prepare the custom PCB and organize the soldering workstation with proper ESD protection.
Hardware Assembly & Wiring
- Solder the UJ31-CH-314-SMT-TR USB-C power jack onto the designated footprint of the PCB, connecting 5V and GND lines to the main power rail.
- Mount and solder the ESP32-WROOM-32 module onto the mainboard, ensuring correct pin alignment with the power and GPIO pads.
- Wire the HC-SR04 ultrasonic sensor to the ESP32 GPIO pins (Trigger to GPIO 5, Echo to GPIO 18, VCC to 5V, GND to GND).
- Connect the 16x2 I2C LCD module to the ESP32 I2C bus (SDA to GPIO 21, SCL to GPIO 22, VCC to 5V, GND to GND) and wire the unit-switching push button to GPIO 4 with an internal pull-up resistor.
Firmware Setup
- Install the Arduino IDE and configure the ESP32 board package along with required libraries including LiquidCrystal_I2C.
- Write and compile the distance meter firmware to read pulse duration from the HC-SR04, compute distance in centimeters and inches, update the 16x2 I2C LCD, and toggle units via the push button interrupt.
- Flash the compiled binary to the ESP32-WROOM-32 via the USB-C interface.
Testing & Calibration
- Power the assembled distance meter via a standard USB-C 5V power supply and verify that the 16x2 I2C LCD initializes successfully with a welcome message.
- Test the unit-switching push button to confirm proper toggling between centimeters and inches on the LCD display.
- Perform distance calibration against known reference measurements (e.g., 20cm, 50cm, 100cm) and adjust the speed of sound calculation constant in the firmware if necessary.
Document
ESP32 Handheld Ultrasonic Distance Meter
A compact handheld USB-powered distance meter built with an ESP32, an HC-SR04 ultrasonic sensor, a 16x2 I2C LCD, and a unit-switching push button.
Design Overview
| Item | Details |
|---|---|
| Product Type | Ultrasonic Distance Meter |
| Key Functions | Measure distance using HC-SR04 ultrasonic sensor, Display distance on 16x2 I2C LCD, Switch between centimeters and inches via push button |
| Power Source | USB-C 5V |
| Connectivity | |
| Size | compact handheld enclosure |
| Environment | indoor |
| Difficulty | Beginner |
| Est. Time | 3-4 hours |
System Architecture
Power Topology: USB-C 5V → MCU 3.3V LDO
Module List
| Module ID | Type | Name | Function | Voltage |
|---|---|---|---|---|
| POWER | POWER | USB-C Power Jack | Power input | 5V |
| MCU | MCU | ESP32-WROOM-32 | Main controller | 3.3V |
Design Schemes
Ultrasonic Distance Meter ★
Key IC selection
main MCU
- Need: Execute timing-critical ultrasonic pulse generation/capture, drive I2C LCD, and handle user input with integrated Wi-Fi/BLE capability if needed.
- Class: 32-bit Wi-Fi/BLE MCU SoC module
- Shortlist: ESP32-WROOM-32, ESP32-S3-WROOM-1
- Pick: Select ESP32-WROOM-32 module based on peripheral availability, cost, and community support for Arduino/ESP-IDF.
power input and regulation
- Need: Accept 5V from USB-C and provide a stable 3.3V rail for the ESP32 and logic levels.
- Class: Low-dropout linear regulator (LDO) or buck converter
- Shortlist: AMS117-3.3, ME6211, RT9013
- Pick: Select a 3.3V 1A LDO with low quiescent current and appropriate package for thermal dissipation from 5V USB input.
Risk register
| ID | Area | Severity | Detail | Mitigation |
|---|---|---|---|---|
| r1 | power | high | HC-SR04 ultrasonic modules typically operate on 5V, while the ESP32 GPIOs are strictly 3.3V tolerant. Direct connection of the HC-SR04 Echo pin (5V logic) to the ESP32 input will damage the MCU. | Implement a resistor voltage divider (e.g., 2k / 1k) or a logic level shifter on the HC-SR04 Echo line before routing to the ESP32 GPIO. |
| r2 | firmware | med | Using standard high-level blocking delays for ultrasonic pulse timing in FreeRTOS can cause inaccurate distance measurements or trigger watchdog resets on the ESP32. | Use hardware pulse counters (PCNT) or input capture interrupts with FreeRTOS task prioritization for accurate echo duration measurement. |
Key Components
2/2 modules matched to real parts. See the BOM tab for the full component table.
USB-C Power Jack (UJ31-CH-314-SMT-TR)
The candidate's MPN matches the primary MPN and the manufacturer is acceptable.
ESP32-WROOM-32 (ESP32-WROOM-32)
Candidate 1 (ESP32-WROOM-32D) is an exact match for the primary MPN prefix with a standard revision suffix from the pref
Build Summary
- Difficulty: Beginner
- Estimated time: 3-4 hours
- Tools required: Soldering iron, Solder wire, Wire stripper, Multimeter, Computer with Arduino IDE, USB-C cable
See the Build tab for the full step-by-step assembly guide.
Generated by YuanQi AI Design System · Query: Distance meter using ESP32, ultrasonic sensor (e.g. HC-SR04), 16x2 LCD with I2C backpack, and one push button. USB powered. Display measured distance; button press switches between cm and inches.