Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use M5 U172 Distance Sensor: Examples, Pinouts, and Specs

Image of M5 U172 Distance Sensor
Cirkit Designer LogoDesign with M5 U172 Distance Sensor in Cirkit Designer

Introduction

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.

Explore Projects Built with M5 U172 Distance Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino UNO-Based Ultrasonic Distance Sensor with OLED Display and SIM900A Communication
Image of SENSOR: A project utilizing M5 U172 Distance Sensor in a practical application
This circuit is a distance measurement and communication system using an Arduino UNO, an ultrasonic sensor, an OLED display, and a SIM900A module. The ultrasonic sensor measures the distance to an object, which is then displayed on the OLED screen and transmitted via the SIM900A module. The system is powered by a 18650 Li-ion battery.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO-Based Ultrasonic Security System with SIM800L GSM Module
Image of Home security system: A project utilizing M5 U172 Distance Sensor in a practical application
This circuit features an Arduino UNO connected to an HC-SR04 ultrasonic sensor for distance measurement and a SIM800L GSM module for communication. The Arduino controls an LED, which lights up based on the distance detected by the ultrasonic sensor. When a certain distance threshold is exceeded, the Arduino uses the SIM800L module to make a phone call, indicating motion detection. A 48V to 5V converter supplies power to the SIM800L and the ultrasonic sensor.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO Based Ultrasonic Distance Measurement with TM1637 Display
Image of UNDERWATER SENSOR: A project utilizing M5 U172 Distance Sensor in a practical application
This circuit is designed to measure distance using the JSN-SR04T ultrasonic sensor and display the measured value on a TM1637 4-digit 7-segment display. The Arduino UNO serves as the central controller, running code to operate the sensor, calculate the distance, and update the display. The sensor's TRIG and ECHO pins are connected to digital pins D12 and D11 of the Arduino, respectively, while the display's CLK and DIO pins are connected to digital pins D3 and D4, with both the sensor and display sharing power and ground connections with the Arduino.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino-Controlled Robotic Vehicle with Ultrasonic Obstacle Avoidance
Image of CIRCUIT DIAGRAM FOR TROLLY CART: A project utilizing M5 U172 Distance Sensor in a practical application
This circuit is designed for a mobile robot with ultrasonic distance sensing and motor control capabilities. It uses an Arduino UNO with a sensor shield to interface with an HC-SR04 ultrasonic sensor for distance measurements and a L298N motor driver to control four gearmotors for movement. The robot can move forwards and backwards, and turn left or right, with the ability to measure distances and adjust its path accordingly, as programmed in the embedded code.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with M5 U172 Distance Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of SENSOR: A project utilizing M5 U172 Distance Sensor in a practical application
Arduino UNO-Based Ultrasonic Distance Sensor with OLED Display and SIM900A Communication
This circuit is a distance measurement and communication system using an Arduino UNO, an ultrasonic sensor, an OLED display, and a SIM900A module. The ultrasonic sensor measures the distance to an object, which is then displayed on the OLED screen and transmitted via the SIM900A module. The system is powered by a 18650 Li-ion battery.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Home security system: A project utilizing M5 U172 Distance Sensor in a practical application
Arduino UNO-Based Ultrasonic Security System with SIM800L GSM Module
This circuit features an Arduino UNO connected to an HC-SR04 ultrasonic sensor for distance measurement and a SIM800L GSM module for communication. The Arduino controls an LED, which lights up based on the distance detected by the ultrasonic sensor. When a certain distance threshold is exceeded, the Arduino uses the SIM800L module to make a phone call, indicating motion detection. A 48V to 5V converter supplies power to the SIM800L and the ultrasonic sensor.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of UNDERWATER SENSOR: A project utilizing M5 U172 Distance Sensor in a practical application
Arduino UNO Based Ultrasonic Distance Measurement with TM1637 Display
This circuit is designed to measure distance using the JSN-SR04T ultrasonic sensor and display the measured value on a TM1637 4-digit 7-segment display. The Arduino UNO serves as the central controller, running code to operate the sensor, calculate the distance, and update the display. The sensor's TRIG and ECHO pins are connected to digital pins D12 and D11 of the Arduino, respectively, while the display's CLK and DIO pins are connected to digital pins D3 and D4, with both the sensor and display sharing power and ground connections with the Arduino.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of CIRCUIT DIAGRAM FOR TROLLY CART: A project utilizing M5 U172 Distance Sensor in a practical application
Arduino-Controlled Robotic Vehicle with Ultrasonic Obstacle Avoidance
This circuit is designed for a mobile robot with ultrasonic distance sensing and motor control capabilities. It uses an Arduino UNO with a sensor shield to interface with an HC-SR04 ultrasonic sensor for distance measurements and a L298N motor driver to control four gearmotors for movement. The robot can move forwards and backwards, and turn left or right, with the ability to measure distances and adjust its path accordingly, as programmed in the embedded code.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications

  • Obstacle detection in robotics
  • Distance measurement in automation systems
  • Liquid level sensing in tanks
  • Proximity detection in IoT devices
  • Parking assistance systems

Technical Specifications

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

Pin Configuration

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

Usage Instructions

How to Use the M5 U172 Distance Sensor in a Circuit

  1. Power the Sensor: Connect the VCC pin to a 3.3V or 5V power source and the GND pin to the ground.
  2. Trigger the Sensor: Send a 10 µs HIGH pulse to the TRIG pin to initiate an ultrasonic burst.
  3. Receive the Echo: Measure the duration of the HIGH signal on the ECHO pin. This duration corresponds to the time taken for the sound wave to travel to the object and back.
  4. Calculate Distance: Use the formula below to calculate the distance: [ \text{Distance (cm)} = \frac{\text{Time (µs)} \times 0.034}{2} ] The factor 0.034 represents the speed of sound in cm/µs, and the division by 2 accounts for the round trip of the sound wave.

Important Considerations

  • Ensure the sensor is mounted securely and aligned properly for accurate measurements.
  • Avoid placing the sensor near sources of ultrasonic noise or vibrations.
  • The sensor's performance may degrade in extreme temperatures or high humidity environments.
  • Use a capacitor (e.g., 10 µF) across the power supply pins to reduce noise.

Example Code for Arduino UNO

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);
}

Best Practices

  • Use short, shielded wires to minimize signal interference.
  • If the sensor is used outdoors, consider adding a protective enclosure to shield it from environmental factors.
  • Regularly clean the sensor surface to ensure accurate readings.

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Output or Incorrect Readings

    • Cause: Incorrect wiring or loose connections.
    • Solution: Double-check the wiring and ensure all connections are secure.
  2. Fluctuating Distance Measurements

    • Cause: Electrical noise or unstable power supply.
    • Solution: Add a decoupling capacitor (e.g., 10 µF) across the VCC and GND pins.
  3. Sensor Not Detecting Objects

    • Cause: Object is outside the sensor's range or at an angle.
    • Solution: Ensure the object is within the 2 cm to 400 cm range and aligned with the sensor's measuring angle.
  4. Slow Response Time

    • Cause: Delay in processing the echo signal.
    • Solution: Optimize the code to reduce unnecessary delays.

FAQs

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.