Ultrasonic sensor noise

i am using ultrasonic sensor hc04 with arduino ,after 1 meter its distance not constant to detect human its very (its take jump) like 152 to 180 or 151 to 190 .
how i can filter this ?
i have useed buffer of 1000
but not solved.
please guide

I moved your topic to an appropriate forum category @edferc.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Hi, @edferc

Can you please post your code?

Can you please post a copy of your circuit a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

1 Like

I'm going to guess that you are using an Uno and there is not enough memory for a buffer of 1000 int.

You do not need to have a buffer at all when you are calculating the average. You only need to keep the total of the readings. You may need to use a long instead of an int to hold that total.

The distance will not change instantaneously, so its reasonable to use an average; however it would be more realistic to use an exponential moving average like this

new average = A*new reading + (1-A) * old average where A<1 so say let A=0.1

then you dont need a buffer

A "human" is not a good target - we are soft and funny shapes so ideally built for ultrasonic stealth.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.