HC-SR04 ultrasonic sensor Range Problem

8 views (last 30 days)
Jordan Jenkins
Jordan Jenkins on 30 Oct 2019
Answered: Amrtanshu Raj on 23 Sep 2021
Hi all, im currently partaking in a robotics Project, with the aim of driving a robot arm using a vision guidence system. Im using a HC-SR04 ultrasonic sensor connected to an arduino uno to collect Z-axis data. The whole project being controlled through MATLAB as this is the main knowledge base at my institution.
However i have come across an issue, when using the Legacy HC-SR04 Add-On Library for Arduino the working range of the sensor is dramatically reduced. I can use the sensor in arduino IDE with a working range of 4 meters, so i beleive this rules out a harware issue, however when the sensor is controlled in MATLAB the working range is reduced to around 0.4 meters after which the sensor returns a value of 0.51m constantly.
Are there any workarounds for this issue? if not i will need to keep the arduino IDE program controlling the arduino/sensor and then import the data to MATLAB as and when needed.
Thanks in Advance,
Jordan.

Answers (1)

Amrtanshu Raj
Amrtanshu Raj on 23 Sep 2021
Hi,
The range problem with Legacy HC-SR04 Add-On Library is a known issue for this Library. This library is now no longer in use and has been replaced by MATLAB Support Package for Arduino Hardware which enables you to use MATLAB to interactively communicate with an Arduino board.
Hope this helps !!

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!