I have at least 3 each SR04 (can't read the last number if there is one) inexpensive ultrasonic sensors that all display similar problems. My problems.... all units are intermittent. There is oscillation happening with each device.
I have had some reasonable output a few times but even that is limited. I am powering these devices with 5vdc. I have tried triggering with 10 usec pulses and gradually increased the trigger length to 80 useconds, rise time in nano seconds, much faster than my scope's bandwidth, with no real change in performance. I have also added filter capacitors across the DC power which does seem to reduce the amplitude of the oscillations. Occasionally one will burp and I can see it responding to distance with a nice clear output waveform.
But even the output is questionable. For example, I put a sheet of paper in front of the transmitter/receiver and as I change the distance, the waveform changes in length....GREAT, AS EXPECTED! No cigar though because the distance response is only a few feet. Beyond that the waveform responds as if it was looking into infinity except it finds infinity located at a mear 2 1/2 - 3 feet!
The maximum response pulse width is about 3 1/2 milliseconds. Round trip time/foot is 1.8 milliseconds. Oh currently using a 20 usecond trigger. Right after making this measurement, it became unstable again.
IS THERE ANYBODY out there with success stories? Should I be using a different device? As it is now, what I have is completely inadequate.
I have used several HC-SR04 with success. One thing that I found was that the supply voltage needs to be a solid 5V. When I powered the Arduino from USB I had trouble. The supply voltage measured 4.8 V.
Thanks for the reply. There are many of these devices out in the great beyond, they should all or at least most work unless I have some that are defective. Your point about 5v--- I know mine is on the soft side, maybe in the 4.8 range. I will look into this later tonight when I have a chance. Strange that the voltage tolerance is that tight but things are what they are.
Target material will also affect range. You might detect a brick wall out to 3 feet but a cloth curtain hanging 1.5 feet away may not generate a strong enough echo.
Is the range really only 2-3 feet? The data sheet has it at 4m maximum which is over 16 feet. Mine cannot see office ceiling while its sitting on my desk.
foggysail:
Mine cannot see office ceiling while its sitting on my desk.
What is your office ceiling made of? Hanging acoustic-dampening tiles, like most offices? Concrete? Something in between? If the latter, then that's an issue. If the former though...
Instead of a sheet of paper, use a 12 x 6" piece of solid wood board or something similar (an unused wooden cutting board would be perfect) as your test target.
Beyond that, where did you get these sensors? If you got them off Ebay, drop shipped from China for a couple bucks each (I've seen such deals - 10 sensors for 15-20 dollars) - then you may have got a bad batch (or ripped off).
Since you seem to be getting some output that seems intermittent, try looking at the solder joints under a microscope; if any seem suspect, reflow them with a low-wattage, small tip soldering iron or hot-air reflow, and try it again.
That - or bite the bullet and purchase the more expensive Parallax PING sensors (which likely go through a real quality-control testing process)...
The problem was voltage, sort of. I measured the voltage on my development board and sure enough, only 4.5vdc. Then I measured the voltage at the power ends as they attach to the SR04 and WALLA! I measured only 3.8vdc even though the voltage source was 4.5.
I have the sensor connected via a 5 pin header connector (only 4 pins used) with the other ends connected to the develpoment board using common pin jumpers that most likely all of you have around your work places. The wire connector was female, it was making poor contact to the DC return header pin on the board. I clipped off the female connector and soldered the 5 Vss return directly to the development board.
I have three devices to play with and yes, they are the EBay cheapies and they all work. I have on order from EBay 5 each US-020's that are good for 7 meters or just over 20 feet or so. I believe these will meet my needs. To answer an earlier question regarding my ceiling--- its plaster.
Guys--- thank each of you for taking the time to offer suggestions. Great site.... even though I prefer using Microchip's C18 rather than the WIRE library, that is just a matter of personal choice and of course I gained experience with thier C first. There is a lot of hi tech engineering going on around here!!! Again-- THANKS