Design and Performance Evaluation of a Distance-Based Object Presence Detector Using Arduino Uno and HC-SR04 Ultrasonic Sensor
DOI:
https://doi.org/10.22373/p-jpft.v13i1.36811Keywords:
Arduino Uno, HC-SR04 Ultrasonic Sensor, Object Presence Detection, Time-of-Flight, Measurement Error, Proximity AlarmAbstract
Low-cost ultrasonic sensors are widely used in proximity alarms, yet many Arduino-based detector studies report only whether the alarm works, without quantifying measurement error, repeatability, or behaviour at the decision threshold. This study designed and evaluated a distance-based object presence detector consisting of an Arduino Uno, an HC-SR04 ultrasonic sensor, and an active buzzer that sounds when an object is closer than 50 cm. The sensor determines distance from the time of flight of a 40 kHz ultrasonic pulse reflected by the object (d = vt/2, with v = 343 m/s). A human hand was used as the target and placed at 10–100 cm in 10 cm steps, and three readings were recorded at each distance (30 trials). Accuracy was assessed using the mean, standard deviation (SD), absolute and relative errors, linear regression against the reference distance, and the agreement of the buzzer state with the programmed threshold. The sensor readings were highly linear (y = 1.009x − 0.289, R² = 0.9998), with a mean absolute error of 0.50 cm (RMSE 0.53 cm) and an SD of 0.58–1.15 cm. The relative error decreased from 6.7% at 10 cm to below 1% at 40 cm and beyond, indicating a nearly constant absolute offset. The buzzer state agreed with the threshold in all 30 trials, including at 50 cm, where the readings (50–51 cm) kept the buzzer OFF. The system detects object presence based on distance and does not distinguish moving from stationary objects; the response time and the effects of target material, incidence angle, and multiple objects were not measured and are reported as limitations. The device is suitable as a simple, low-cost proximity alarm and as a teaching medium for ultrasonic time-of-flight measurement.
References
Abdulkhaleq, N. I., Hasan, I. J., & Salih, N. A. J. (2020). Investigating the resolution ability of the HC-SRO4 ultrasonic sensor. IOP Conference Series: Materials Science and Engineering, 745(1), 012043. https://doi.org/10.1088/1757-899X/745/1/012043
Akhter, F., Khadivizand, S., Siddiquei, H. R., Alahi, M. E. E., & Mukhopadhyay, S. (2019). IoT enabled intelligent sensor node for smart city: Pedestrian counting and ambient monitoring. Sensors, 19(15), 3374. https://doi.org/10.3390/s19153374
Andreas, Aldawira, C. R., Putra, H. W., Hanafiah, N., Surjarwo, S., & Wibisurya, A. (2019). Door security system for home monitoring based on ESP32. Procedia Computer Science, 157, 673–682. https://doi.org/10.1016/j.procs.2019.08.218
Arunglabi, R., Allu, N., & Patandianan, H. J. A. (2026). Analysis of the effect of temperature variations on HC-SR04 ultrasonic sensor distance measurement accuracy based on Tinkercad simulation. Journal Zetroem, 8(1), 94–100. https://doi.org/10.36526/ztr.v8i1.7637
Carullo, A., & Parvis, M. (2001). An ultrasonic sensor for distance measurement in automotive applications. IEEE Sensors Journal, 1(2), 143–147. https://doi.org/10.1109/JSEN.2001.936931
Cramer, O. (1993). The variation of the specific heat ratio and the speed of sound in air with temperature, pressure, humidity, and CO2 concentration. The Journal of the Acoustical Society of America, 93(5), 2510–2516. https://doi.org/10.1121/1.405827
Gabriel, M. M., & Kuria, K. P. (2020). Arduino Uno, ultrasonic sensor HC-SR04 motion detector with display of distance in the LCD. International Journal of Engineering Research & Technology, 9(5). https://doi.org/10.17577/IJERTV9IS050677
Hanafie, A., Kamal, & Ramadhan, R. (2022). Perancangan alat pendeteksi gerak sebagai sistem keamanan menggunakan ESP32 CAM berbasis IoT. Jurnal Teknologi dan Komputer (JTEK), 2(2), 142–148. https://doi.org/10.56923/jtek.v2i02.101
Haq, A., Firdaus, R. A., Khoiro, M., Rahmawati, E., & Winarto, N. (2026). Accuracy of HC-SR04 ultrasonic servo in servo-scanned 2D ranging. Prisma Sains: Jurnal Pengkajian Ilmu dan Pembelajaran Matematika dan IPA IKIP Mataram, 14(3), 1417–1431. https://doi.org/10.33394/j-ps.v14i3.19813
Hodson, T. O. (2022). Root-mean-square error (RMSE) or mean absolute error (MAE): When to use them or not. Geoscientific Model Development, 15(14), 5481–5487. https://doi.org/10.5194/gmd-15-5481-2022
Juliansyah, A., Ramlah, R., & Nadiani, D. (2021). Sistem pendeteksi gerak menggunakan sensor PIR dan Raspberry Pi. JTIM: Jurnal Teknologi Informasi dan Multimedia, 2(4), 199–205. https://doi.org/10.35746/jtim.v2i4.113
Kim, J. W., Sul, S. H., & Choi, J. B. (2020). Development of real-time Internet of Things motion detection platform applying non-contact sensor based on open source hardware. International Journal of Distributed Sensor Networks, 16(8), 1–12. https://doi.org/10.1177/1550147720944024
Kinsler, L. E., Frey, A. R., Coppens, A. B., & Sanders, J. V. (2000). Fundamentals of acoustics (4th ed.). John Wiley & Sons.
Lee, D. K., In, J., & Lee, S. (2015). Standard deviation and standard error of the mean. Korean Journal of Anesthesiology, 68(3), 220–223. https://doi.org/10.4097/kjae.2015.68.3.220
Marioli, D., Narduzzi, C., Offelli, C., Petri, D., Sardini, E., & Taroni, A. (1992). Digital time-of-flight measurement for ultrasonic sensors. IEEE Transactions on Instrumentation and Measurement, 41(1), 93–97. https://doi.org/10.1109/19.126639
Mocanu, B., Tapu, R., & Zaharia, T. (2016). When ultrasonic sensors and computer vision join forces for efficient obstacle detection and recognition. Sensors, 16(11), 1807. https://doi.org/10.3390/s16111807
Pakpahan, D. M. N., Purwadi, H., & Wajiansyah, A. (2026). Arduino-based automatic door opener design using ultra-sonic sensors. Journal of Engineering, Electrical and Informatics, 6(1), 17–24. https://doi.org/10.55606/jeei.v6i1.6663
Putri, E. E., & Kinanti, A. Z. L. (2026). Development of an Arduino-assisted physics practicum system for mirror image formation measurement using an HC-SR04 ultrasonic distance sensor. Edu Sains: Jurnal Pendidikan Sains & Matematika, 14(1), 100–110. https://doi.org/10.23971/b2nc3t19
Putri, S. O. N., Sari, D. F., Iskandar, E., & Buryadi, I. Y. (2022). Sistem keamanan rumah berbasis IoT dengan NodeMCU ESP8266 menggunakan sensor PIR sebagai pendeteksi gerakan. Jurnal Informatika Komputer, Bisnis dan Manajemen, 20(2). https://doi.org/10.61805/fahma.v20i2.29
Rudyk, A., Semenov, A., Baraban, S., Semenova, O., Kulakov, P., Kustovskyj, O., & Brych, L. (2025). Influence of environmental factors on the accuracy of the ultrasonic rangefinder in a mobile robotic technical vision system. Electronics, 14(7), 1393. https://doi.org/10.3390/electronics14071393
Ruuhwan, R., Rizal, R., & Kurniawan, R. (2020). Pendeteksi gerakan menggunakan sensor PIR untuk sistem keamanan di ruang kamar berbasis SMS. Jurnal Informatika Universitas Pamulang, 5(3), 281–287. https://doi.org/10.32493/informatika.v5i3.5706
Subekti, A., Cahyono, B. E., Misto, & Nugroho, A. T. (2022). Static characteristics analysis of ultrasonic sensor HC-SR 04 and its application to water level monitoring based on Arduino Uno. AIP Conference Proceedings, 2663(1), 060006. https://doi.org/10.1063/5.0108043
Surantha, N., & Wicaksono, W. R. (2018). Design of smart home security system using object recognition and PIR sensor. Procedia Computer Science, 135, 465–472. https://doi.org/10.1016/j.procs.2018.08.198
Waworundeng, J., Irawan, L. D., & Pangalila, C. A. (2017). Implementasi sensor PIR sebagai pendeteksi gerakan untuk sistem keamanan rumah menggunakan platform IoT. CogITo Smart Journal, 3(2), 152–163. https://doi.org/10.31154/cogito.v3i2.65.152-163
Wu, C.-M., Chen, X.-Y., Wen, C.-Y., & Sethares, W. A. (2021). Cooperative networked PIR detection system for indoor human localization. Sensors, 21(18), 6180. https://doi.org/10.3390/s21186180
Z, M. R., Purwadi, H., & Maesaroh, D. T. (2026). Deteksi gerak berbasis Internet of Things (IoT) menggunakan sensor PIR dan ESP32 dengan notifikasi Telegram. Jurnal Informatika dan Teknik Elektro Terapan, 14(2). https://doi.org/10.23960/jitet.v14i2.9408
Downloads
Published
Issue
Section
License
Copyright (c) 2026 Sofiyanti Sofiyanti, Khairiah Khairiah, Lia Afriyanti Nasution, Phaklen Ehkan

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
License Terms
Articles published in Jurnal Phi: Jurnal Pendidikan Fisika dan Fisika Terapan are open access and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0)
Under this license, anyone is free to:
-
Share — copy and redistribute the material in any medium or format for any purpose, even commercially.
-
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
Under the following terms:
-
Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
-
ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

