

The M5 U172 Distance Sensor is an ultrasonic sensor designed to measure the distance to an object by emitting sound waves and calculating the time it takes for the echo to return. This sensor is highly reliable and accurate, making it ideal for applications requiring precise distance measurements. It is commonly used in robotics, automation systems, and IoT projects for tasks such as obstacle detection, proximity sensing, and level measurement.








The M5 U172 Distance Sensor is designed to provide accurate and consistent distance measurements. Below are its key technical details:
| Parameter | Specification |
|---|---|
| Operating Voltage | 3.3V to 5V DC |
| Operating Current | ≤ 15mA |
| Measuring Range | 2 cm to 400 cm |
| Measuring Angle | 15° |
| Accuracy | ± 3 mm |
| Output Signal | Digital pulse |
| Operating Temperature | -15°C to 70°C |
| Dimensions | 45 mm x 20 mm x 15 mm |
The M5 U172 Distance Sensor has a simple 4-pin interface for easy integration into circuits. Below is the pinout description:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (3.3V to 5V DC) |
| 2 | TRIG | Trigger pin to initiate ultrasonic pulse |
| 3 | ECHO | Echo pin to receive the reflected signal |
| 4 | GND | Ground connection |
VCC pin to a 3.3V or 5V power source and the GND pin to the ground.TRIG pin to initiate an ultrasonic burst.ECHO pin. This duration corresponds to the time taken for the sound wave to travel to the object and back.0.034 represents the speed of sound in cm/µs, and the division by 2 accounts for the round trip of the sound wave.Below is an example of how to use the M5 U172 Distance Sensor with an Arduino UNO:
// Define pins for the M5 U172 Distance Sensor
const int trigPin = 9; // TRIG pin connected to digital pin 9
const int echoPin = 10; // ECHO pin connected to digital pin 10
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
// Set pin modes
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
// Send a 10 µs HIGH pulse to the TRIG pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Measure the duration of the HIGH signal on the ECHO pin
long duration = pulseIn(echoPin, HIGH);
// Calculate the distance in cm
float distance = (duration * 0.034) / 2;
// Print the distance to the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// Wait before the next measurement
delay(500);
}
No Output or Incorrect Readings
Fluctuating Distance Measurements
VCC and GND pins.Sensor Not Detecting Objects
Slow Response Time
Q: Can the M5 U172 Distance Sensor detect transparent objects?
A: Ultrasonic sensors may struggle to detect transparent objects like glass due to poor sound wave reflection. Consider using alternative sensors for such applications.
Q: What is the maximum sampling rate of the sensor?
A: The sensor can take approximately 20 measurements per second, depending on the processing speed of the microcontroller.
Q: Can I use the sensor with a 3.3V microcontroller?
A: Yes, the sensor is compatible with both 3.3V and 5V systems.
Q: How do I extend the sensor's range?
A: The range is hardware-limited to 400 cm. For longer distances, consider using a different sensor model.
By following this documentation, you can effectively integrate the M5 U172 Distance Sensor into your projects and troubleshoot common issues with ease.