HC-SR04 ultrasonic module tested

(Published on 22/12/2017)

With the HC-SR04 module, you can measure distances of up to 4.5 metres at a very low cost. The module is prepared for working with well-known microcomputer platforms such as the Arduino.

Introduction to the HC-SR04


Measuring distances with ultrasonic sound
With ultrasonic sound you can measure small distances fairly accurately according to the radar principle. An ultrasonic transducer emits a few pulses of a signal with a frequency of 40 kHz. This signal reflects back on an object. The reflected signal is captured in a second transducer and amplified. By measuring the time between sending and receiving the pulses, you can accurately measure the distance from the transducers to the object. The speed of ultrasonic sound in the air at sea level at 0 °C and 0 % relative humidity is 331.4 meters per second or 1193.00 km/h. The distance is then equal to the measured time times this speed and that divided by two. The ultrasonic signals travel twice the distance between transducers and the object.
If you want to measure very accurately, you have to take into account the local temperature and humidity of the air. The speed of sound is then given by:
speed = 331.4 + [0.606 - t] + [0.0124 - TH].
in which:
      - t is the air temperature in °C.
      - RH is the relative humidity in %.

HC-SR04-ultrasonic-module(01) (© 2018 Jos Verstraten)
The principle of measuring distances with ultrasonic sound. (© 2018 Jos Verstraten)
HC-SR04 ultrasonic module
The HC-SR04 is a module that takes a large part of the work off your hands. This module contains not only the two transducers, but also all the electronics needed to send and receive the 40 kHz pulses. The module has one input Trig on which you set a narrow start pulse and one output Echo which gets high between sending and receiving the first pulse of the burst. Can it be easier? The module comes (of course) from China and is offered under various brand names. It seems that a company called Cytron Technologies is the real manufacturer of the module. As is usually the case with this type of product, the HC-SR04 is offered at various prices. We found prices ranging from € 0.66 to € 9.99!

HC-SR04-ultrasonic-module(02) (© Aliexpress)
The front of the HC-SR04 module. (© Aliexpress)
The electronics in the HC-SR04
There are different versions of this module in circulation, hence perhaps the large price difference. In all found versions, however, there is almost identical electronics on the back of the PCB. An op-amp of the type LM324 provides the amplification of the received signal.



Strangely enough, the transducer that sends is controlled from a MAX232A. This is an RS232 line driver and receiver. However, it contains a voltage pump, which generates two symmetrical voltages of ±12V from a power supply voltage of 5 V.  In this inventive way the transmitter transducer is controlled with a much larger signal than the available 5 V power supply allows, which of course increases the range of the module. The receive and emit circuits are controlled by an EM78P153S Chinese microcontroller running at 27 MHz.  This microcontroller generates the eight periods of the transmission signal of 40 kHz via a small program from the present crystal of 27 MHz.

HC-SR04-ultrasonic-module(03) (© 2017 Jos Verstraten)
The electronics on the back of the HC-SR04. (© 2017 Jos Verstraten)


The wiring diagram of the electronics
By applying reverse engineering it is possible to largely reconstruct the scheme of the module. The technicians of mc-computing have spent quite some time on this, with the result below.

HC-SR04-ultrasonic-module(04) (© mc-computing)
The diagram of the module. (© mc-computing)
Technical data
       - Price indication: € 0.66 to € 9.99
       - Manufacturer: Cytron Technologies (?)
       - Supply voltage: + 5 Vdc
       - Quiescent current: less than 2 mA
       - Working current: 15 mA typical
       - Operating frequency: 40 kHz typical
       - System opening angle: less than 15°
       - Range: 2 cm to 450 cm
       - Accuracy: ±3 mm
       - Trigger pulse: positive, 10 µs minimum
       - Dimensions: 43 mm x 20 mm x 15 mm
       - EAN code: 4250236810256

Working with the HC-SR04


The timing of the HC-SR04
The operation of the module is extremely simple. You put on the pen 'Trigger' a positive pulse of at least 10 µs. You can repeat these pulses every 100 µs. On the trailing edge of this pulse, the module generates eight periods of the 40 kHz signal. At the start of this signal, the leading edge of a positive pulse appears on the 'Echo' output. When the first reflected period is received, this signal goes to zero. You have to measure the time between the leading and the trailing edge of the pulse on 'Echo' via for example an Arduino.

HC-SR04-ultrasonic-module(05) (© 2017 Jos Verstraten)
The timing of the HC-SR04. (© 2017 Jos Verstraten)
A simple analog measurement method
If you are working analog, you can use this time to charge a capacitor from a constant current source. The voltage across the capacitor is then directly proportional to the measured distance and you can use an LED thermometer scale to display this voltage.




(Banggood sponsor ad)
HC-SR04 Distance Measuring Ranging Transducer Sensor