Skip to content

Ultrasonic Sensor

Updated: 6/28/2025 Words: 0 words Reading time: 0 minutes

Ultrasonic waves refer to mechanical sound waves with frequencies higher than the upper limit of human hearing (>20kHz), typically ranging from 40kHz to 10MHz. Ultrasonic waves require elastic media (gas/liquid/solid) for propagation and cannot travel through vacuum. Ultrasonic waves can be used for distance measurement and imaging.

Preparation

Hardware

HardwareDescriptionImage
Creative Box PlatformMy Image
Ultrasonic SensorTaobao Purchase LinkMy Image
Dupont WiresTaobao Purchase Link, please select male-to-female type

Software

SoftwareLinkDescription
Ultrasonic Sensor AppLinkOfficial frontend application, can be loaded and used directly through the console.

Connection

My Image
Connection
Connect the ultrasonic sensor's VCC pin to the platform's 3.3V power supply.
Connect the ultrasonic sensor's GND pin to the platform's GND.
Connect the ultrasonic sensor's trigger pin to any pin on the platform, the diagram shows pin 4.
Connect the ultrasonic sensor's echo signal to any pin on the platform, the diagram shows pin 5.

Note

The ultrasonic sensor you purchase may have the trigger pin and echo pin sharing one pin. In this case, just connect that pin to any pin on the platform and select the same pin number in the application.

Usage

Open the Creative Box console and load the Ultrasonic Distance Measurement application from the sensor applications. Enter the application, fill in the pin numbers for trigger signal and echo signal connections to the Creative Box. Click the start button to begin, and the distance to obstacles ahead will be displayed in the application. Click the stop button to stop distance measurement.

Creative Box ConsoleLoad ApplicationSelect Trigger Signal and Echo Signal Connection PinsStart Distance Measurement

Principles

HC-SR04 Ultrasonic Distance Sensor

The HC-SR04 ultrasonic sensor is a commonly used distance measurement module based on pulse-echo ranging principles. When the module performs distance measurement, it automatically emits 8 pulses of 40kHz ultrasonic waves. The transmitter (T) converts electrical signals into ultrasonic waves, which propagate through air at 343m/s (at 20°C). When they encounter obstacles, they produce reflected echoes. The receiver (R) converts the reflected sound waves into electrical signals. The built-in CX20106A chip performs signal amplification and filtering, outputting a high Echo level when valid echoes are detected.

The HC-SR04 ultrasonic distance sensor emits ultrasonic signals from the transmitter. After the ultrasonic signal is sent out, the receiver captures the returned ultrasonic waves. The distance from the sensor to the obstacle ahead is calculated based on the time between ultrasonic transmission and return.

My Image

Parameters

Parameter NameHC-SR04
Operating Voltage5V
Power ConsumptionNormal supply current is 15mA
Distance Range2cm-400cm
Distance Accuracy0.3cm
Measurement Angle15°

Reference Datasheet Download

Datasheet DownloadLink
HC-SR04Link and Link

Trigger Signal and Echo Signal

First, apply a high-level signal of at least 10 microseconds to the ultrasonic sensor's trigger pin. Upon receiving this signal, the sensor will send ultrasonic signals and wait for the ultrasonic signal to return at the receiver. When the returned ultrasonic signal is received, the sensor calculates the time between sending and receiving the ultrasonic waves, using this time to calculate the distance from the sensor to the obstacle ahead. The greater the distance, the longer the duration of the sensor's return signal.

My Image