You are on page 1of 6

HC-SR04 ULTRASONIC SENSOR – ACCURACY AND RESOLUTION TESTS

rigonz2@netscape.net
R0 May 2014

1. BACKGROUND AND PURPOSE


Distance detection by ultrasonic sensors is common in DIY electronics and robots, and
most references that I have reviewed seem to be satisfied with the accuracy and precision
of the sensors they used. My own experience has been mixed, and a new project that I am
planning requires precise thorough knowledge on the reliability of the readings taken by the
ultrasonic sensor that I intend to use. As the technical specifications of these sensors
seldom provide the details that I need, I have launched a home-made battery of tests
aimed at evaluating:
the accuracy and precision of the readings,
the spatial range of readings (resolution, width and depth of view),
the dynamic behavior of consecutive readings.
This document provides information on the procedures and results, and recommendations
for a better use of ultrasonic sensors.

2. ULTRASONIC SENSORS
There are a number of ultrasonic sensors available for the hobbyist, as shown in the
attached pictures. The model I have used is labelled HC-SR04 and has no mark of
manufacturer. As per the information available in Internet it seems that several companies
manufacture very similar versions.

HC-SR04 Tests R0 1/6


Figure 1: Ultrasonic Sensor Modules (from left to right, from top to down: Devantech SRF04, Vex
Ultrasonic, Parallax Ping, SKU 2760342, Maxbotix LV-EZ1, SRF02, URM05, URM37, RB URF v1.1,
US-020, Cebek C-7210, Probe F16)

Figure 2: HC-SR04 Ultrasonic Sensor Module


The HC-SR04 has the emitter and the sensor physically separated. In order to measure the
distance, after the trigger signal (a high pulse of 10 microsecond duration) the emitter
sends an 8 cycle burst of ultrasound at 40 kHz; the receiver collects the echo and sends a
TTL signal whose duration is the time elapsed between the burst pulse (ping) and the echo
reception (pong), which is the total travelling time of the sound signal.
The specifications that I have been able to collect are summarized as follows (source:
www.elecfreaks.com):
Range: 2-400 cm (some sources mention up to 500 cm)
Accuracy: up to 3 mm
Measuring angle: 15º

HC-SR04 Tests R0 2/6


Resolution: “when tested objects, the range of area is not less than 0.5 square
meters and the plane requests as smooth as possible, otherwise it will affect the
results of measuring”

Figure 3: Directional Chart (Source: User’s Manual – HC-SR04 Ultrasonic Sensor, Cytron
Technology)

3. RANGE AND FOV; ACCURACY AND PRECISION

3.1. Definitions
For any non-contact directional sensor the geometry of the external world is determined by
its Field of View (FOV) and range.
The FOV is a measurement of the angular range within which a sensor percepts. It can be
conceived as the part of the surrounding space where items can be detected through the
sensor: objects outside the FOV cannot be recorded. The FOV is usually measured as the
angular size of the view cone, expressed in horizontal and vertical degrees (f.eg. 22° ×
15°).
The range is the distance from the sensor to the nearest and farthest planes on which
objects can be detected by the sensor.
The spatial resolution of a sensor, or Instantaneous Field of View (IFOV), is the smallest
detail within the FOV that can be measured.

Figure 4: FOV (Source: Wikipedia)

HC-SR04 Tests R0 3/6


Regarding accuracy and precision: “the accuracy of a measurement system is the degree
of closeness of measurements of a quantity to that quantity's actual (true) value. The
precision of a measurement system (…) is the degree to which repeated measurements
under unchanged conditions show the same results” (source: Wikipedia).

Figure 5: Accuracy and Precision (Source: http://bhargreaves.com; Wikipedia)

3.2. Tests Procedure


A quite simple and domestic procedure has been implemented for determining the FOV
and spatial resolution, as well as the accuracy and precision of my HC-SR04. I have
mounted the sensor on a simple support, fixed, at the floor level, and placed several
objects in front of it, at different and known locations. The measurements have been done
with an Arduino sketch, recorded from the PC serial display with CoolTerm and analyzed in
an Excel spreadsheet.
Because I also wanted to assess the influence of the measurement conditions from the
controlling program, the Arduino sketch included a series of 10 consecutive readings with
different time intervals: 1, 10, 50, 100 and 200 milliseconds.
And because I had doubts on the consistency of the manufacturing conditions I have
partially repeated the test with a second HC-SR04 from the same manufacturer.
The following pictures show the in-house testing arrangements.

HC-SR04 Tests R0 4/6


Figure 6: Domestic Tests Arrangements

3.3. Results
I have determined the horizontal FOV (HFOV) with a metal pencil sharpener, with a gross
section of 25*15 mm at distances of 10, 20 and 100 cm. The results fluctuate between 18
and 24º (full cone), for an average of 21º (considerably less than the 30º mentioned in the
specifications).
The HFOV seems to be slightly skewed to one side, probably due to the asymmetry of the
module (but a part of this asymmetry maybe due to irregularities in the testing procedure):
the total HFOV is approx. 9.5+11.5º.
Despite of the variable results, the border of the HFOV is sharp: a shift of 2 mm can be the
difference between reading and error (see attached tables).

Figure 7: Sharp HFOV Borders: Results with 2 mm Side Displacement

For the determination of the vertical FOV (VFOV) I placed the measuring object (the metal
sharpener) on a vertical rod at a known height, and shifted it along the line in front of the
sensor until it was detected. The VFOV (full cone) that I have measured is approximately

HC-SR04 Tests R0 5/6


only 4º, which I find surprising considering the external symmetry of the emitter and
receiver.
With regard to the spatial resolution, I have tested it with the pencil sharpener (25*15 mm)
and with a clock (60*60 mm) looking for the distance at which the measurements started to
show larger inconsistencies. The cone aperture for the resolution is between 0.6-1.4º.
The precision of the measures is only moderate: the standard deviation of the raw data is
often between 0.2 and 0.8 cm, for few hundred readings. If the data are filtered it can be
reduced to 0.1-0.5 cm, although the variability of the standard deviation is large between
groups of measurements.
Accuracy is rather volatile: I have measured average absolute errors ranging from 0.6 cm
at 20 cm from the sensor to 5.7 cm at a distance of 180 cm. There is a trend between these
two ends but with low correlation between distance and error even after filtering the data
(R2=0.89).
With regard to the differences between measuring intervals, I have not noticed any
difference of relevance between the intervals tested (1, 10, 50, 100 and 200 milliseconds).
Finally, the two sensors that I have tested show similar behavior (although one is not
reducible to the other).

4. CONCLUSIONS AND RECOMMENDATIONS


Based on my tests the specifications of the HC-SR04 are:
FOV (full cone): horizontal ~21º, vertical ~4º
Spatial resolution (full cone): ~0.6-1.4º
Range: tested from 5 to 200 cm
Accuracy: absolute error ~0.035 cm/cm.
Precision: standard deviation ~0.1-0.5 cm
The use of these sensors needs attention in the interpretation of their readings. Specific
testing is recommended, as well as repeated readings and filtering of the data prior to any
calculation based on them.

HC-SR04 Tests R0 6/6

You might also like