What happens if an Ultrasonic Sensor HC-SR04 does not hit any object, for example if it is outdoors and is pointed straight up at the sky? Using the standard distance measuring equation will it return 0?
The sky is very far from us and dosen't catch any object with HC-SR04 and the max distance of taking distance of the sensor is 255 cm not more then that.
So, if there is any type of object within 255 cm it will surely Catch the object
If your object is not catching so pls share the code and check your board as well as connection as well as sensor
My use case is to detect when a metal plate falls down, it detects the plate just fine. I have only tested it inside, was wondering what would happen when moved outside and there is no object within 255cm
Just read the documentation on pulsein and found it should return 0 if no echo detected, that should mean if it just points to the sky it will read 0
If there is no object within 255 cm so sensor will not able to detect object so try falling metal plate within 255 cm and check the result or check the distance of the distance in serial monitor that sensor is working or not
That's an interesting assertion.
Baseless, but interesting.
There will always be an echo pulse; the echo pin goes high as soon as the outgoing ping has left, so your best bet is to specify a pulseIn timeout shorter than the default.
Hi,
If you use NewPing library, there is a parameter you can set to set maximum range.
If you try the library you will find it comes with quite few helpful examples.
Tom...
PS. Let NewPing do the range finding for you, much simpler and convenient.
If there is no object to detect there is no distance to measure the returned result is 0.
Fixed.
What do you Mean?
Request you to kindly share your code @picklesdoggo
To understand it, you have to put 2 and 2 together. The system works by timing return pulses. Obviously, to do that you have to wait for a return pulse after sending. How long do you want to wait before giving up, so you can send another pulse?
PulseIn() does that for you by returning 0 if a pulse has not been received within a defined time interval.
It's only when PulseIn is combined with the sensor that you can say, "pulsein should return 0 if no echo detected".
I mean "there is no inherent range limitation of 255cm for the HC-Sr04, as you implied"
In some sensor it take up to 255 cm and in some sensor it take up to 400 cm you can also check
I think you're confusing "sensor" with "software" - you can also check.
This is what I was looking for, probably should have RTFM first
The range of an ultrasonic sensor depends on both the sensor and the target characteristics. So you can't determine a "bare" fixed maximum range. You have to specify a target.
It would be calculated as follows: Speed of sound in air is |v|=343ms the distance between the moon and earth is about 384.4×106 meters. So distance divided by the speed is 384,400,000 m343ms=1120699.70845 seconds, about 13 days.
"In Space, no-one can hear your HC-SR04"