Object distance sensor. Ultrasonic Distance Measuring Sensor HC-SR04. How a sensor with two digital outputs works

REAL3 sensors from Infineon use ToF technology to measure the time of flight of infrared light pulses and build a three-dimensional picture of the surrounding space. Main Feature These sensors become a sensitive matrix capable of not only detecting IR radiation, but also measuring the amplitude of the received signals. Due to its compact size, REAL3 sensors can be used not only in industrial applications, but also in compact commercial devices such as modern smartphones.

Currently, the development of ultrasonic sensors goes in several directions: extending the range, reducing consumption, reducing dimensions, and reducing costs. This article describes the new 2nd generation transformerless sensors from Elmos Semiconductor with extended range.

This guide addresses the following issues: inconsistent operation of ultrasonic sensors; synchronous operation of ultrasonic sensors; sequential start and looped operation of ultrasonic sensors. As well as questions and answers about crosstalk that occurs when using ultrasonic sensors.

Ultrasonic sensors solve many home problems when it comes to keeping your family safe, protecting your bank account, or protecting your home from damage. The article discusses some examples of their use.

MaxBotix ultrasonic sensors are very popular among developers of mobile robots. This applies to both large large-scale and small educational projects. Unlike many other manufacturers, MaxBotix factory calibrates their sensors to minimize their performance variation. The company offers a wide range of ultrasonic sensors for a wide range of applications, as well as developing custom sensors, assisting in the selection of optimal models and providing technical support when solving problems.

The MB1340 is a high performance XL-MaxSonar®-AE4™ series ultrasonic range finder featuring superior noise immunity and a very narrow beam pattern. The range is designed for indoor use. The MB1340 is designed and calibrated to provide reliable distance information to large objects, even in harsh acoustic and electrical noise environments.

Ultrasonic sensors are most commonly used as proximity or presence sensors. At the same time, the requirements for them are highly dependent on the specific application. Somewhere metrological characteristics become key parameters, somewhere the IP protection rating or the possibility of sharing several sensors turns out to be more important. MaxBotix, being one of the leaders in the production of ultrasonic sensors, offers its solutions for a wide variety of applications.

Ultrasonic sensors of the XL-MaxSonar-EZ (MB12x0) and I2XL-MaxSonar-EZ (MB12x2) series are designed to detect objects and people in the room. They feature high acoustic output and real-time auto-calibration on every measurement cycle to compensate for temperature, humidity, supply voltage, and acoustic or electrical noise suppression circuitry.

Currently, more and more functions related to sales and consultations are performed by electronic terminals. Specifically for interactive terminals, MaxBotix offers a series of ProxSonar ultrasonic proximity sensors. These sensors allow you to set the sensing distance in the range from 30 cm to about 2 m, which is useful for fine-tuning the terminal's behavior algorithms.

Purpose and principle of operation of the ultrasonic sensor. Common modes of operation are described: uni-/bi-directional systems and systems with reflectors.

Purpose and principle of operation of the ultrasonic sensor

Physics and technology

The main purpose of the ultrasonic sensor is to measure the distance to the controlled object or to register the appearance of an object in the "field of view" of the sensor.
Ultrasonic sensors use ultrasonic waves as an information carrier. The transducer sends out a pulse of sound and converts the received reflected signal into a voltage. By measuring the time until the arrival of the reflected signal from the sound speed factor, the controller integrated into the sensor calculates the distance to the object.
Ultrasonic sensors use ultrasonic waves as an information carrier.

Depending on the operating conditions and the features of the controlled object, it is advisable to use a one-/bidirectional or reflective control method.

Unidirectional systems

The transmitter and receiver are mounted opposite. If the ultrasound signal path is interrupted by an object, the transducer output will become active.

Advantage: High range.

Reflective systems


The transmitter and receiver are in the same housing. Ultrasound is reflected from the nearest reflector.

Advantage: Non-reflective or only slightly reflective objects can also be recognized.

Object reflection mode

There are 2 main functional types:

Unidirectional mode

The transmitter and receiver are in the same housing. Ultrasound is directly reflected by the registered object to the receiver.

Advantages: Simple, compact sensor, the most commonly used principle.

Bidirectional mode

The transmitter and receiver are separated, the transmit/receive sectors (transmitter/receiver) intersect.

Advantages: 3D registration area - Recognizes very small objects.

The ultrasonic distance sensor, just like the optical one, has been widely used in automation in various industries. Unlike optical rangefinders, this type of sensors has a smaller range of measurement values, as well as a significantly lower measurement speed.

There are several advantages: relatively high accuracy of the instrument, low sensitivity to air pollution environment, to the coloring of the surface of objects, and also has a huge range of temperatures at which it can be operated.

Ultrasonic sensors are quite compact, have a high-quality design, they do not have various moving parts. In addition, the equipment is practically maintenance-free.

Ultrasonic sensors are used to calculate the time it takes for sound to travel from the device to an object and back to the sensor (diffusive mode operation), or to check if the sent signal was received by a certain individual receiver (for oppositional mode of operation) .

The position sensor is used to control the presence or location of various mechanisms, as well as to count the objects present. Such a device can also be used as an indicator of the limit level of various kinds of liquids or bulk substances.

The principle of operation of the ultrasonic position sensor supports two modes:

  • opposition;
  • diffusion.

At opposition regime functioning, the transmitter and receiver are separate devices that are installed one opposite the other. In this case, the switch output will be activated if the ultrasonic beam collides with an obstacle (object).

There are several features:

  1. Large range, because the ultrasonic beam overcomes the signal distance only once;
  2. Relatively fast switching;
  3. Does not perceive interference very much, which allows it to be used in rather difficult conditions;
  4. The relatively high cost of installation work, because it is necessary to install two sensors - a transmitter and a receiver.

For autonomous switching on and off of lighting, it is not at all necessary to buy a special device. You can do it by following the step by step instructions.

Before the sensor, it is necessary to adjust it and avoid contamination of the surface, as this may adversely affect the performance of the detector.

Diffusion mode work is called the functioning of sensors in the case when the emitter and receiver are placed in the same housing. Thanks to this, the cost of installation work is minimized, because only one device needs to be fixed and configured.
However, it is characterized by a longer response time than the period characteristic of those who operate in opposition mode.

Features of distance and displacement sensors

The principle of operation of ultrasonic distance and displacement sensors is practically no different from the above device. The only slight difference is that the output is an analog signal, not a discrete one.

Sensors of this type are used to convert linear indicators of the distance to the detected object into electrical signals that comply with the 4-20 mA or 0-10 Volt standard. The measurement accuracy is at least 0.5 mm when the distance is less than one meter, and about 1 mm if the distance is more than one meter.

To ensure the safety of using a home electrical network, you need to know. In this case, it is necessary to take into account the nuances when installing different types this protective equipment.

But before installing the machine in the switchboard, it is necessary to evaluate in various situations. The success of installation and replacement depends on correctly drawn up standard schemes and strict adherence to the stages of installation work.

Sensors with an analog output and an upper measurement limit setting require an upper distance measurement limit to be specified. This is done thanks to the slotted potentiometer, which is displayed on the body of the device.

Ultrasonic distance and displacement sensors, having an analog output and the property of memorizing the range of work, provide such a feature as fixing the settings of the lower and upper limits of measurements.
This is due to the presence of some volatile memory and the use of a hardware programming method. In order to set the range of operation, it is necessary to place an object in front of the sensor near the first measurement boundary, then press the button to save and move the object to another boundary, and then press this button again.

How does a sensor with two digital outputs work?

An ultrasonic sensor with two digital outputs, as well as a memory of switching thresholds, has a number of features. So, for threshold regulation it is necessary that the value of the sag or the liquid level should not exceed one value or be significantly less than the other. The drive of this regulator can be connected to the body of only one device. Setting thresholds for two outputs is done using the button, which is located on the sensor panel.

The ability to install two sensors close to each other is explained by the organization of their alternating action, which allows such a feature as a synchronization input. Thanks to this, it is possible to create a controller with four thresholds, which makes independent measurements on both pairs of response thresholds.

The use of an ultrasonic sensor circuit is aimed at a two-level control system for the liquids present in the tanks.
The first sensor measures the control levels, and the second - at emergency levels. Thanks to the synchronization of actions, the devices function without interfering with each other.

Video with a simple example of the ultrasonic distance sensor

The very first non-contact distance sensors provided information only about the presence or absence of an object in front of the sensor in the form of a discrete ON / OFF signal. These simplest sensors are still widely used in various industries. At the same time, to solve more complex tasks of process automation, engineers need additional information about the position of measurement objects. For these purposes, sensors have been developed that allow you to determine the distance to the object and its position using an analog output, the signal on which is proportional to the distance to the measured object. Such sensors can be used in a variety of applications such as object distance detection, thickness measurement, tilt and strain measurement, product profile measurement, centering, and diameter measurement.

Distance sensors can use different measurement principles: inductive, ultrasonic or optical, but all of them have an electrical output signal, the magnitude of which is proportional to the distance to the object being measured. Table 1 shows the main types of analog proximity sensors for measuring distances and their main features.

Table 1

Inductive Ultrasonic Optical
triangulation Radar
Distance 0 – 20 mm 10 – 10.000 mm 10 – 1.000 mm 10 – 500.000 mm
Permission 0.1 µm 0.1 mm 1 µm 0.5 mm
Accuracy 1 µm 0.2 mm 2 µm 2 mm
Linearity 0,4% – 5% 0,5% 0,05% - 1% 0,001%
Time 0.3ms 20ms 1 ms 1 ms

inductive sensors. Inductive distance sensors detect distances to conductive metal objects such as steel, aluminium, brass. Since the principle of operation of inductive sensors is based on the detection of mutual induction currents, such sensors are very resistant to non-metallic objects and interference, such as dust or machine oil. Modern technologies allow you to create an inductive sensor with an analog output with a diameter of only 6 mm and a measurable distance of 2 mm. Such sensors with high resolution and fast response time are used in most high-speed applications.

However, despite the excellent accuracy, resolution and response time, a significant non-linearity of 3% - 5% presents a certain problem. To overcome this, some manufacturers define the output signal of the sensor as a polynomial function that mathematically describes the signal, and thus make it possible to program most modern controllers with this function for a more accurate measurement algorithm. A typical function that describes the output of an analog inductive sensor as a function of distance is shown below:

Distance = a + b (I out) + c (I out)2 + d (I out)3 + e (I out)4

Where: I out = output current
Measured distance = 0-2 mm, 0-20 mA (I out)

The coefficients of the function have the following values:
a = -0.144334; c = -0.00782; e = -7.27311 ? 10-6; b = 0.151453; d = 0.00040

Thus, for example, at a distance of 0.4638 mm, the output signal will be 5 mA. Linearity problems can also be solved using the microprocessor integrated into the sensor. This method allows one to linearize the output characteristic of the sensor and significantly reduce the non-linearity. For example, an inductive sensor with a diameter of 12 mm and a measuring distance of 0 - 4 mm, with a built-in microprocessor, has a linearity better than 0.4%.

ultrasonic sensors. The principle of operation of ultrasonic distance sensors is based on the emission of ultrasonic pulses and measurement until the sound pulse, reflected from the measurement object, returns back to the sensor. This achieves a resolution of up to 0.2 mm.

Due to the fact that a piezoresistive transducer can serve as both an emitter and a receiver of ultrasonic pulses, it becomes possible to create ultrasonic distance sensors with a single transducer. Such a transducer first emits a short ultrasonic pulse. At the same time, an internal timer is started in the sensor. When the ultrasonic pulse reflected from the object returns back to the sensor, the timer stops. The time elapsed between the moment the pulse was emitted and the moment when the reflected pulse returned to the sensor serves as the basis for calculating the distance to the object. Full control over the measurement process is carried out using a microprocessor, which ensures high linearity of measurements. The most important application features of ultrasonic sensors is their ability to measure distances to such complex objects as, for example, bulk solids, liquids, granules, transparent or otherwise highly reflective surfaces. In addition, ultrasonic sensors can measure relatively large distances while maintaining their small size, which can be essential for a number of applications.

However, ultrasonic sensors also have a number of limitations. First of all, these are foam and other objects that strongly absorb ultrasonic vibrations. Such absorption greatly reduces the measured distance. Highly curved surfaces also reduce the distance and accuracy of measurements, as they scatter ultrasonic vibrations in different directions. Ultrasonic sensors emit a pulse in the form of a wide cone, which also limits the ability to measure the distance to small objects, increasing the level of interference from other objects that may also be in the field of view of the sensor. Some ultrasonic transducers have a cone angle as small as 5 degrees. This allows them to be used to measure much smaller objects such as bottles or ampoules.

Optical sensors. There are many various ways measure the distance to an object using optics such as laser interferometers, diffuse light sensors and radar-type optical sensors. Each type of sensor has its own strengths and weaknesses. Laser interferometers have a large measurement range and an accuracy of several nanometers, however, these devices are very expensive and difficult to operate. Diffuse-reflection sensors with analog output can measure a wide range of distances, but because they work with reflected light, there may be problems measuring distances to colored or reflective objects. Optical sensors of the radar type, mainly laser ones, can measure long distances, but the principle of their operation, based on measuring the propagation time of light from the sensor to the object and back, makes it possible to measure with a limited resolution of 2–3 mm.

The vast majority of measurement tasks in industry fall within the ranges from fractions of a micron to several tens of meters. At the same time, the sensors must work with objects that are far from ideal: small in size, having a different color, complex surface structure and moving with high speed. For such purposes, laser distance sensors operating on the principle of optical triangulation are most suitable.


Drawing. The principle of operation of the optical distance sensor

The figure shows the principle of operation of the optical distance sensor. The laser sends a beam through the lens, which is reflected from the object and focused on a line of photodiodes, which converts the light signal into an electrical signal. Any change in the distance to the object causes a change in the angle of the reflected beam and hence the position that the reflected beam occupies on the array of photodiodes. The microcontroller processes the signal from the photodiode array and converts it into an analog electrical signal.

The most important quality of such distance sensors is the combination of high measurement accuracy and large measurable distances. Most manufacturers offer sensors with resolutions ranging from 1 µm to 1 mm. However, high accuracy is only possible over relatively short distances. So, for example, an accuracy of 1 micron at distances of 1 meter is unlikely to be obtained.

To reduce the effect of noise, all laser distance sensors allow integral or average measurements. In this case, many measurements of the distance to the object are made and the result is then averaged, thereby increasing the accuracy of measurements. However, greater accuracy requires a large number of measurements, thus increasing the total measurement time. So, for example, to ensure an accuracy of 1 µm, a typical measurement time is of the order of 0.1 sec.

Correct choice of sensor. In order to choose the right distance sensor, you need to answer 7 questions:

What is the object of measurement? What is the distance to the object? What accuracy is required? How fast is the object moving? What are the external adverse conditions? What type of output signal is required? How limited is the space for installing the sensor?

Having received the answer to these questions, and having knowledge of the principles of operation of inductive, ultrasonic and optical distance sensors, you will be able to the best way select the desired sensor.

Arduino ultrasonic distance sensors are in great demand in robotics projects due to their relative simplicity, sufficient accuracy and availability. They can be used as devices to help avoid obstacles, get the size of objects, simulate a map of the room and signal the approach or removal of objects. One of the common options for such a device is a distance sensor, which includes an ultrasonic range finder HC SR04. In this article, we will get acquainted with the principle of operation of the distance sensor, consider several options for connecting to Arduino boards, an interaction diagram and examples of sketches.

The ability of an ultrasonic sensor to determine the distance to an object is based on the principle of sonar - by sending a beam of ultrasound, and receiving its reflection with a delay, the device determines the presence of objects and the distance to them. The ultrasonic signals generated by the receiver, reflected from the obstacle, return to it after a certain period of time. It is this time interval that becomes a characteristic that helps determine the distance to the object.

Attention! Since the principle of operation is based on ultrasound, such a sensor is not suitable for determining the distance to sound-absorbing objects. Objects with a flat, smooth surface are optimal for measurement.

Description of the HC SR04 sensor

The Arduino distance sensor is a non-contact type device, and provides high-precision measurement and stability. The range of its measurement range is from 2 to 400 cm. Its operation is not significantly affected by electromagnetic radiation and solar energy. The module kit with HC SR04 arduino also includes a receiver and a transmitter.

Ultrasonic range finder HC SR04 has the following technical parameters:

  • Supply voltage 5V;
  • The operating parameter of the power of the current is 15 mA;
  • Passive Current< 2 мА;
  • Viewing angle – 15°;
  • Touch resolution - 0.3 cm;
  • Measuring angle – 30°;
  • Pulse width - 10 -6 s.

The sensor is equipped with four leads (standard 2.54 mm):

  • Positive type power contact - + 5V;
  • Trig (Т) – input signal output;
  • Echo (R) - output signal output;
  • GND - output "Earth".

Where to buy the SR04 module for Arduino

The distance sensor is a fairly common component and can be easily found in online stores. The cheapest options (from 40-60 rubles apiece), traditionally on the well-known site.

Distance sensor module HC-SR04 for Arduino Another option for ultrasonic sensor HC-SR04 from a reliable supplier
Distance sensors SR05 Ultrasonic HC-SR05 (improved performance) HC-SR05 HY-SRF05 module for UNO R3 MEGA2560 DUE from a reliable supplier

Scheme of interaction with Arduino

To obtain data, you must perform the following sequence of actions:

  • Apply a 10 microsecond pulse to the Trig output;
  • In the hc sr04 ultrasonic rangefinder connected to the arduino, the signal will be converted into 8 pulses with a frequency of 40 kHz, which will be sent forward through the emitter;
  • When the impulses reach the obstacle, they will be reflected from it and will be received by the receiver R, which will provide an input signal at the Echo output;
  • On the controller side, the received signal should be converted into a distance using formulas.

Dividing the pulse width by 58.2 gives the data in centimeters, dividing by 148 gives the data in inches.

Connecting HC SR04 to Arduino

Connecting an ultrasonic distance sensor to the Arduino board is quite simple. The connection diagram is shown in the figure.

The ground pin is connected to the GND pin on the Arduino board, the power output is connected to 5V. We connect Trig and Echo outputs to arduino to digital pins. Breadboard connection option:

Library for working with HC SR04

To facilitate work with the HC SR04 distance sensor on arduino, you can use the NewPing library. It has no problems with pings and adds some new features.

The features of the library include:

  • Ability to work with various ultrasonic sensors;
  • Can work with a distance sensor with just one pin;
  • No lag of 1 second in the absence of echo ping;
  • For simple error correction, there is a built-in digital filter;
  • The most accurate distance calculation.

You can download the NewPing library

Distance measurement accuracy with HC SR04 sensor

The accuracy of the sensor depends on several factors:

  • air temperature and humidity;
  • distance to the object;
  • location relative to the sensor (according to the radiation diagram);
  • performance quality of the elements of the sensor module.

The principle of operation of any ultrasonic sensor is based on the phenomenon of reflection of acoustic waves propagating in the air. But as is known from the course of physics, the speed of sound propagation in air depends on the properties of this very air (primarily on temperature). The sensor, emitting waves and measuring the time until their return, does not guess in which medium they will propagate and takes some average value for calculations. In real conditions, due to the air temperature factor, the HC-SR04 may have an error of 1 to 3-5 cm.

The factor of distance to the object is important, because the probability of reflection from neighboring objects increases, in addition, the signal itself attenuates with distance.

Also, to improve accuracy, it is necessary to correctly direct the sensor: make sure that the object is within the cone of the radiation pattern. Simply put, the HC-SR04's "eyes" should look straight at the subject.

To reduce errors and measurement errors, the following actions are usually performed:

  • the values ​​​​are averaged (we measure several times, remove bursts, then find the average);
  • using sensors (for example,) the temperature is determined and correction factors are introduced;
  • the sensor is mounted on a servomotor, with the help of which we “turn our head”, moving the radiation pattern to the left or right.

Distance sensor examples

Let's look at an example of a simple project with an Arduino Uno board and an HC SR04 distance sensor. In the sketch, we will get the value of the distance to objects and output them to the port monitor in the Arduino IDE. You can easily change the sketch and the connection scheme so that the sensor signals the approach or distance of an object.

Connecting the sensor to arduino

When writing the sketch, the following pinout option for connecting the sensor was used:

  • VCC: +5V
  • Trig - 12 pins
  • Echo - 11 pins
  • Ground (GND) – Ground (GND)

Sketch example

Let's start working with the sensor right away with a relatively complex option - without using external libraries.

In this sketch, we perform the following sequence of actions:

  • With a short pulse (2-5 microseconds), we transfer the distance sensor to the echolocation mode, in which ultrasonic waves with a frequency of 40 kHz are sent into the surrounding space.
  • We are waiting for the sensor to analyze the reflected signals and determine the distance by the delay.
  • We get the value of the distance. To do this, we wait until the HC SR04 generates a pulse proportional to the distance at the ECHO input. We determine the duration of the pulse using the pulseIn function, which will return us the time elapsed before the signal level changed (in our case, until the reverse edge of the pulse appeared).
  • Having received the time, we convert it into a distance in centimeters by dividing the value by a constant (for the SR04 sensor, this is 29.1 for the “there” signal, the same for the “back” signal, which will give a total of 58.2).

If the distance sensor does not read the signal, then the output signal conversion will never take the value of a short pulse - LOW. Since for some sensors the delay time varies depending on the manufacturer, it is recommended to set its value manually when using these sketches (we do this at the beginning of the cycle).

If the distance is more than 3 meters, at which the HC SR04 starts to work poorly, it is better to set the delay time to more than 20 ms, i.e. 25 or 30 ms.

#define PIN_TRIG 12 #define PIN_ECHO 11 long duration, cm; void setup() ( // Initialize communication on the serial port Serial.begin (9600); // Define inputs and outputs pinMode(PIN_TRIG, OUTPUT); pinMode(PIN_ECHO, INPUT); ) void loop() ( // First generate a short pulse duration 2-5 microseconds digitalWrite(PIN_TRIG, LOW); delayMicroseconds(5); digitalWrite(PIN_TRIG, HIGH); // Setting high level signal, we wait about 10 microseconds. At this point, the sensor will send signals at a frequency of 40 kHz. delayMicroseconds(10); digitalWrite(PIN_TRIG, LOW); // The delay time of the acoustic signal on the echo sounder. duration = pulseIn(PIN_ECHO, HIGH); // Now it remains to convert time to distance cm = (duration / 2) / 29.1; Serial.print("Distance to object: "); Serial print(cm); Serial.println("see."); // Delay between measurements for the sketch to work correctly delay(250); )

Sketch using the NewPing library

Now let's look at a sketch using the NewPing library. The code will be significantly simplified, because all the actions described earlier are hidden inside the library. All we need to do is create an object of the NewPing class, specifying the pins with which we connect the distance sensor and use the methods of the object. In our example, we need to use ping_cm() to get the distance in centimeters.

#include #define PIN_TRIG 12 #define PIN_ECHO 11 #define MAX_DISTANCE 200 // Constant for defining the maximum distance we'll consider valid. // Create an object whose methods we will then use to get the distance. // As parameters we pass the numbers of pins to which the ECHO and TRIG outputs of the NewPing sonar sensor are connected(PIN_TRIG, PIN_ECHO, MAX_DISTANCE); void setup() ( // Initialize communication over the serial port at baud rate 9600 Serial.begin(9600); ) void loop() ( // Start delay required for correct operation. delay(50); // Get the value from the distance sensor and store it in a variable unsigned int distance = sonar.ping_cm(); // Print the distance in the port monitor Serial.print(distance); Serial.println("cm"); )

An example of connecting an ultrasonic rangefinder HC SR04 with one pin

Connecting the HC-SR04 to the Arduino can be done using a single pin. This option is useful if you are working on a large project and you do not have enough free pins. To connect, you just need to install a 2.2K resistor between the TRIG and ECHO pins and connect the TRIG pin to the arduino.

#include #define PIN_PING 12 // The Arduino pin is connected to the trigger and echo pins on the distance sensor #define MAX_DISTANCE 200 // The maximum distance we can control (400-500cm). NewPing sonar(PIN_PING, PIN_PING, MAX_DISTANCE); // Adjust pins and maximum distance void setup() ( Serial.begin(9600); // Open protocol with data and baud rate 115200 bps. ) void loop() ( delay(50); // 50ms delay between generated waves 29ms is the minimum allowed value unsigned int distanceSm = sonar.ping(); // Creating a signal, getting its duration parameter in µs (uS). Serial.print("Ping: "); Serial.print(distanceSm / US_ROUNDTRIP_CM); // Converting the time parameter into a distance value and outputting the result (0 corresponds to exceeding the allowed limit) Serial.println("cm"); )

Brief conclusions

Ultrasonic distance sensors are versatile and accurate enough to be used for most hobby projects. The article discusses the extremely popular HC SR04 sensor, which is easily connected to the arduino board (for this, two free pins should be immediately provided, but there is a connection option with one pin). There are several free libraries for working with the sensor (only one of them, NewPing, is considered in the article), but you can do without them - the algorithm for interacting with the sensor's internal controller is quite simple, we have shown it in this article.

Based own experience, it can be stated that the HC-SR04 sensor is accurate within one centimeter at distances from 10 cm to 2 m. At shorter and longer distances, strong interference may occur, which is highly dependent on the surrounding objects and the method of use. But for the most part, the HC-SR04 did the job just fine.