ESP32-WROOM-32
ESP32 Ultrasonic Distance Meter
概要
An ESP32-based desktop distance meter that measures distance with an HC-SR04 sensor, displays readings on an I2C 16x2 LCD, and toggles units via a push button.
システムアーキテクチャ
- POWER → MCUPowerPower supply
部品表(BOM)
| 型番 | タイプ | 部品 | メーカー | パッケージ | 数量 | データシート | 一致 |
|---|---|---|---|---|---|---|---|
| 105455-0101 | POWER | USB-C Power Jack Power input | Molex | - | 1 | 一致済み | |
| ESP32-WROOM-32 | MCU | ESP32-WROOM-32 Main controller | Espressif Systems | Reel | 1 | 一致済み | |
検討された代替品2件を表示projects.detail.aiVerified | |||||||
組み立てガイド
Procurement & Preparation
- Source all required electronic components including the ESP32-WROOM-32, HC-SR04 ultrasonic sensor, I2C 16x2 LCD display, USB-C Power Jack (105455-0101), push button, and general passive components.
- Prepare the workbench by laying out the soldering iron, solder wire, flux, wire strippers, multimeter, and breadboard or custom PCB.
Hardware Assembly & Wiring
- Solder the USB-C Power Jack (105455-0101) to the power conditioning circuit, routing the 5V and GND power rails to the ESP32-WROOM-32 power input pins.
- Wire the HC-SR04 ultrasonic sensor to the ESP32-WROOM-32, connecting VCC to 5V, GND to GND, Trig to GPIO 5, and Echo to GPIO 18 (using a voltage divider if necessary for the 5V echo signal).
- Connect the I2C 16x2 LCD display to the ESP32-WROOM-32, linking VCC to 5V, GND to GND, SDA to GPIO 21, and SCL to GPIO 22.
- Wire the push button between GPIO 4 and GND, adding an external pull-up resistor or configuring the internal pull-up resistor in firmware to toggle measurement units.
Firmware Setup
- Install the Arduino IDE and add the ESP32 board package via the Board Manager, then install the LiquidCrystal_I2C library for the display.
- Write and compile the firmware code to initialize the HC-SR04 trigger/echo pins, configure the I2C LCD display, read the push button state for unit toggling (Metric/Imperial), and calculate distance.
- Connect the ESP32-WROOM-32 to the computer via USB-C and flash the compiled firmware binary to the microcontroller.
Testing & Calibration
- Power the desktop distance meter via the USB-C port and verify that the I2C 16x2 LCD powers on and displays the boot screen.
- Test distance measuring accuracy by placing objects at known intervals (e.g., 10cm, 50cm, 100cm) in front of the HC-SR04 sensor and observing the LCD output.
- Press the push button to verify that the display successfully toggles distance units between centimeters and inches without resetting the device.
ドキュメント
ESP32 Ultrasonic Distance Meter
An ESP32-based desktop distance meter that measures distance with an HC-SR04 sensor, displays readings on an I2C 16x2 LCD, and toggles units via a push button.
Design Overview
| Item | Details |
|---|---|
| Product Type | Ultrasonic Distance Meter |
| Key Functions | Measure distance using an ultrasonic sensor (HC-SR04), Display distance measurements on a 16x2 LCD with I2C backpack, Switch between centimeters and inches using a push button |
| Power Source | USB 5V |
| Connectivity | |
| Size | Exposed breadboard / dev kit style |
| Environment | indoor |
| Difficulty | Beginner |
| Est. Time | 3-5 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 and Wi-Fi/BLE controller
- Need: Provide dual-core processing, GPIOs for ultrasonic trigger/echo, I2C for LCD, and an input pin for the mode switch button.
- Class: 32-bit Wi-Fi/BLE Microcontroller Module
- Shortlist: Espressif ESP32-WROOM-32, Espressif ESP32-C3-MINI-1
- Pick: Select based on peripheral availability (sufficient GPIOs and hardware I2C) and module availability in current distribution channels.
Risk register
| ID | Area | Severity | Detail | Mitigation |
|---|---|---|---|---|
| r1 | firmware | high | HC-SR04 sensor operates on 5V logic for its trigger and echo pins, while the ESP32-WROOM-32 GPIOs are strictly 3.3V tolerant. | Add a resistor divider (e.g., 1k/2k) or a dedicated logic level converter on the Echo line to protect the ESP32 GPIO from overvoltage. |
| r2 | power | med | USB-C power input directly powers the 5V HC-SR04 and 5V LCD backpack, but the ESP32 module requires an on-board 3.3V LDO regulator. | Ensure the POWER module includes a robust 5V-to-3.3V LDO (e.g., AMS1117-3.3 or RT9013) with adequate bulk capacitance to handle ESP32 Wi-Fi peak current transients, even if Wi-Fi is unused. |
Key Components
2/2 modules matched to real parts. See the BOM tab for the full component table.
USB-C Power Jack (105455-0101)
The candidate's MPN (105455-0101) exactly matches the primary MPN and is the correct USB-C connector component.
ESP32-WROOM-32 (ESP32-WROOM-32)
The candidate MPN 'ESP32-WROOM-32' is an exact match for the primary MPN, and the manufacturer matches Espressif.
Build Summary
- Difficulty: Beginner
- Estimated time: 3-5 hours
- Tools required: Soldering station, Solder wire, Wire strippers, Multimeter, Flush cutters, Computer with Arduino IDE
See the Build tab for the full step-by-step assembly guide.
Generated by YuanQi AI Design System · Query: Distance meter using ESP32, an ultrasonic sensor (e.g. HC-SR04), a 16x2 LCD with I2C backpack, and one push button. LCD displays measured distance; button switches between centimeters and inches. USB powered.