HC-SR04 Application Guide


I’ll research the HC-SR04’s specifications, wiring, alternatives, and sourcing, then create a cited application guide in the project files. I’ll clearly flag specifications that cannot be verified for this generic module.
Thought for 5 mins 39 sec
Thought for 6 sec
Referenced guidance.
Thought for 8 sec
Created 2 tasks.
1/2 Research sources and write the HC-SR04 application guide.
Accessed knowledge for the next task.
Thought for 18 sec
Awaiting 1 task
Thought for 6 sec
2/2 Check the guide’s completeness, citations, and integration guidance.

Research sources and write the HC-SR04 application guide.

Check the guide’s completeness, citations, and integration guidance.

Accessed knowledge for the next task.
"HC-SR04 Application Guide" completed.
Created and checked the HC-SR04 Application and Usage Guide in the project files, covering all seven requested sections with citations, practical wiring, alternatives, and sourcing guidance. Unverified absolute maximum ratings, temperature limits, and variant-dependent mechanics are explicitly flagged rather than assumed.

HC-SR04 Application and Usage Guide
The HC-SR04 is a low-cost 40 kHz ultrasonic time-of-flight module that reports target distance as the width of a digital Echo pulse. Generic “HC-SR04” modules are produced by multiple vendors, so electrical, mechanical, temperature, and logic-level details must be verified against the exact purchased module rather than inferred from the family name.
1. Quick Specifications
Provenance note: the commonly circulated two-page HC-SR04 document is branded ELECFREAKS but is also mirrored by SparkFun and DigiKey; it does not identify an original HC-SR04 manufacturer, revision, or publication date. Values below are therefore reference values for that documented variant, not guaranteed limits for every marketplace module.

Table


ParameterAbsolute maximum ratingRecommended / nominal operationEvidence and engineering note
Supply voltageNot specified in the reference document5 V DCDo not treat 5 V nominal as an absolute maximum. Some later vendor variants claim 3.3–5 V operation, but that is variant-specific and must not be generalized.
Supply currentNot specified15 mA working currentBudget additional rail margin for startup/transmit transients because the document gives no peak-current limit.
Operating/storage temperatureNot specifiedNot specifiedQualify the exact purchased module over the intended environment; do not copy temperature limits from a different HC-SR04 clone.
Ranging performanceNot an absolute rating2 cm to 4 m; stated measuring angle 15°Range depends strongly on target size, angle, material, air conditions, and acoustic surroundings.
Ultrasonic burstNot applicableEight cycles at 40 kHz after a valid triggerThe table’s “40 Hz working frequency” is ambiguous; the operating description clearly identifies the acoustic burst as 40 kHz.
Module dimensionsNot specified as toleranced limits45 × 20 × 15 mm nominalVerify board outline, transducer height, mounting holes, and connector position on the physical lot before enclosure or carrier-PCB release.
Package / header pitchNot applicableOff-board PCB module; commonly a 1×4, 2.54 mm header, but pitch is variant-dependent and not specified by the ELECFREAKS referenceMeasure the received module or obtain a mechanical drawing. The Flux library contains a separate 2.54 mm HC-SR04 header model, which is useful reference geometry but not proof for every clone.
2. Pinout & Connections
The reference document shows the labeled order VCC, Trig, Echo, GND. Pin numbering is not standardized across all drawings: the table below numbers pins 1–4 left-to-right while viewing the component side with both ultrasonic transducers facing you and the header along the bottom edge; always verify the silkscreen on the actual module before applying power.

Table


Pin NumberPin NameDescriptionBest Practice
1VCC5 V supply input for the documented variant.Use a regulated 5 V rail and confirm the actual module variant before attempting 3.3 V supply operation.
2TrigDigital trigger input; drive HIGH for at least 10 µs.Hold LOW when idle; a 3.3 V MCU output commonly works, but the generic document gives no VIH/VIL limits, so validate logic margin on the purchased lot.
3EchoDigital pulse output whose HIGH duration represents acoustic round-trip time.Treat as 5 V logic unless the exact vendor explicitly states otherwise; translate before connection to a non-5-V-tolerant MCU.
4GND0 V supply return.Connect directly to MCU/system ground with a short return path; verify ground first during bench wiring.
3. Standard Application Circuit
5 V MCU or 5 V-tolerant GPIO
Connect VCC → regulated 5 V, GND → system ground, Trig → MCU output, and Echo → MCU timer/capture input only when that input is explicitly 5 V tolerant. The module document defines Echo only as a TTL-level output and does not specify VOH, source impedance, or clamp behavior, so “5 V tolerant” must come from the MCU datasheet, not assumption.
3.3 V MCU
Power the documented HC-SR04 variant from 5 V and share ground. Drive Trig from a 3.3 V output only after validating that the actual module reliably recognizes it; for Echo, use one of these approaches:
  1. Preferred: a 5 V-tolerant input buffer or level translator whose input accepts 5 V and whose output is powered at 3.3 V.
  2. Simple engineering option: a divider with 10 kΩ from Echo to MCU input and 15 kΩ from MCU input to GND. Derivation: VMCU = VECHO × 15 kΩ / (10 kΩ + 15 kΩ) = 0.60 × VECHO, so a 5.00 V Echo becomes 3.00 V. With independent ±1% resistors, the maximum ratio is 15.15 / (9.90 + 15.15) = 0.6048, or 3.024 V at 5.00 V input; still verify the MCU’s VIH requirement, input leakage, rail tolerance, and absolute maximum voltage. This divider is an engineering recommendation, not an HC-SR04 datasheet requirement.
Supply decoupling engineering recommendation: place 100 nF ceramic in parallel with 4.7–10 µF bulk capacitance between 5 V and GND near the module connector, especially with long jumper wires. These values are practical noise-control recommendations; the reference HC-SR04 document does not mandate external decoupling values.
Trigger, measurement, conversion, and timeout
  1. Keep Trig LOW, then issue a HIGH pulse of at least 10 µs.
  2. The module sends an eight-cycle 40 kHz burst and raises Echo; measure Echo HIGH time with a hardware timer/input-capture peripheral where possible.
  3. Convert pulse width using distance_cm = echo_high_time_µs / 58, distance_in = echo_high_time_µs / 148, or the underlying round-trip equation distance = time × speed_of_sound / 2.
  4. Wait more than 60 ms between triggers to reduce interaction with the preceding burst/echo.
  5. Implement a firmware timeout. A 4 m round trip at 340 m/s is approximately 2 × 4 / 340 = 23.5 ms; an engineering timeout around 30 ms accommodates the documented maximum range while preventing a missing Echo edge from blocking the program. A longer timeout may be required for clone behavior or unusually slow local sound velocity.
For higher accuracy, compensate the speed of sound for ambient conditions and calibrate against known distances; the /58 shortcut assumes approximately 340 m/s and is not a precision environmental model.
4. PCB Layout & Routing Guidelines
  • Keep both transducer faces unobstructed and outside enclosure walls, bezels, cables, and board edges that can reflect energy into the receiver; provide a clear forward acoustic field and test the final enclosure.
  • Treat the module as mechanically variant-dependent: verify its board outline, header pitch/orientation, transducer diameter/height, and mounting-hole locations against the received lot before freezing carrier-PCB holes or enclosure features.
  • Place the recommended 100 nF plus 4.7–10 µF supply capacitors near the module connector and use a short, direct ground return; these are engineering recommendations rather than published HC-SR04 requirements.
  • Route Trig and Echo as ordinary low-speed single-ended signals over a continuous ground reference. Avoid long unshielded leads near motors, relays, switch nodes, and high-current loops; no differential-pair or controlled-impedance routing is required.
  • If multiple ultrasonic sensors are used, separate their trigger times and validate cross-talk in the actual mechanical assembly; acoustic isolation cannot be guaranteed by PCB routing alone.
5. Common Pitfalls / Things to Watch Out For
  1. Unsafe Echo interface: connecting a nominal 5 V Echo output directly to a 3.3 V-only MCU input can violate the MCU absolute maximum rating. Use a verified 5 V-tolerant input, a suitable buffer/translator, or a calculated divider with tolerance and VIH checks.
  2. Treating nominal range as guaranteed: angled, small, soft, porous, curved, moving, or acoustically shadowed targets can give missing or false echoes; triggering faster than the recommended >60 ms interval, omitting a timeout, or operating multiple sensors simultaneously compounds the problem.
These are not drop-in replacements. Connector, pinout, interface, supply, timing, beam pattern, minimum range, optics/acoustics, firmware, and mechanical footprint must all be redesigned or revalidated.

Table


AlternativeVerified characteristicsCompatibility
MaxBotix MB1010-000 LV-MaxSonar-EZ1Branded ultrasonic module; manufacturer lists 2.5–5.5 V operation, 6–254 in range, 1 in resolution, and analog, pulse-width, and asynchronous serial outputs on the official LV-MaxSonar-EZ product family page.Functionally similar ultrasonic rangefinder, but not pin-, protocol-, or footprint-compatible with HC-SR04.
STMicroelectronics VL53L1CXV0FY/1Branded optical time-of-flight IC; 2.6–3.5 V supply, I²C up to 400 kHz, and up to 4 m ranging depending on conditions. ST datasheet DS12385 Rev 8 is dated August 2024.Functionally similar distance sensing, but it is an optical reflowable IC requiring a host driver and optical/mechanical design; not pin-, protocol-, technology-, or footprint-compatible.
7. Sourcing & Purchasing Guide
Because “HC-SR04” is a generic family name used by multiple factories, purchase records should capture seller, claimed manufacturer, product page, photo/revision, logic-voltage statement, and mechanical drawing for every approved source.

Table


AttributeDetails
Primary DistributorsThe Flux library currently links an OSEPP-branded HC-SR04 listing at Mouser and a Universal-Solder Electronics HC-SR04 listing at DigiKey. These are seller/manufacturer-specific products, not proof that all generic modules are equivalent.
Packaging OptionsOSEPP listings describe retail/blister packaging; generic marketplace modules are also sold individually or in multipacks. No universal tape-and-reel, tray, or factory-pack standard exists for HC-SR04 modules, and an ordering suffix should not be inferred without seller documentation.
Standard MOQNo industry-standard MOQ exists. Distributor listings commonly permit single-unit purchases, but MOQ, pack quantity, and price breaks are seller- and date-dependent; confirm on the live listing at order time.
Sourcing AdviceFor prototypes, buy enough units from one traceable lot to characterize 5 V current, 3.3 V Trig recognition, Echo amplitude, timeout behavior, minimum/maximum useful range, beam interactions, and mechanical dimensions. For production, prefer a branded module with a controlled revision and change notification, or select a manufacturer-controlled alternative such as MaxBotix; do not second-source generic HC-SR04 modules without incoming inspection and regression tests.
Sources
  • ELECFREAKS, “Ultrasonic Ranging Module HC-SR04”, revision/date not stated: datasheet PDF hosted by SparkFun; ELECFREAKS-hosted mirror. This is the primary technical reference for HC-SR04 values in this guide, but provenance does not establish a universal original manufacturer.
  • OSEPP Electronics, “OSEPP Ultrasonic Sensor Module,” stock code HC-SR04, page date/revision not stated: official product page.
  • Adafruit, “HC-SR04 Ultrasonic Sonar Distance Sensor + 2 × 10K resistors,” Product ID 3942, document dated 2018-10-02: product guide PDF. Used as corroborating interface guidance that common HC-SR04 Echo is 5 V logic; module sourcing and dimensions can differ.
  • MaxBotix, “LV-MaxSonar-EZ Ultrasonic Sensor Datasheet / Product Family,” live manufacturer documentation, revision/date not exposed on the web page: official datasheet page and official product family page.
  • STMicroelectronics, VL53L1X Datasheet DS12385, Rev 8, August 2024: official datasheet PDF and official product page.
  • Flux library records used to confirm project-library availability: HC-SR04, MB1010-000, and VL53L1CXV0FY/1.
  • 1. Quick Specifications

  • 2. Pinout & Connections

  • 3. Standard Application Circuit

  • 5 V MCU or 5 V-tolerant GPIO

  • 3.3 V MCU

  • Trigger, measurement, conversion, and timeout

  • 4. PCB Layout & Routing Guidelines

  • 5. Common Pitfalls / Things to Watch Out For

  • 6. Popular Alternatives & Equivalents

  • 7. Sourcing & Purchasing Guide

  • Sources