Hello, is there any way to extract a numric result out of hc-sr04?

we are trying to make a sonar but we want a numeric value and not a t/f one

What's that?

Welcome to the forum

Are you trying to use the HC-SR04 to measure distance ? If so, then given the time taken between sending a pulse and receiving back the echo and knowing the speed of sound in air then you can calculate the distance

You will find literally hundreds of projects on line showing you how to do this

If that is not what you are doing then please provide more detail

the one we currently use is this: https://www.youtube.com/watch?v=JvmIutmQd9U. we are new to Arduino and want to know if we can somehow extract the amount(I'm not sure it's the correct word) of sound waves that are coming back to us. I'm sorry if this isn't easy to understand English is not my first language.

It is not clear what you mean by "the amount" of sound waves

Try using Google Translate from your native language to English to explain what you want to do

sorry for not being clear, maybe you can explain to me how does the sensor work? does it give a
Boolean value for whether it senses something in front of it or not? our goal is to check how does the material of a cube affects the sensor detection of it.

The sensor works by sending out an ultrasonic pulse then detecting the echo. Using suitable software on an Arduino you can measure the time taken for the return journey

There is no measurement of the strength of the returned echo, at least not as far as I know

What is it that you are trying to measure

ok, thank you so much for the help! what I was trying to measure was the strength of the returned echo. my goal is to check if some materials can absorb some of the echo as part of a school science project. seems like it is not possible using Arduino so I'll search for another way. thanks again for all the help.

Ah, so when you said "t/f" you mean true/false. Got it.

No, that is not how these sensors work. They measure the distance between the sensor and an object, that is the amount you can get. The distance is measured by timing the sound wave as it travels from the sensor to the object and back to the sensor. The Arduino can then convert that time into a distance.

It does not work by measuring the strength of the returning wave, you can not get that measurement from the sensor.

It is not possible with hc-sr04. It is possible with Arduino if you use a sensor that can measure the strength of the returning wave. I do not have a suggestion for a sensor like that.

More accurately, they allow you to measure the distance between the sensor and an object, as you and I have described

An ultrasonic microphone and amplifier is used for that, sampled at 2x the frequency of the ultrasonic pulse, minimum. This would be difficult to implement with minimal Arduinos like the classic Uno.

This could be done, but it wouldn't be simple to do.

The yellow line in the following graph shows the signal received by the HC-SR04, after some amplification by the HC-SR04. The yellow trace is the input to a comparator which controls the echo pin. The red line is the echo pin output.

The amplifier output could be processed to estimate the strength of the returned echo. (This is what you could sample at 2x the frequency of the pulses, minimum, as mentioned in post #12.)

Note the upper part of the yellow trace is clipped. The lower part would be the source of return strength information. The David Pilling website discusses the clipping and use of the lower part by the comparator.

image

Graph is from: David Pilling : HC-SR04

Another good website to help you understand how the sensor works: Emil's Projects & Reviews: Making a better HC-SR04 Echo Locator

Glad you got it. I was about to guess. tee hee.