I am testing HC-SR04 ultrasonic sensor using Arduino Mega. It is to be used on a Quadcopter for measuring distance from below.
The sensor gives roughly correct values mostly but sometimes it gives readings of about 1200cm for a few intervals. The spikes happen when I move some solid object in front of the sensor, gradually bringing it closer or farther. When something static is placed in front of it, then there are no spikes.
wvmarle:
Do post your code and other info here as per forum guidelines.
How frequently do you take readings?
I take real-time readings using the serial port. The ones you see attached in the post are for a few seconds only.
I am sorry about not posting as per guidelines.
More members will see your code if posted properly. Read the how get the most out of this forum sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code in code tags. If the code is too large to post it can be attached.
It is much better if you post the images so that we do no have to download them. See How to post images.
I never experienced this really, moving the sensor by hand. At that kind of speeds (no more than 1 m/s or about 0.3% of the speed of sound) doppler shift should not be an issue - no way those transducers are that specific.
You should begin testing by running all the motors and props. Likely the props will produce ultrasonic noise that will mask the sensor pulse. Also the air turbulence will disport any echo.
Paul