Ultrasonic Sensor

Principle

The ultrasonic sensor is a device widely used for distance measurement and object detection. It primarily consists of a transmission section, a reception section, and a control section. The core component is a piezoelectric crystal, which vibrates rapidly when stimulated by voltage, emitting ultrasonic signals.

During operation, the sensor first emits a series of high-frequency ultrasonic pulses through its transmission section. These waves reflect back when they encounter an object and are captured by the reception section. The control section then analyzes the received signal and calculates the distance to the object based on the time difference between signal emission and reception.

The ultrasonic sensor offers the advantage of non-contact measurement and can operate stably in various environments. It is widely used in fields such as automation equipment, robotics, liquid level detection, and traffic monitoring.

Specifications

Item

Description

Name

Ultrasonic Sensor

Code

B0020012

Dimensions

47×43 mm

Voltage

5V - DC

Data Type

Analog Signal

Data Range

2~400 cm

Ports

Grove

Usage

Side View

Front View

Side View

Ultrasonic Sensor Connection Diagram

The ultrasonic sensor can be connected to the general-purpose sensor ports of the micro: bit smart hub, including P0-P13, P1-P14, P2-P15, P7-P8, P9-P12, and P10-P16. It is programmed for distance measurement tasks.

The sensor measures the distance between an object and itself. Once installed in a fixed position, it emits ultrasonic pulses and receives reflected waves to calculate distance based on the time difference. Proper sensor placement is crucial to avoid interference from obstacles. Environmental factors like temperature, humidity, and airflow can affect sensor performance. Additionally, the shape, material, and surface smoothness of the detected object impact wave reflection; flat and hard surfaces reflect sound waves more effectively.

Modular Coding

Using the MakeCode coding software, the Microbit extension allows for coding to read signal values from ports such as P0 and P13. The data can be visualized on the micro: bit LED matrix display.

The ultrasonic sensor’s return values can be expressed in three units:

  • Centimeters (cm): Measures distance in metric units.

  • Microseconds (µs): Indicates the time taken for the ultrasonic wave to travel from emission to reception.

  • Inches (in): Represents distance in imperial units.

By measuring the echo time, the corresponding distance can be calculated using the speed of sound, enabling precise measurement of the target object.